More refactoring

This commit is contained in:
James Seibel
2022-07-19 20:22:11 -05:00
parent d5f7818252
commit c4a9a72118
10 changed files with 40 additions and 33 deletions
@@ -23,12 +23,12 @@ package com.seibel.lod.core.util;
* Miscellaneous string helper functions.
*
* @author James Seibel
* @version 2022-7-18
* @version 2022-7-19
*/
public class StringUtil
{
/**
* Returns the n-th index of the given string
* Returns the n-th index of the given string. <br> <br>
*
* Original source: https://stackoverflow.com/questions/3976616/how-to-find-nth-occurrence-of-character-in-a-string
*/
@@ -1,4 +1,4 @@
package testItems.dependencyInjection.objects;
package testItems.eventInjection.abstractObjects;
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
@@ -1,6 +1,6 @@
package testItems.dependencyInjection.implementations;
package testItems.eventInjection.objects;
import testItems.dependencyInjection.objects.DhApiTestEvent;
import testItems.eventInjection.abstractObjects.DhApiTestEvent;
/**
* Dummy test event for unit tests.
@@ -1,6 +1,6 @@
package testItems.dependencyInjection.implementations;
package testItems.eventInjection.objects;
import testItems.dependencyInjection.objects.DhApiTestEvent;
import testItems.eventInjection.abstractObjects.DhApiTestEvent;
/**
* Dummy test event for unit tests.
@@ -1,4 +1,4 @@
package testItems.dependencyInjection.interfaces;
package testItems.singletonInjection.interfaces;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
@@ -1,4 +1,4 @@
package testItems.dependencyInjection.interfaces;
package testItems.singletonInjection.interfaces;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
@@ -1,8 +1,8 @@
package testItems.dependencyInjection.objects;
package testItems.singletonInjection.objects;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
import testItems.dependencyInjection.interfaces.ISingletonTestOne;
import testItems.dependencyInjection.interfaces.ISingletonTestTwo;
import testItems.singletonInjection.interfaces.ISingletonTestOne;
import testItems.singletonInjection.interfaces.ISingletonTestTwo;
/**
* Dummy test implementation object for dependency injection unit tests.
@@ -1,8 +1,8 @@
package testItems.dependencyInjection.objects;
package testItems.singletonInjection.objects;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
import testItems.dependencyInjection.interfaces.ISingletonTestOne;
import testItems.dependencyInjection.interfaces.ISingletonTestTwo;
import testItems.singletonInjection.interfaces.ISingletonTestOne;
import testItems.singletonInjection.interfaces.ISingletonTestTwo;
import tests.DependencyInjectorTest;
/**
@@ -1,8 +1,8 @@
package testItems.dependencyInjection.objects;
package testItems.singletonInjection.objects;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
import testItems.dependencyInjection.interfaces.ISingletonTestOne;
import testItems.dependencyInjection.interfaces.ISingletonTestTwo;
import testItems.singletonInjection.interfaces.ISingletonTestOne;
import testItems.singletonInjection.interfaces.ISingletonTestTwo;
import tests.DependencyInjectorTest;
/**
+22 -15
View File
@@ -4,16 +4,19 @@ import com.seibel.lod.core.handlers.dependencyInjection.DependencyInjector;
import com.seibel.lod.core.handlers.dependencyInjection.DhApiEventInjector;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
import com.seibel.lod.core.handlers.dependencyInjection.OverrideInjector;
import org.junit.Assert;
import org.junit.Test;
import testItems.dependencyInjection.implementations.DhTestEvent;
import testItems.dependencyInjection.implementations.DhTestEventAlt;
import testItems.dependencyInjection.interfaces.ISingletonTestOne;
import testItems.dependencyInjection.interfaces.ISingletonTestTwo;
import testItems.dependencyInjection.objects.ConcreteSingletonTestBoth;
import testItems.dependencyInjection.objects.ConcreteSingletonTestOne;
import testItems.dependencyInjection.objects.ConcreteSingletonTestTwo;
import testItems.dependencyInjection.objects.DhApiTestEvent;
import testItems.eventInjection.objects.DhTestEvent;
import testItems.eventInjection.objects.DhTestEventAlt;
import testItems.singletonInjection.interfaces.ISingletonTestOne;
import testItems.singletonInjection.interfaces.ISingletonTestTwo;
import testItems.singletonInjection.objects.ConcreteSingletonTestBoth;
import testItems.singletonInjection.objects.ConcreteSingletonTestOne;
import testItems.singletonInjection.objects.ConcreteSingletonTestTwo;
import testItems.eventInjection.abstractObjects.DhApiTestEvent;
import testItems.overrideInjection.interfaces.IOverrideTest;
import testItems.overrideInjection.objects.OverrideTestAssembly;
import java.util.ArrayList;
@@ -28,11 +31,11 @@ public class DependencyInjectorTest
@Test
public void testSingleImplementationSingleton()
{
// clear the previous dependencies and only allow single dependencies
// Injector setup
DependencyInjector<IBindable> TEST_SINGLETON_HANDLER = new DependencyInjector<>(IBindable.class, false);
// pre-setup
// pre-dependency setup
Assert.assertNull(ISingletonTestOne.class.getSimpleName() + " should not have been bound.", TEST_SINGLETON_HANDLER.get(ISingletonTestOne.class));
@@ -62,11 +65,11 @@ public class DependencyInjectorTest
@Test
public void testMultipleImplementationSingleton()
{
// clear the previous dependencies and only allow single dependencies
// Injector setup
DependencyInjector<IBindable> TEST_SINGLETON_HANDLER = new DependencyInjector<IBindable>(IBindable.class, false);
// pre-setup
// pre-dependency setup
Assert.assertNull(ISingletonTestOne.class.getSimpleName() + " should not have been bound.", TEST_SINGLETON_HANDLER.get(ISingletonTestOne.class));
@@ -91,13 +94,12 @@ public class DependencyInjectorTest
@Test
public void testEventDependencies() // this also tests list dependencies since there can be more than one event handler bound per event
{
// clear the previous dependencies and only allow single dependencies
// Injector setup
DependencyInjector<IBindable> TEST_SINGLETON_HANDLER = new DependencyInjector<>(IBindable.class, false);
// setup the list (event) dependency handler
DhApiEventInjector TEST_EVENT_HANDLER = new DhApiEventInjector();
// pre-setup
// pre-dependency setup
Assert.assertNull("Nothing should have been bound.", TEST_EVENT_HANDLER.get(DhApiTestEvent.class));
@@ -151,6 +153,11 @@ public class DependencyInjectorTest
}
Assert.assertNotNull(ISingletonTestTwo.class.getSimpleName() + " not bound.", testInterTwo);
Assert.assertEquals(ISingletonTestTwo.class.getSimpleName() + " incorrect value.", testInterTwo.getValue(), ConcreteSingletonTestBoth.VALUE);
}
}