use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class ComponentSerializerTest method testComponentTypeIdUsedWhenLookupTableEnabledForComponentDeltas.
@Test
public void testComponentTypeIdUsedWhenLookupTableEnabledForComponentDeltas() throws Exception {
componentSerializer.setIdMapping(ImmutableMap.<Class<? extends Component>, Integer>builder().put(StringComponent.class, 413).build());
EntityData.Component componentData = componentSerializer.serialize(new StringComponent("Original"), new StringComponent("Value"));
assertEquals(413, componentData.getTypeIndex());
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testAddComponentEventSent.
@Test
public void testAddComponentEventSent() {
EventSystem eventSystem = mock(EventSystem.class);
entityManager.setEventSystem(eventSystem);
EntityRef entity1 = entityManager.create();
StringComponent comp = entity1.addComponent(new StringComponent());
verify(eventSystem).send(entity1, OnAddedComponent.newInstance(), comp);
verify(eventSystem).send(entity1, OnActivatedComponent.newInstance(), comp);
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testGetComponentCount.
@Test
public void testGetComponentCount() {
entityManager.create().addComponent(new StringComponent());
entityManager.create().addComponent(new StringComponent());
assertEquals(2, entityManager.getCountOfEntitiesWith(StringComponent.class));
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testCreateEntityWithComponent.
@Test
public void testCreateEntityWithComponent() {
StringComponent comp = new StringComponent("Test");
EntityRef entity = entityManager.create(comp);
assertNotNull(entity);
assertNotNull(entity.getComponent(StringComponent.class));
assertEquals(comp, entity.getComponent(StringComponent.class));
assertEquals(CHUNK, entity.getScope());
assertTrue(entityManager.getGlobalPool().contains(entity.getId()));
assertFalse(entityManager.getSectorManager().contains(entity.getId()));
}
use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method setup.
@Before
public void setup() {
context.put(NetworkSystem.class, mock(NetworkSystem.class));
EntitySystemSetupUtil.addReflectionBasedLibraries(context);
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
entityManager = (PojoEntityManager) context.get(EntityManager.class);
PrefabData protoPrefab = new PrefabData();
protoPrefab.addComponent(new StringComponent("Test"));
prefab = Assets.generateAsset(new ResourceUrn("unittest:myprefab"), protoPrefab, Prefab.class);
}
Aggregations