Search in sources :

Example 1 with RelationshipTypes

use of com.enonic.xp.schema.relationship.RelationshipTypes in project xp by enonic.

the class ApplicationInfoServiceImplTest method mockRelationshipTypes.

private void mockRelationshipTypes(final ApplicationKey applicationKey) {
    final RelationshipTypes relationshipTypes = RelationshipTypes.from(RelationshipType.create().name("myapplication:person").build(), RelationshipType.create().name("myapplication:site").build());
    Mockito.when(this.relationshipTypeService.getByApplication(applicationKey)).thenReturn(relationshipTypes);
}
Also used : RelationshipTypes(com.enonic.xp.schema.relationship.RelationshipTypes)

Example 2 with RelationshipTypes

use of com.enonic.xp.schema.relationship.RelationshipTypes in project xp by enonic.

the class RelationshipTypeServiceImpl method getAll.

@Override
public RelationshipTypes getAll() {
    final Set<RelationshipType> list = new LinkedHashSet<>(this.builtInTypes.getAll().getList());
    for (final Application application : this.applicationService.getInstalledApplications()) {
        final RelationshipTypes types = getByApplication(application.getKey());
        list.addAll(types.getList());
    }
    return RelationshipTypes.from(list);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) RelationshipTypes(com.enonic.xp.schema.relationship.RelationshipTypes) RelationshipType(com.enonic.xp.schema.relationship.RelationshipType) Application(com.enonic.xp.app.Application)

Example 3 with RelationshipTypes

use of com.enonic.xp.schema.relationship.RelationshipTypes in project xp by enonic.

the class RelationshipTypeServiceImplTest method testSystemTypes.

@Test
public void testSystemTypes() {
    RelationshipTypes relationshipTypes = service.getAll();
    assertNotNull(relationshipTypes);
    assertEquals(2, relationshipTypes.getSize());
    relationshipTypes = service.getByApplication(ApplicationKey.SYSTEM);
    assertNotNull(relationshipTypes);
    assertEquals(2, relationshipTypes.getSize());
    RelationshipType relationshipType = service.getByName(RelationshipTypeName.PARENT);
    assertNotNull(relationshipType);
    relationshipType = service.getByName(RelationshipTypeName.REFERENCE);
    assertNotNull(relationshipType);
}
Also used : RelationshipTypes(com.enonic.xp.schema.relationship.RelationshipTypes) RelationshipType(com.enonic.xp.schema.relationship.RelationshipType) Test(org.junit.jupiter.api.Test) AbstractSchemaTest(com.enonic.xp.core.impl.schema.AbstractSchemaTest)

Example 4 with RelationshipTypes

use of com.enonic.xp.schema.relationship.RelationshipTypes in project xp by enonic.

the class BuiltinRelationshipTypesTest method testGetAll.

@Test
public void testGetAll() {
    final RelationshipTypes types = new BuiltinRelationshipTypes().getAll();
    assertEquals(2, types.getSize());
    assertType(types.get(0), RelationshipTypeName.REFERENCE, true);
    assertType(types.get(1), RelationshipTypeName.PARENT, true);
}
Also used : RelationshipTypes(com.enonic.xp.schema.relationship.RelationshipTypes) Test(org.junit.jupiter.api.Test)

Example 5 with RelationshipTypes

use of com.enonic.xp.schema.relationship.RelationshipTypes in project xp by enonic.

the class ApplicationInfoServiceImplTest method testRelationshipTypes.

@Test
public void testRelationshipTypes() {
    mockRelationshipTypes(this.applicationKey);
    final RelationshipTypes relationshipTypes = this.service.getRelationshipTypes(this.applicationKey);
    assertEquals(relationshipTypes.getSize(), 2);
}
Also used : RelationshipTypes(com.enonic.xp.schema.relationship.RelationshipTypes) Test(org.junit.jupiter.api.Test)

Aggregations

RelationshipTypes (com.enonic.xp.schema.relationship.RelationshipTypes)7 Test (org.junit.jupiter.api.Test)5 RelationshipType (com.enonic.xp.schema.relationship.RelationshipType)4 AbstractSchemaTest (com.enonic.xp.core.impl.schema.AbstractSchemaTest)3 Application (com.enonic.xp.app.Application)1 LinkedHashSet (java.util.LinkedHashSet)1