Search in sources :

Example 11 with ContextImpl

use of org.terasology.engine.context.internal.ContextImpl in project Terasology by MovingBlocks.

the class OwnershipHelperTest method setup.

@BeforeEach
public void setup() {
    ContextImpl context = new ContextImpl();
    context.put(ModuleManager.class, moduleManager);
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    context.put(NetworkSystem.class, networkSystem);
    context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
    CoreRegistry.setContext(context);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    entityManager = context.get(EngineEntityManager.class);
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) NetworkSystem(org.terasology.engine.network.NetworkSystem) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) ContextImpl(org.terasology.engine.context.internal.ContextImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with ContextImpl

use of org.terasology.engine.context.internal.ContextImpl in project Terasology by MovingBlocks.

the class VisualCharacterSystemTest method setup.

@BeforeEach
public void setup() throws Exception {
    this.system = new VisualCharacterSystem();
    Context context = new ContextImpl();
    this.localPlayer = Mockito.mock(LocalPlayer.class);
    context.put(LocalPlayer.class, localPlayer);
    Mockito.doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return clientEntityReturnedByLocalPlayer;
        }
    }).when(localPlayer).getClientEntity();
    this.entityManager = Mockito.mock(EntityManager.class);
    Mockito.doReturn(Mockito.mock(EntityBuilder.class)).when(entityManager).newBuilder();
    context.put(EntityManager.class, this.entityManager);
    InjectionHelper.inject(system, context);
    system.setCreateAndAttachVisualEntityStrategy((entityBuilder, characterEntity) -> Mockito.mock(EntityRef.class));
}
Also used : Context(org.terasology.engine.context.Context) Answer(org.mockito.stubbing.Answer) EntityManager(org.terasology.engine.entitySystem.entity.EntityManager) LocalPlayer(org.terasology.engine.logic.players.LocalPlayer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) EntityBuilder(org.terasology.engine.entitySystem.entity.EntityBuilder) ContextImpl(org.terasology.engine.context.internal.ContextImpl) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with ContextImpl

use of org.terasology.engine.context.internal.ContextImpl in project Terasology by MovingBlocks.

the class EntitySerializerTest method setupClass.

@BeforeAll
public static void setupClass() throws Exception {
    context = new ContextImpl();
    CoreRegistry.setContext(context);
    context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
    moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManagerImpl();
    assetTypeManager.createAssetType(Prefab.class, PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
}
Also used : PojoPrefab(org.terasology.engine.entitySystem.prefab.internal.PojoPrefab) ModuleAwareAssetTypeManager(org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) ModuleAwareAssetTypeManagerImpl(org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManagerImpl) ContextImpl(org.terasology.engine.context.internal.ContextImpl) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 14 with ContextImpl

use of org.terasology.engine.context.internal.ContextImpl in project Terasology by MovingBlocks.

the class ComponentSerializerTest method setup.

@BeforeEach
public void setup() {
    context = new ContextImpl();
    context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
    context.put(ModuleManager.class, moduleManager);
    CoreRegistry.setContext(context);
    Reflections reflections = new Reflections(getClass().getClassLoader());
    TypeHandlerLibrary serializationLibrary = new TypeHandlerLibraryImpl(reflections);
    serializationLibrary.addTypeHandler(Vector3f.class, new Vector3fTypeHandler());
    serializationLibrary.addTypeHandler(Quaternionf.class, new QuaternionfTypeHandler());
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    EngineEntityManager entityManager = context.get(EngineEntityManager.class);
    entityManager.getComponentLibrary().register(new ResourceUrn("test", "gettersetter"), GetterSetterComponent.class);
    entityManager.getComponentLibrary().register(new ResourceUrn("test", "string"), StringComponent.class);
    entityManager.getComponentLibrary().register(new ResourceUrn("test", "integer"), IntegerComponent.class);
    ComponentLibrary componentLibrary = entityManager.getComponentLibrary();
    componentSerializer = new ComponentSerializer(componentLibrary, serializationLibrary);
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) QuaternionfTypeHandler(org.terasology.engine.persistence.typeHandling.mathTypes.QuaternionfTypeHandler) Vector3fTypeHandler(org.terasology.engine.persistence.typeHandling.mathTypes.Vector3fTypeHandler) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) NetworkSystem(org.terasology.engine.network.NetworkSystem) ComponentLibrary(org.terasology.engine.entitySystem.metadata.ComponentLibrary) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) ContextImpl(org.terasology.engine.context.internal.ContextImpl) TypeHandlerLibraryImpl(org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) ComponentSerializer(org.terasology.engine.persistence.serializers.ComponentSerializer) Reflections(org.reflections.Reflections) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with ContextImpl

use of org.terasology.engine.context.internal.ContextImpl in project Terasology by MovingBlocks.

the class BaseEntityRefTest method setupClass.

@BeforeAll
public static void setupClass() throws Exception {
    context = new ContextImpl();
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManagerImpl();
    assetTypeManager.createAssetType(Prefab.class, PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
    CoreRegistry.setContext(context);
}
Also used : PojoPrefab(org.terasology.engine.entitySystem.prefab.internal.PojoPrefab) ModuleAwareAssetTypeManager(org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager) ModuleAwareAssetTypeManagerImpl(org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManagerImpl) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) ContextImpl(org.terasology.engine.context.internal.ContextImpl) ModuleManager(org.terasology.engine.core.module.ModuleManager) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

ContextImpl (org.terasology.engine.context.internal.ContextImpl)26 BeforeEach (org.junit.jupiter.api.BeforeEach)13 ModuleManager (org.terasology.engine.core.module.ModuleManager)8 RecordAndReplayCurrentStatus (org.terasology.engine.recording.RecordAndReplayCurrentStatus)8 Context (org.terasology.engine.context.Context)7 ModuleAwareAssetTypeManager (org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager)7 PojoPrefab (org.terasology.engine.entitySystem.prefab.internal.PojoPrefab)6 ModuleAwareAssetTypeManagerImpl (org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManagerImpl)6 BeforeAll (org.junit.jupiter.api.BeforeAll)5 Test (org.junit.jupiter.api.Test)4 PojoPrefabManager (org.terasology.engine.entitySystem.prefab.internal.PojoPrefabManager)4 NetworkSystem (org.terasology.engine.network.NetworkSystem)4 TypeHandlerLibrary (org.terasology.persistence.typeHandling.TypeHandlerLibrary)4 Reflections (org.reflections.Reflections)3 ComponentLibrary (org.terasology.engine.entitySystem.metadata.ComponentLibrary)3 EntitySystemLibrary (org.terasology.engine.entitySystem.metadata.EntitySystemLibrary)3 TypeHandlerLibraryImpl (org.terasology.engine.persistence.typeHandling.TypeHandlerLibraryImpl)3 Config (org.terasology.engine.config.Config)2 EnvironmentSwitchHandler (org.terasology.engine.core.bootstrap.EnvironmentSwitchHandler)2 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)2