DefaultCommunicationService implements CommunicationService { public Direction computeNextDirection(Direction directionToRemove) { if (directionToRemove == null) { return Direction.BOTH; } if (directionToRemove.equals(Direction.INCOMING)) { return Direction.OUTGOING; } if (directionToRemove.equals(Direction.OUTGOING)) { return Direction.INCOMING; } return null; }  @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 computeNextDirection_shouldReturnNull_GivenDirectionBoth() { Assert.assertEquals(null, this.service.computeNextDirection(CommunicationService.Direction.BOTH)); }
@Test public void computeNextDirection_shouldReturnIncoming_GivenDirectionOutgoing() { Assert.assertEquals(CommunicationService.Direction.INCOMING, this.service.computeNextDirection(CommunicationService.Direction.OUTGOING)); }
@Test public void computeNextDirection_shouldReturnOutgoing_GivenDirectionIncoming() { Assert.assertEquals(CommunicationService.Direction.OUTGOING, this.service.computeNextDirection(CommunicationService.Direction.INCOMING)); }
@Test public void computeNextDirection_shouldReturnBoth_GivenNull() { Assert.assertEquals(CommunicationService.Direction.BOTH, this.service.computeNextDirection(null)); }