More test refactoring

This commit is contained in:
James Seibel
2022-07-20 07:00:11 -05:00
parent c4a9a72118
commit 0e73aa1820
3 changed files with 25 additions and 6 deletions
@@ -1,5 +1,6 @@
package testItems.singletonInjection.objects;
import com.seibel.lod.core.handlers.dependencyInjection.DependencyInjector;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
import testItems.singletonInjection.interfaces.ISingletonTestOne;
import testItems.singletonInjection.interfaces.ISingletonTestTwo;
@@ -13,14 +14,20 @@ import tests.DependencyInjectorTest;
*/
public class ConcreteSingletonTestOne implements ISingletonTestOne, IBindable
{
private final DependencyInjector<IBindable> dependencyInjector;
private ISingletonTestTwo testInterTwo;
public static int VALUE = 1;
public ConcreteSingletonTestOne(DependencyInjector<IBindable> newDependencyInjector)
{
dependencyInjector = newDependencyInjector;
}
@Override
public void finishDelayedSetup() { testInterTwo = DependencyInjectorTest.TEST_SINGLETON_HANDLER.get(ISingletonTestTwo.class, true); }
public void finishDelayedSetup() { testInterTwo = dependencyInjector.get(ISingletonTestTwo.class, true); }
@Override
public boolean getDelayedSetupComplete() { return testInterTwo != null; }
@@ -1,5 +1,6 @@
package testItems.singletonInjection.objects;
import com.seibel.lod.core.handlers.dependencyInjection.DependencyInjector;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
import testItems.singletonInjection.interfaces.ISingletonTestOne;
import testItems.singletonInjection.interfaces.ISingletonTestTwo;
@@ -13,18 +14,24 @@ import tests.DependencyInjectorTest;
*/
public class ConcreteSingletonTestTwo implements ISingletonTestTwo, IBindable
{
private final DependencyInjector<IBindable> dependencyInjector;
private ISingletonTestOne testInterOne;
public static int VALUE = 2;
public ConcreteSingletonTestTwo(DependencyInjector<IBindable> newDependencyInjector)
{
dependencyInjector = newDependencyInjector;
}
@Override
public void finishDelayedSetup() { testInterOne = DependencyInjectorTest.TEST_SINGLETON_HANDLER.get(ISingletonTestOne.class, true); }
public void finishDelayedSetup() { testInterOne = dependencyInjector.get(ISingletonTestOne.class, true); }
@Override
public boolean getDelayedSetupComplete() { return testInterOne != null; }
@Override
public int getValue() { return VALUE; }
@@ -1,5 +1,7 @@
package tests;
import com.seibel.lod.core.api.external.items.enums.override.EDhApiOverridePriority;
import com.seibel.lod.core.enums.override.EApiOverridePriority;
import com.seibel.lod.core.handlers.dependencyInjection.DependencyInjector;
import com.seibel.lod.core.handlers.dependencyInjection.DhApiEventInjector;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
@@ -9,6 +11,9 @@ import org.junit.Assert;
import org.junit.Test;
import testItems.eventInjection.objects.DhTestEvent;
import testItems.eventInjection.objects.DhTestEventAlt;
import testItems.overrideInjection.objects.OverrideTestCore;
import testItems.overrideInjection.objects.OverrideTestPrimary;
import testItems.overrideInjection.objects.OverrideTestSecondary;
import testItems.singletonInjection.interfaces.ISingletonTestOne;
import testItems.singletonInjection.interfaces.ISingletonTestTwo;
import testItems.singletonInjection.objects.ConcreteSingletonTestBoth;
@@ -23,7 +28,7 @@ import java.util.ArrayList;
/**
* @author James Seibel
* @version 2022-7-19
* @version 2022-7-20
*/
public class DependencyInjectorTest
{
@@ -40,8 +45,8 @@ public class DependencyInjectorTest
// dependency setup
TEST_SINGLETON_HANDLER.bind(ISingletonTestOne.class, new ConcreteSingletonTestOne());
TEST_SINGLETON_HANDLER.bind(ISingletonTestTwo.class, new ConcreteSingletonTestTwo());
TEST_SINGLETON_HANDLER.bind(ISingletonTestOne.class, new ConcreteSingletonTestOne(TEST_SINGLETON_HANDLER));
TEST_SINGLETON_HANDLER.bind(ISingletonTestTwo.class, new ConcreteSingletonTestTwo(TEST_SINGLETON_HANDLER));
TEST_SINGLETON_HANDLER.runDelayedSetup();