EntityServiceImpl implements EntityService { @Override public EntityType getType(Context context, Entity entity) throws SQLException { Item item = entity.getItem(); List<MetadataValue> list = itemService.getMetadata(item, "relationship", "type", null, Item.ANY, false); if (!list.isEmpty()) { return entityTypeService.findByEntityType(context, list.get(0).getValue()); } else { return null; } }  @Override Entity findByItemId(Context context, UUID itemId); @Override Entity findByItemId(Context context, UUID itemId, Integer limit, Integer offset); @Override EntityType getType(Context context, Entity entity); @Override List<Relationship> getLeftRelations(Context context, Entity entity); @Override List<Relationship> getRightRelations(Context context, Entity entity); @Override List<Relationship> getRelationsByTypeName(Context context, String typeName); @Override List<Relationship> getRelationsByTypeName(Context context, String typeName, Integer limit, Integer offset); @Override List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity); @Override List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity, Integer limit, Integer offset); @Override List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity); @Override List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity, boolean isLeft,
                                                           Integer limit, Integer offset); @Override List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity); @Override List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity, boolean isLeft,
                                                            Integer limit, Integer offset); @Override List<RelationshipType> getRelationshipTypesByTypeName(Context context, String type); @Override List<RelationshipType> getRelationshipTypesByTypeName(Context context, String typeName,
                                                                 Integer limit, Integer offset);  }
@Test public void testGetType() throws Exception { Entity entity = mock(Entity.class); EntityTypeService entityTypeService = mock(EntityTypeService.class); EntityType entityType = entityTypeService.findByEntityType(context, "testType"); assertEquals("TestGetType 0", entityType, entityService.getType(context, entity)); }