@Test void testGetTypeLabel() { Repository repository = mock(Repository.class); EntityType entityType = mock(EntityType.class); when(entityType.getLabel()).thenReturn("typeLabel"); when(repository.getEntityType()).thenReturn(entityType); when(dataService.getRepository("typeId")).thenReturn(repository); assertEquals("typeLabel", entityHelper.getLabel("entity-typeId")); }
public String getLabel(String typeId, String untypedIdentifier) { String entityTypeId = getEntityTypeIdFromType(typeId); Object typedIdentifier = getTypedValue(untypedIdentifier, typeId); Entity[] result = new Entity[1]; runAsSystem(() -> result[0] = getEntityByIdentifier(typedIdentifier, entityTypeId)); if (result[0] == null) { throw new UnknownEntityException(entityTypeId, typedIdentifier); } return result[0].getLabelValue().toString(); }
EntityHelper { public String getLabel(String typeId, String untypedIdentifier) { String entityTypeId = getEntityTypeIdFromType(typeId); Object typedIdentifier = getTypedValue(untypedIdentifier, typeId); Entity[] result = new Entity[1]; runAsSystem(() -> result[0] = getEntityByIdentifier(typedIdentifier, entityTypeId)); if (result[0] == null) { throw new UnknownEntityException(entityTypeId, typedIdentifier); } return result[0].getLabelValue().toString(); } }
EntityHelper { public String getLabel(String typeId, String untypedIdentifier) { String entityTypeId = getEntityTypeIdFromType(typeId); Object typedIdentifier = getTypedValue(untypedIdentifier, typeId); Entity[] result = new Entity[1]; runAsSystem(() -> result[0] = getEntityByIdentifier(typedIdentifier, entityTypeId)); if (result[0] == null) { throw new UnknownEntityException(entityTypeId, typedIdentifier); } return result[0].getLabelValue().toString(); } EntityHelper(DataService dataService); }
EntityHelper { public String getLabel(String typeId, String untypedIdentifier) { String entityTypeId = getEntityTypeIdFromType(typeId); Object typedIdentifier = getTypedValue(untypedIdentifier, typeId); Entity[] result = new Entity[1]; runAsSystem(() -> result[0] = getEntityByIdentifier(typedIdentifier, entityTypeId)); if (result[0] == null) { throw new UnknownEntityException(entityTypeId, typedIdentifier); } return result[0].getLabelValue().toString(); } 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 String getLabel(String typeId, String untypedIdentifier) { String entityTypeId = getEntityTypeIdFromType(typeId); Object typedIdentifier = getTypedValue(untypedIdentifier, typeId); Entity[] result = new Entity[1]; runAsSystem(() -> result[0] = getEntityByIdentifier(typedIdentifier, entityTypeId)); if (result[0] == null) { throw new UnknownEntityException(entityTypeId, typedIdentifier); } return result[0].getLabelValue().toString(); } 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; }