RelationshipDeletionHandler extends DeletionHandler { @Override public String allowDeleteRelationshipType( RelationshipType relationshipType ) { Collection<Relationship> relationships = relationshipService.getRelationshipsByRelationshipType( relationshipType ); return relationships.isEmpty() ? null : ERROR; } RelationshipDeletionHandler( RelationshipService relationshipService ); @Override String getClassName(); @Override void deleteTrackedEntityInstance( TrackedEntityInstance entityInstance ); @Override String allowDeleteRelationshipType( RelationshipType relationshipType );  }
@Test public void allowDeleteRelationshipTypeWithData() { Mockito.when( relationshipService.getRelationshipsByRelationshipType( Mockito.any() ) ).thenReturn( Lists.newArrayList( new Relationship() ) ); String res = relationshipDeletionHandler.allowDeleteRelationshipType( relationshipTypeWithoutData ); assertNotNull( res ); }
@Test public void allowDeleteRelationshipTypeWithoutData() { Mockito.when( relationshipService.getRelationshipsByRelationshipType( Mockito.any() ) ).thenReturn( Lists.newArrayList() ); String res = relationshipDeletionHandler.allowDeleteRelationshipType( relationshipTypeWithData ); assertNull( res ); }