use of org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationFsm.State in project open-kilda by telstra.
the class CompleteYFlowValidationAction method performWithResponse.
@Override
public Optional<Message> performWithResponse(State from, State to, Event event, YFlowValidationContext context, YFlowValidationFsm stateMachine) throws FlowNotFoundException, SwitchNotFoundException {
YFlowDiscrepancyDto resourcesValidationResult = validationService.validateYFlowResources(stateMachine.getYFlowId(), stateMachine.getReceivedRules(), stateMachine.getReceivedMeters());
YFlowValidationResponse result = new YFlowValidationResponse();
result.setYFlowValidationResult(resourcesValidationResult);
result.setSubFlowValidationResults(stateMachine.getSubFlowValidationResults());
boolean notAsExpected = !resourcesValidationResult.isAsExpected() || stateMachine.getSubFlowValidationResults().stream().map(FlowValidationResponse::getAsExpected).anyMatch(n -> !n);
result.setAsExpected(!notAsExpected);
CommandContext commandContext = stateMachine.getCommandContext();
InfoMessage message = new InfoMessage(result, commandContext.getCreateTime(), commandContext.getCorrelationId());
return Optional.of(message);
}
Aggregations