@Test public void testUpdate() throws Exception { context.turnOffAuthorisationSystem(); MetadataValue metVal = mock(MetadataValue.class); List<MetadataValue> metsList = new ArrayList<>(); Item leftItem = mock(Item.class); Item rightItem = mock(Item.class); RelationshipType testRel = new RelationshipType(); EntityType leftEntityType = mock(EntityType.class); EntityType rightEntityType = mock(EntityType.class); testRel.setLeftType(leftEntityType); testRel.setRightType(rightEntityType); testRel.setLeftwardType("Entitylabel"); testRel.setRightwardType("Entitylabel"); testRel.setLeftMinCardinality(0); testRel.setRightMinCardinality(0); metsList.add(metVal); relationship = getRelationship(leftItem, rightItem, testRel, 0,0); when(itemService.getMetadata(leftItem, "relationship", "type", null, Item.ANY)).thenReturn(metsList); when(itemService.getMetadata(rightItem, "relationship", "type", null, Item.ANY)).thenReturn(metsList); when(authorizeService.authorizeActionBoolean(context, relationship.getLeftItem(), Constants.WRITE)).thenReturn(true); relationshipService.update(context, relationship); Mockito.verify(relationshipDAO).save(context, relationship); }
@Override public void update(Context context, Relationship relationship) throws SQLException, AuthorizeException { update(context, Collections.singletonList(relationship)); }
RelationshipServiceImpl implements RelationshipService { @Override public void update(Context context, Relationship relationship) throws SQLException, AuthorizeException { update(context, Collections.singletonList(relationship)); } }
RelationshipServiceImpl implements RelationshipService { @Override public void update(Context context, Relationship relationship) throws SQLException, AuthorizeException { update(context, Collections.singletonList(relationship)); }  }
RelationshipServiceImpl implements RelationshipService { @Override public void update(Context context, Relationship relationship) throws SQLException, AuthorizeException { update(context, Collections.singletonList(relationship)); }  @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 void update(Context context, Relationship relationship) throws SQLException, AuthorizeException { update(context, Collections.singletonList(relationship)); }  @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);  }