use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.
the class FlowController method statusFlow.
/**
* Gets flow status.
*
* @param flowId flow id
* @param correlationId correlation ID header value
* @return list of flow
*/
@ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = FlowIdStatusPayload.class, message = "Operation is successful"), @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 500, response = MessageError.class, message = "General error"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/flows/status/{flow-id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId, @RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
logger.debug("Flow status: {}={}", CORRELATION_ID, correlationId);
FlowIdStatusPayload response = flowService.statusFlow(flowId, correlationId);
return new ResponseEntity<>(response, new HttpHeaders(), HttpStatus.OK);
}
use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.
the class FlowServiceImpl method pathFlow.
/**
* {@inheritDoc}
*/
@Override
public FlowPathPayload pathFlow(final String id, final String correlationId) {
LOGGER.debug("Flow path: {}={}", CORRELATION_ID, correlationId);
FlowPathRequest data = new FlowPathRequest(new FlowIdStatusPayload(id, null));
CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, request);
Message message = (Message) messageConsumer.poll(correlationId);
FlowPathResponse response = (FlowPathResponse) validateInfoMessage(request, message, correlationId);
return Converter.buildFlowPathPayloadByFlowPath(id, response.getPayload());
}
use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.
the class FlowServiceImpl method statusFlow.
/**
* {@inheritDoc}
*/
@Override
public FlowIdStatusPayload statusFlow(final String id, final String correlationId) {
LOGGER.debug("Flow status: {}={}", CORRELATION_ID, correlationId);
FlowStatusRequest data = new FlowStatusRequest(new FlowIdStatusPayload(id, null));
CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, request);
Message message = (Message) messageConsumer.poll(correlationId);
FlowStatusResponse response = (FlowStatusResponse) validateInfoMessage(request, message, correlationId);
return response.getPayload();
}
use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.
the class FlowServiceImpl method getFlow.
/**
* {@inheritDoc}
*/
@Override
public FlowPayload getFlow(final String id, final String correlationId) {
LOGGER.debug("Get flow: {}={}", CORRELATION_ID, correlationId);
FlowGetRequest data = new FlowGetRequest(new FlowIdStatusPayload(id, null));
CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, request);
Message message = (Message) messageConsumer.poll(correlationId);
FlowResponse response = (FlowResponse) validateInfoMessage(request, message, correlationId);
return Converter.buildFlowPayloadByFlow(response.getPayload());
}
use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.
the class FlowControllerTest method statusFlow.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void statusFlow() throws Exception {
MvcResult result = mockMvc.perform(get("/flows/status/{flow-id}", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
FlowIdStatusPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowIdStatusPayload.class);
assertEquals(TestMessageMock.flowStatus, response);
}
Aggregations