use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class EntitySerializerTest method testMappedTypeHandling.
@Test
public void testMappedTypeHandling() throws Exception {
componentLibrary.register(new SimpleUri("test", "mappedtype"), MappedTypeComponent.class);
EntityRef entity = entityManager.create();
entity.addComponent(new MappedTypeComponent());
EntityData.Entity entityData = entitySerializer.serialize(entity);
long nextId = entityManager.getNextId();
entityManager.clear();
entityManager.setNextId(nextId);
EntityRef loadedEntity = entitySerializer.deserialize(entityData);
assertTrue(loadedEntity.exists());
assertTrue(loadedEntity.hasComponent(MappedTypeComponent.class));
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class EntitySerializerTest method setup.
@Before
public void setup() {
context.put(NetworkSystem.class, mock(NetworkSystem.class));
EntitySystemSetupUtil.addReflectionBasedLibraries(context);
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
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);
entitySerializer = new EntitySerializer(entityManager);
componentLibrary = entityManager.getComponentLibrary();
PrefabData prefabData = new PrefabData();
prefabData.addComponent(new StringComponent("Value"));
prefab = Assets.generateAsset(new ResourceUrn("test:Test"), prefabData, Prefab.class);
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class BindsSubsystemTest method testUpdateBinds.
@Test
public void testUpdateBinds() {
registerBindButtonClasses.add(TestEventButton.class);
bindsSubsystem.updateConfigWithDefaultBinds();
List<Input> defaultBinds = bindsSubsystem.getDefaultBindsConfig().getBinds(new SimpleUri(TEST_MODULE, "testEvent"));
assertThat(defaultBinds.size(), is(1));
assertThat(defaultBinds.get(0).getType(), is(InputType.KEY));
assertThat(defaultBinds.get(0).getId(), is(KeyId.T));
assertThat(defaultBinds.get(0).getName(), is(Key.T.getName()));
assertThat(defaultBinds.get(0).getDisplayName(), is(Key.T.getDisplayName()));
List<Input> binds = bindsSubsystem.getBindsConfig().getBinds(new SimpleUri(TEST_MODULE, "testEvent"));
assertThat(binds.size(), is(1));
assertThat(binds.get(0).getType(), is(InputType.KEY));
assertThat(binds.get(0).getId(), is(KeyId.T));
assertThat(binds.get(0).getName(), is(Key.T.getName()));
assertThat(binds.get(0).getDisplayName(), is(Key.T.getDisplayName()));
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class PojoEventSystemTests method testChildEvent.
@Test
public void testChildEvent() {
entity.addComponent(new IntegerComponent());
TestEventHandler handler = new TestEventHandler();
eventSystem.registerEvent(new SimpleUri("test:childEvent"), TestChildEvent.class);
eventSystem.registerEventHandler(handler);
TestChildEvent event = new TestChildEvent();
eventSystem.send(entity, event);
assertEquals(1, handler.childEventReceived.size());
assertEquals(1, handler.receivedList.size());
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class FieldMetadataTest method testOwnsAnnotationCollectionProcessed.
@Test
public void testOwnsAnnotationCollectionProcessed() throws NoSuchMethodException {
ComponentMetadata<OwnedCollectionComponent> classMetadata = new ComponentMetadata<>(new SimpleUri("unittest:OwnedCollectionComponent"), OwnedCollectionComponent.class, factory, copyStrategyLibrary);
ComponentFieldMetadata metadata = classMetadata.getField("items");
assertTrue(metadata.isOwnedReference());
}
Aggregations