@Test public void testGetLeftRelation() { Item item = mock(Item.class); UUID uuid = UUID.randomUUID(); Relationship relationship = mock(Relationship.class); List<Relationship> relationshipList = new ArrayList<>(); relationshipList.add(relationship); Entity entity = mock(Entity.class); when(entity.getItem()).thenReturn(item); when(relationship.getLeftItem()).thenReturn(item); when(item.getID()).thenReturn(uuid); when(entity.getRelationships()).thenReturn(relationshipList); assertEquals("TestGetLeftRelations 0", relationshipList, entityService.getLeftRelations(context, entity)); }
@Override public List<Relationship> getLeftRelations(Context context, Entity entity) { List<Relationship> fullList = entity.getRelationships(); List<Relationship> listToReturn = new LinkedList<>(); for (Relationship relationship : fullList) { if (relationship.getLeftItem().getID() == entity.getItem().getID()) { listToReturn.add(relationship); } } return listToReturn; }
EntityServiceImpl implements EntityService { @Override public List<Relationship> getLeftRelations(Context context, Entity entity) { List<Relationship> fullList = entity.getRelationships(); List<Relationship> listToReturn = new LinkedList<>(); for (Relationship relationship : fullList) { if (relationship.getLeftItem().getID() == entity.getItem().getID()) { listToReturn.add(relationship); } } return listToReturn; } }
EntityServiceImpl implements EntityService { @Override public List<Relationship> getLeftRelations(Context context, Entity entity) { List<Relationship> fullList = entity.getRelationships(); List<Relationship> listToReturn = new LinkedList<>(); for (Relationship relationship : fullList) { if (relationship.getLeftItem().getID() == entity.getItem().getID()) { listToReturn.add(relationship); } } return listToReturn; }  }
EntityServiceImpl implements EntityService { @Override public List<Relationship> getLeftRelations(Context context, Entity entity) { List<Relationship> fullList = entity.getRelationships(); List<Relationship> listToReturn = new LinkedList<>(); for (Relationship relationship : fullList) { if (relationship.getLeftItem().getID() == entity.getItem().getID()) { listToReturn.add(relationship); } } return listToReturn; }  @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); }
EntityServiceImpl implements EntityService { @Override public List<Relationship> getLeftRelations(Context context, Entity entity) { List<Relationship> fullList = entity.getRelationships(); List<Relationship> listToReturn = new LinkedList<>(); for (Relationship relationship : fullList) { if (relationship.getLeftItem().getID() == entity.getItem().getID()) { listToReturn.add(relationship); } } return listToReturn; }  @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);  }