DefaultCommunicationService implements CommunicationService { public Direction computeDirectionToRemove(boolean hasIncomingRelationship, boolean hasOutgoingRelationship) { if (hasIncomingRelationship && hasOutgoingRelationship) { return null; } if (hasIncomingRelationship) { return Direction.INCOMING; } if (hasOutgoingRelationship) { return Direction.OUTGOING; } return Direction.BOTH; }  @Override void addLink(String startGroupId, String endGroupId, Handler<Either<String, JsonObject>> handler); @Override void removeLink(String startGroupId, String endGroupId, Handler<Either<String, JsonObject>> handler); @Override void addLinkWithUsers(String groupId, Direction direction, Handler<Either<String, JsonObject>> handler); @Override void addLinkWithUsers(Map<String, Direction> params, Handler<Either<String, JsonObject>> handler); @Override void removeLinkWithUsers(String groupId, Direction direction, Handler<Either<String, JsonObject>> handler); @Override void communiqueWith(String groupId, Handler<Either<String, JsonObject>> handler); @Override void addLinkBetweenRelativeAndStudent(String groupId, Direction direction,
			Handler<Either<String, JsonObject>> handler); @Override void removeLinkBetweenRelativeAndStudent(String groupId, Direction direction,
			Handler<Either<String, JsonObject>> handler); @Override void initDefaultRules(JsonArray structureIds, JsonObject defaultRules,
			final Handler<Either<String, JsonObject>> handler); @Override void applyDefaultRules(JsonArray structureIds, Handler<Either<String, JsonObject>> handler); @Override void applyRules(String groupId, Handler<Either<String, JsonObject>> handler); @Override void removeRules(String structureId, Handler<Either<String, JsonObject>> handler); @Override void visibleUsers(String userId, String structureId, JsonArray expectedTypes, boolean itSelf,
							 boolean myGroup, boolean profile, String preFilter, String customReturn, JsonObject additionnalParams,
							 final Handler<Either<String, JsonArray>> handler); @Override void visibleUsers(String userId, String structureId, JsonArray expectedTypes, boolean itSelf,
			boolean myGroup, boolean profile, String preFilter, String customReturn, JsonObject additionnalParams, String userProfile,
			final Handler<Either<String, JsonArray>> handler); @Override void usersCanSeeMe(String userId, Handler<Either<String, JsonArray>> handler); @Override void visibleProfilsGroups(String userId, String customReturn, JsonObject additionnalParams,
			String preFilter, Handler<Either<String, JsonArray>> handler); @Override void visibleManualGroups(String userId, String customReturn, JsonObject additionnalParams,
			Handler<Either<String, JsonArray>> handler); @Override void getOutgoingRelations(String id, Handler<Either<String, JsonArray>> results); @Override void getIncomingRelations(String id, Handler<Either<String, JsonArray>> results); @Override void safelyRemoveLinkWithUsers(String groupId, Handler<Either<String, JsonObject>> handler); @Override void getDirections(String startGroupId, String endGroupId, Handler<Either<String, JsonObject>> handler); @Override void addLinkCheckOnly(String startGroupId, String endGroupId, UserInfos userInfos, Handler<Either<String, JsonObject>> handler); @Override void removeRelations(String sendingGroupId, String receivingGroupId, Handler<Either<String, JsonObject>> handler); @Override void processChangeDirectionAfterAddingLink(String startGroupId, String endGroupId, Handler<Either<String, JsonObject>> handler); Direction computeDirectionToRemove(boolean hasIncomingRelationship, boolean hasOutgoingRelationship); Direction computeNextDirection(Direction directionToRemove); String computeWarningMessageForAddLinkCheck(Direction startDirection, Direction endDirection); boolean isImpossibleToChangeDirectionGroupForAddLink(String filter, String subType, UserInfos userInfos); Map<String, Direction> computeNewDirectionAfterAddingLink(String startGroupId, Direction startDirection, String endGroupId, Direction endDirection);  }
@Test public void computeDirectionToRemove_shouldReturnNull_WhenTheGroupHasBothIncomingAndOutgoingRelationship() { Assert.assertEquals(null, this.service.computeDirectionToRemove(true, true)); }
@Test public void computeDirectionToRemove_shouldReturnDirectionIncoming_WhenTheGroupHasIncomingRelationship() { Assert.assertEquals(CommunicationService.Direction.INCOMING, this.service.computeDirectionToRemove(true, false)); }
@Test public void computeDirectionToRemove_shouldReturnDirectionOutgoing_WhenTheGroupHasOutgoingRelationship() { Assert.assertEquals(CommunicationService.Direction.OUTGOING, this.service.computeDirectionToRemove(false, true)); }
@Test public void computeDirectionToRemove_shouldReturnBoth_WhenTheGroupHasNoRelationship() { Assert.assertEquals(CommunicationService.Direction.BOTH, this.service.computeDirectionToRemove(false, false)); }