@Test void testGetLabelledObjectIdentity() { Repository repository = mock(Repository.class); EntityType entityType = mock(EntityType.class); when(entityType.getLabel()).thenReturn("typeLabel"); Attribute idAttr = mock(Attribute.class); when(idAttr.getDataType()).thenReturn(STRING); when(entityType.getIdAttribute()).thenReturn(idAttr); when(repository.getEntityType()).thenReturn(entityType); Entity entity = mock(Entity.class); when(entity.getLabelValue()).thenReturn("label"); when(repository.findOneById("identifier")).thenReturn(entity); when(dataService.getRepository("typeId")).thenReturn(repository); when(dataService.getEntityType("typeId")).thenReturn(entityType); assertEquals( create("entity-typeId", "typeId", "typeLabel", "identifier", "label"), entityHelper.getLabelledObjectIdentity( new ObjectIdentityImpl("entity-typeId", "identifier"))); }
public LabelledObjectIdentity getLabelledObjectIdentity(ObjectIdentity objectIdentity) { String typeLabel = getLabel(objectIdentity.getType()); String entityTypeId = getEntityTypeIdFromType(objectIdentity.getType()); String identifierLabel = getLabel(objectIdentity.getType(), objectIdentity.getIdentifier().toString()); return LabelledObjectIdentity.create( objectIdentity.getType(), entityTypeId, typeLabel, objectIdentity.getIdentifier().toString(), identifierLabel); }
EntityHelper { public LabelledObjectIdentity getLabelledObjectIdentity(ObjectIdentity objectIdentity) { String typeLabel = getLabel(objectIdentity.getType()); String entityTypeId = getEntityTypeIdFromType(objectIdentity.getType()); String identifierLabel = getLabel(objectIdentity.getType(), objectIdentity.getIdentifier().toString()); return LabelledObjectIdentity.create( objectIdentity.getType(), entityTypeId, typeLabel, objectIdentity.getIdentifier().toString(), identifierLabel); } }
EntityHelper { public LabelledObjectIdentity getLabelledObjectIdentity(ObjectIdentity objectIdentity) { String typeLabel = getLabel(objectIdentity.getType()); String entityTypeId = getEntityTypeIdFromType(objectIdentity.getType()); String identifierLabel = getLabel(objectIdentity.getType(), objectIdentity.getIdentifier().toString()); return LabelledObjectIdentity.create( objectIdentity.getType(), entityTypeId, typeLabel, objectIdentity.getIdentifier().toString(), identifierLabel); } EntityHelper(DataService dataService); }
EntityHelper { public LabelledObjectIdentity getLabelledObjectIdentity(ObjectIdentity objectIdentity) { String typeLabel = getLabel(objectIdentity.getType()); String entityTypeId = getEntityTypeIdFromType(objectIdentity.getType()); String identifierLabel = getLabel(objectIdentity.getType(), objectIdentity.getIdentifier().toString()); return LabelledObjectIdentity.create( objectIdentity.getType(), entityTypeId, typeLabel, objectIdentity.getIdentifier().toString(), identifierLabel); } EntityHelper(DataService dataService); ObjectIdentity getObjectIdentity(String classId, String objectIdentifier); String getLabel(String typeId, String untypedIdentifier); String getLabel(String typeId); LabelledObjectIdentity getLabelledObjectIdentity(ObjectIdentity objectIdentity); void checkEntityExists(ObjectIdentity objectIdentity); void checkEntityTypeExists(String typeId); void checkIsNotSystem(String typeId); }
EntityHelper { public LabelledObjectIdentity getLabelledObjectIdentity(ObjectIdentity objectIdentity) { String typeLabel = getLabel(objectIdentity.getType()); String entityTypeId = getEntityTypeIdFromType(objectIdentity.getType()); String identifierLabel = getLabel(objectIdentity.getType(), objectIdentity.getIdentifier().toString()); return LabelledObjectIdentity.create( objectIdentity.getType(), entityTypeId, typeLabel, objectIdentity.getIdentifier().toString(), identifierLabel); } EntityHelper(DataService dataService); ObjectIdentity getObjectIdentity(String classId, String objectIdentifier); String getLabel(String typeId, String untypedIdentifier); String getLabel(String typeId); LabelledObjectIdentity getLabelledObjectIdentity(ObjectIdentity objectIdentity); void checkEntityExists(ObjectIdentity objectIdentity); void checkEntityTypeExists(String typeId); void checkIsNotSystem(String typeId); static final String ENTITY_PREFIX; static final String PLUGIN; static final String SYS_PLUGIN; }