use of org.terasology.unittest.stubs.OwnerComponent in project Terasology by MovingBlocks.
the class ComponentMetadataTest method testOwnsReferencesPopulated.
@Test
public void testOwnsReferencesPopulated() {
Reflections reflections = new Reflections(getClass().getClassLoader());
EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, new TypeHandlerLibraryImpl(reflections));
ComponentLibrary lib = entitySystemLibrary.getComponentLibrary();
lib.register(new ResourceUrn("unittest:owner"), OwnerComponent.class);
ComponentMetadata<OwnerComponent> metadata = lib.getMetadata(OwnerComponent.class);
assertTrue(metadata.isReferenceOwner());
}
use of org.terasology.unittest.stubs.OwnerComponent in project Terasology by MovingBlocks.
the class FieldMetadataTest method testOwnsAnnotationProcessed.
@Test
public void testOwnsAnnotationProcessed() throws NoSuchMethodException {
ComponentMetadata<OwnerComponent> classMetadata = new ComponentMetadata<>(new ResourceUrn("unittest:owner"), OwnerComponent.class, factory, copyStrategyLibrary);
ComponentFieldMetadata metadata = classMetadata.getField("child");
assertTrue(metadata.isOwnedReference());
}
use of org.terasology.unittest.stubs.OwnerComponent in project Terasology by MovingBlocks.
the class OwnershipHelperTest method testListsOwnedEntities.
@Test
public void testListsOwnedEntities() {
EntityRef ownedEntity = entityManager.create();
OwnerComponent ownerComp = new OwnerComponent();
ownerComp.child = ownedEntity;
EntityRef ownerEntity = entityManager.create(ownerComp);
OwnershipHelper helper = new OwnershipHelper(entityManager.getComponentLibrary());
ArrayList<EntityRef> target = Lists.newArrayList(helper.listOwnedEntities(ownerEntity));
assertEquals(target.size(), 1);
assertEquals(target.get(0), ownedEntity);
}
Aggregations