@Test(expected = InvalidFlowException.class) public void shouldFailOnSwapWhenEqualsEndpointsOnFirstAndSecondFlow() throws InvalidFlowException { RequestedFlow firstFlow = RequestedFlow.builder() .flowId("firstFlow") .srcSwitch(SWITCH_ID_1) .srcPort(10) .srcVlan(11) .destSwitch(SWITCH_ID_2) .destPort(12) .destVlan(13) .build(); RequestedFlow secondFlow = RequestedFlow.builder() .flowId("secondFlow") .srcSwitch(SWITCH_ID_1) .srcPort(10) .srcVlan(11) .destSwitch(SWITCH_ID_2) .destPort(12) .destVlan(13) .build(); flowValidator.checkForEqualsEndpoints(firstFlow, secondFlow); }
@VisibleForTesting void checkForEqualsEndpoints(RequestedFlow firstFlow, RequestedFlow secondFlow) throws InvalidFlowException { String message = "New requested endpoint for '%s' conflicts with existing endpoint for '%s'"; Set<FlowEndpoint> firstFlowEndpoints = validateFlowEqualsEndpoints(firstFlow, message); Set<FlowEndpoint> secondFlowEndpoints = validateFlowEqualsEndpoints(secondFlow, message); for (FlowEndpoint endpoint : secondFlowEndpoints) { if (firstFlowEndpoints.contains(endpoint)) { message = String.format(message, secondFlow.getFlowId(), firstFlow.getFlowId()); throw new InvalidFlowException(message, ErrorType.DATA_INVALID); } } }
FlowValidator { @VisibleForTesting void checkForEqualsEndpoints(RequestedFlow firstFlow, RequestedFlow secondFlow) throws InvalidFlowException { String message = "New requested endpoint for '%s' conflicts with existing endpoint for '%s'"; Set<FlowEndpoint> firstFlowEndpoints = validateFlowEqualsEndpoints(firstFlow, message); Set<FlowEndpoint> secondFlowEndpoints = validateFlowEqualsEndpoints(secondFlow, message); for (FlowEndpoint endpoint : secondFlowEndpoints) { if (firstFlowEndpoints.contains(endpoint)) { message = String.format(message, secondFlow.getFlowId(), firstFlow.getFlowId()); throw new InvalidFlowException(message, ErrorType.DATA_INVALID); } } } }
FlowValidator { @VisibleForTesting void checkForEqualsEndpoints(RequestedFlow firstFlow, RequestedFlow secondFlow) throws InvalidFlowException { String message = "New requested endpoint for '%s' conflicts with existing endpoint for '%s'"; Set<FlowEndpoint> firstFlowEndpoints = validateFlowEqualsEndpoints(firstFlow, message); Set<FlowEndpoint> secondFlowEndpoints = validateFlowEqualsEndpoints(secondFlow, message); for (FlowEndpoint endpoint : secondFlowEndpoints) { if (firstFlowEndpoints.contains(endpoint)) { message = String.format(message, secondFlow.getFlowId(), firstFlow.getFlowId()); throw new InvalidFlowException(message, ErrorType.DATA_INVALID); } } } FlowValidator(FlowRepository flowRepository, SwitchRepository switchRepository,
                         IslRepository islRepository, SwitchPropertiesRepository switchPropertiesRepository); }
FlowValidator { @VisibleForTesting void checkForEqualsEndpoints(RequestedFlow firstFlow, RequestedFlow secondFlow) throws InvalidFlowException { String message = "New requested endpoint for '%s' conflicts with existing endpoint for '%s'"; Set<FlowEndpoint> firstFlowEndpoints = validateFlowEqualsEndpoints(firstFlow, message); Set<FlowEndpoint> secondFlowEndpoints = validateFlowEqualsEndpoints(secondFlow, message); for (FlowEndpoint endpoint : secondFlowEndpoints) { if (firstFlowEndpoints.contains(endpoint)) { message = String.format(message, secondFlow.getFlowId(), firstFlow.getFlowId()); throw new InvalidFlowException(message, ErrorType.DATA_INVALID); } } } FlowValidator(FlowRepository flowRepository, SwitchRepository switchRepository,
                         IslRepository islRepository, SwitchPropertiesRepository switchPropertiesRepository); void validate(RequestedFlow flow); void validate(RequestedFlow flow, Set<String> bulkUpdateFlowIds); void validateForSwapEndpoints(RequestedFlow firstFlow, RequestedFlow secondFlow); }
FlowValidator { @VisibleForTesting void checkForEqualsEndpoints(RequestedFlow firstFlow, RequestedFlow secondFlow) throws InvalidFlowException { String message = "New requested endpoint for '%s' conflicts with existing endpoint for '%s'"; Set<FlowEndpoint> firstFlowEndpoints = validateFlowEqualsEndpoints(firstFlow, message); Set<FlowEndpoint> secondFlowEndpoints = validateFlowEqualsEndpoints(secondFlow, message); for (FlowEndpoint endpoint : secondFlowEndpoints) { if (firstFlowEndpoints.contains(endpoint)) { message = String.format(message, secondFlow.getFlowId(), firstFlow.getFlowId()); throw new InvalidFlowException(message, ErrorType.DATA_INVALID); } } } FlowValidator(FlowRepository flowRepository, SwitchRepository switchRepository,
                         IslRepository islRepository, SwitchPropertiesRepository switchPropertiesRepository); void validate(RequestedFlow flow); void validate(RequestedFlow flow, Set<String> bulkUpdateFlowIds); void validateForSwapEndpoints(RequestedFlow firstFlow, RequestedFlow secondFlow);  }