Search in sources :

Example 1 with OwnerComponent

use of org.terasology.entitySystem.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());
    assertEqualsContent(Lists.newArrayList(ownedEntity), helper.listOwnedEntities(ownerEntity));
}
Also used : OwnerComponent(org.terasology.entitySystem.stubs.OwnerComponent) OwnershipHelper(org.terasology.entitySystem.entity.internal.OwnershipHelper) EntityRef(org.terasology.entitySystem.entity.EntityRef) Test(org.junit.Test)

Example 2 with OwnerComponent

use of org.terasology.entitySystem.stubs.OwnerComponent in project Terasology by MovingBlocks.

the class ComponentMetadataTest method testOwnsReferencesPopulated.

@Test
public void testOwnsReferencesPopulated() {
    EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, new TypeSerializationLibrary(reflectFactory, copyStrategies));
    ComponentLibrary lib = entitySystemLibrary.getComponentLibrary();
    lib.register(new SimpleUri("unittest:owner"), OwnerComponent.class);
    ComponentMetadata<OwnerComponent> metadata = lib.getMetadata(OwnerComponent.class);
    assertTrue(metadata.isReferenceOwner());
}
Also used : OwnerComponent(org.terasology.entitySystem.stubs.OwnerComponent) SimpleUri(org.terasology.engine.SimpleUri) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) Test(org.junit.Test)

Example 3 with OwnerComponent

use of org.terasology.entitySystem.stubs.OwnerComponent in project Terasology by MovingBlocks.

the class FieldMetadataTest method testOwnsAnnotationProcessed.

@Test
public void testOwnsAnnotationProcessed() throws NoSuchMethodException {
    ComponentMetadata<OwnerComponent> classMetadata = new ComponentMetadata<>(new SimpleUri("unittest:owner"), OwnerComponent.class, factory, copyStrategyLibrary);
    ComponentFieldMetadata metadata = classMetadata.getField("child");
    assertTrue(metadata.isOwnedReference());
}
Also used : OwnerComponent(org.terasology.entitySystem.stubs.OwnerComponent) SimpleUri(org.terasology.engine.SimpleUri) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 OwnerComponent (org.terasology.entitySystem.stubs.OwnerComponent)3 SimpleUri (org.terasology.engine.SimpleUri)2 EntityRef (org.terasology.entitySystem.entity.EntityRef)1 OwnershipHelper (org.terasology.entitySystem.entity.internal.OwnershipHelper)1 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)1