@Test public void testFindByItem() throws Exception { List<Relationship> relationshipTest = new ArrayList<>(); Item cindy = mock(Item.class); Item fred = mock(Item.class); Item bob = mock(Item.class); Item hank = mock(Item.class); Item jasper = mock(Item.class); Item spot = mock(Item.class); RelationshipType hasDog = new RelationshipType(); RelationshipType hasFather = new RelationshipType(); RelationshipType hasMother = new RelationshipType(); hasDog.setLeftwardType("hasDog"); hasDog.setRightwardType("isDogOf"); hasFather.setLeftwardType("hasFather"); hasFather.setRightwardType("isFatherOf"); hasMother.setLeftwardType("hasMother"); hasMother.setRightwardType("isMotherOf"); relationshipTest.add(getRelationship(cindy, spot, hasDog,0,0)); relationshipTest.add(getRelationship(cindy, jasper, hasDog,0,1)); relationshipTest.add(getRelationship(cindy, hank, hasFather,0,0)); relationshipTest.add(getRelationship(fred, cindy, hasMother,0,0)); relationshipTest.add(getRelationship(bob, cindy, hasMother,1,0)); when(relationshipService.findByItem(context, cindy, -1, -1)).thenReturn(relationshipTest); when(relationshipDAO.findByItem(context, cindy, -1, -1)).thenReturn(relationshipTest); List<Relationship> results = relationshipService.findByItem(context, cindy); assertEquals("TestFindByItem 0", relationshipTest, results); for (int i = 0; i < relationshipTest.size(); i++) { assertEquals("TestFindByItem sort integrity", relationshipTest.get(i), results.get(i)); } }
@Override public List<Relationship> findByItem(Context context, Item item) throws SQLException { return findByItem(context, item, -1, -1); }
RelationshipServiceImpl implements RelationshipService { @Override public List<Relationship> findByItem(Context context, Item item) throws SQLException { return findByItem(context, item, -1, -1); } }
RelationshipServiceImpl implements RelationshipService { @Override public List<Relationship> findByItem(Context context, Item item) throws SQLException { return findByItem(context, item, -1, -1); }  }
RelationshipServiceImpl implements RelationshipService { @Override public List<Relationship> findByItem(Context context, Item item) throws SQLException { return findByItem(context, item, -1, -1); }  @Override Relationship create(Context context); @Override Relationship create(Context c, Item leftItem, Item rightItem, RelationshipType relationshipType,
                               int leftPlace, int rightPlace); @Override Relationship create(Context c, Item leftItem, Item rightItem, RelationshipType relationshipType,
                               int leftPlace, int rightPlace, String leftwardValue, String rightwardValue); @Override Relationship create(Context context, Relationship relationship); @Override void updatePlaceInRelationship(Context context, Relationship relationship); @Override void updateItem(Context context, Item relatedItem); @Override int findNextLeftPlaceByLeftItem(Context context, Item item); @Override int findNextRightPlaceByRightItem(Context context, Item item); Relationship find(Context context, int id); @Override List<Relationship> findByItem(Context context, Item item); @Override List<Relationship> findByItem(Context context, Item item, Integer limit, Integer offset); @Override List<Relationship> findAll(Context context); @Override List<Relationship> findAll(Context context, Integer limit, Integer offset); @Override void update(Context context, Relationship relationship); @Override void update(Context context, List<Relationship> relationships); @Override void delete(Context context, Relationship relationship); @Override void delete(Context context, Relationship relationship, boolean copyToLeftItem, boolean copyToRightItem); List<Relationship> findByItemAndRelationshipType(Context context, Item item,
                                                            RelationshipType relationshipType, boolean isLeft); @Override List<Relationship> findByItemAndRelationshipType(Context context, Item item,
                                                            RelationshipType relationshipType); @Override List<Relationship> findByItemAndRelationshipType(Context context, Item item,
                                                            RelationshipType relationshipType, int limit, int offset); @Override List<Relationship> findByItemAndRelationshipType(Context context, Item item,
                                                            RelationshipType relationshipType, boolean isLeft,
                                                            int limit, int offset); @Override List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType); @Override List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType, Integer limit,
                                                     Integer offset); @Override List<Relationship> findByTypeName(Context context, String typeName); @Override List<Relationship> findByTypeName(Context context, String typeName, Integer limit, Integer offset); @Override int countTotal(Context context); @Override int countByItem(Context context, Item item); @Override int countByRelationshipType(Context context, RelationshipType relationshipType); @Override int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType); @Override int countByTypeName(Context context, String typeName); }
RelationshipServiceImpl implements RelationshipService { @Override public List<Relationship> findByItem(Context context, Item item) throws SQLException { return findByItem(context, item, -1, -1); }  @Override Relationship create(Context context); @Override Relationship create(Context c, Item leftItem, Item rightItem, RelationshipType relationshipType,
                               int leftPlace, int rightPlace); @Override Relationship create(Context c, Item leftItem, Item rightItem, RelationshipType relationshipType,
                               int leftPlace, int rightPlace, String leftwardValue, String rightwardValue); @Override Relationship create(Context context, Relationship relationship); @Override void updatePlaceInRelationship(Context context, Relationship relationship); @Override void updateItem(Context context, Item relatedItem); @Override int findNextLeftPlaceByLeftItem(Context context, Item item); @Override int findNextRightPlaceByRightItem(Context context, Item item); Relationship find(Context context, int id); @Override List<Relationship> findByItem(Context context, Item item); @Override List<Relationship> findByItem(Context context, Item item, Integer limit, Integer offset); @Override List<Relationship> findAll(Context context); @Override List<Relationship> findAll(Context context, Integer limit, Integer offset); @Override void update(Context context, Relationship relationship); @Override void update(Context context, List<Relationship> relationships); @Override void delete(Context context, Relationship relationship); @Override void delete(Context context, Relationship relationship, boolean copyToLeftItem, boolean copyToRightItem); List<Relationship> findByItemAndRelationshipType(Context context, Item item,
                                                            RelationshipType relationshipType, boolean isLeft); @Override List<Relationship> findByItemAndRelationshipType(Context context, Item item,
                                                            RelationshipType relationshipType); @Override List<Relationship> findByItemAndRelationshipType(Context context, Item item,
                                                            RelationshipType relationshipType, int limit, int offset); @Override List<Relationship> findByItemAndRelationshipType(Context context, Item item,
                                                            RelationshipType relationshipType, boolean isLeft,
                                                            int limit, int offset); @Override List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType); @Override List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType, Integer limit,
                                                     Integer offset); @Override List<Relationship> findByTypeName(Context context, String typeName); @Override List<Relationship> findByTypeName(Context context, String typeName, Integer limit, Integer offset); @Override int countTotal(Context context); @Override int countByItem(Context context, Item item); @Override int countByRelationshipType(Context context, RelationshipType relationshipType); @Override int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType); @Override int countByTypeName(Context context, String typeName);  }