use of org.terasology.context.internal.ContextImpl in project Terasology by MovingBlocks.
the class TreeTests method setup.
@Before
public void setup() {
ContextImpl context = new ContextImpl();
CoreRegistry.setContext(context);
// Needed only as long as #1536 is unresolved
context.put(Config.class, new Config(new MockContext()));
blockManager = Mockito.mock(BlockManager.class);
Block air = blockManager.getBlock(BlockManager.AIR_ID);
biomeManager = Mockito.mock(BiomeManager.class);
Mockito.when(blockManager.getBlock(Matchers.<BlockUri>any())).thenReturn(air);
Mockito.when(blockManager.getBlock(Matchers.<String>any())).thenReturn(air);
context.put(BlockManager.class, blockManager);
}
use of org.terasology.context.internal.ContextImpl in project Terasology by MovingBlocks.
the class ComponentSerializerTest method setup.
@Before
public void setup() {
context = new ContextImpl();
context.put(ModuleManager.class, moduleManager);
CoreRegistry.setContext(context);
TypeSerializationLibrary serializationLibrary = new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary);
serializationLibrary.add(Vector3f.class, new Vector3fTypeHandler());
serializationLibrary.add(Quat4f.class, new Quat4fTypeHandler());
NetworkSystem networkSystem = mock(NetworkSystem.class);
context.put(NetworkSystem.class, networkSystem);
EntitySystemSetupUtil.addReflectionBasedLibraries(context);
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
EngineEntityManager entityManager = context.get(EngineEntityManager.class);
entityManager.getComponentLibrary().register(new SimpleUri("test", "gettersetter"), GetterSetterComponent.class);
entityManager.getComponentLibrary().register(new SimpleUri("test", "string"), StringComponent.class);
entityManager.getComponentLibrary().register(new SimpleUri("test", "integer"), IntegerComponent.class);
ComponentLibrary componentLibrary = entityManager.getComponentLibrary();
componentSerializer = new ComponentSerializer(componentLibrary, serializationLibrary);
}
use of org.terasology.context.internal.ContextImpl in project Terasology by MovingBlocks.
the class InjectionHelperTest method testConstructorInjectionNoDefaultConstructorForFallback.
@Test(expected = NoSuchElementException.class)
public void testConstructorInjectionNoDefaultConstructorForFallback() {
Context context = new ContextImpl();
context.put(ServiceA.class, serviceA);
// context.put(ServiceB.class, serviceB);
// there is only one constructor for serviceB which is not present on the context.
// a default constructor is not available, so the injection fails.
InjectionHelper.createWithConstructorInjection(ConstructorB.class, context);
}
use of org.terasology.context.internal.ContextImpl in project Terasology by MovingBlocks.
the class InjectionHelperTest method testConstructorInjectionNotAllParametersPopulatedFallback.
@Test
public void testConstructorInjectionNotAllParametersPopulatedFallback() {
Context context = new ContextImpl();
context.put(ServiceA.class, serviceA);
// context.put(ServiceB.class, serviceB);
ConstructorA_AB constructorA_AB = InjectionHelper.createWithConstructorInjection(ConstructorA_AB.class, context);
// the one-arg constructor is used as it can be populated with serviceA which is available
assertThat(constructorA_AB.getServiceA(), is(serviceA));
assertThat(constructorA_AB.getServiceB(), is(nullValue()));
}
use of org.terasology.context.internal.ContextImpl in project Terasology by MovingBlocks.
the class BindsSubsystemTest method setUp.
@Before
public void setUp() {
bindsSubsystem = new BindsSubsystem();
bindsConfiguration = new BindsConfigAdapter(new BindsConfig());
context = new ContextImpl();
context.put(BindsConfiguration.class, bindsConfiguration);
bindsSubsystem.preInitialise(context);
setUpMockModuleEnvironment();
}
Aggregations