Search in sources :

Example 6 with FlowPathPayload

use of org.openkilda.messaging.payload.flow.FlowPathPayload in project open-kilda by telstra.

the class NorthboundRunTest method checkFlowPath.

@Then("^path of flow (.*) could be read$")
public void checkFlowPath(final String flowId) {
    String flowName = FlowUtils.getFlowName(flowId);
    FlowPathPayload payload = FlowUtils.getFlowPath(flowName);
    assertNotNull(payload);
    assertEquals(flowName, payload.getId());
    assertEquals(expectedFlowPath, payload.getPath());
}
Also used : FlowPathPayload(org.openkilda.messaging.payload.flow.FlowPathPayload) Then(cucumber.api.java.en.Then)

Example 7 with FlowPathPayload

use of org.openkilda.messaging.payload.flow.FlowPathPayload in project open-kilda by telstra.

the class FlowController method pathFlow.

/**
 * Gets flow path.
 *
 * @param flowId        flow id
 * @param correlationId correlation ID header value
 * @return list of flow
 */
@ApiOperation(value = "Gets flow path", response = FlowPathPayload.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = FlowPathPayload.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/path/{flow-id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId, @RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
    logger.debug("Flow path: {}={}, {}={}", CORRELATION_ID, correlationId, FLOW_ID, flowId);
    FlowPathPayload response = flowService.pathFlow(flowId, correlationId);
    return new ResponseEntity<>(response, new HttpHeaders(), HttpStatus.OK);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) FlowPathPayload(org.openkilda.messaging.payload.flow.FlowPathPayload) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 8 with FlowPathPayload

use of org.openkilda.messaging.payload.flow.FlowPathPayload in project open-kilda by telstra.

the class FlowControllerTest method pathFlow.

@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void pathFlow() throws Exception {
    MvcResult result = mockMvc.perform(get("/flows/path/{flow-id}", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
    FlowPathPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPathPayload.class);
    assertEquals(TestMessageMock.flowPath, response);
}
Also used : FlowPathPayload(org.openkilda.messaging.payload.flow.FlowPathPayload) MvcResult(org.springframework.test.web.servlet.MvcResult) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 9 with FlowPathPayload

use of org.openkilda.messaging.payload.flow.FlowPathPayload in project open-kilda by telstra.

the class FlowFFRTest method flowPathIsShortest.

@When("^flow (.+) path is shortest$")
public void flowPathIsShortest(String flowId) throws Throwable {
    String flowName = FlowUtils.getFlowName(flowId);
    FlowPathPayload payload = getFlowPath(flowName, FlowPathTest.expectedShortestPath.getLeft());
    assertNotNull(payload);
    assertEquals(flowName, payload.getId());
    assertEquals(FlowPathTest.expectedShortestPath.getLeft(), payload.getPath());
}
Also used : FlowPathPayload(org.openkilda.messaging.payload.flow.FlowPathPayload) When(cucumber.api.java.en.When)

Aggregations

FlowPathPayload (org.openkilda.messaging.payload.flow.FlowPathPayload)9 Then (cucumber.api.java.en.Then)2 When (cucumber.api.java.en.When)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Client (javax.ws.rs.client.Client)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 DefaultParameters.northboundEndpoint (org.openkilda.DefaultParameters.northboundEndpoint)1 DefaultParameters.topologyEndpoint (org.openkilda.DefaultParameters.topologyEndpoint)1 DefaultParameters.trafficEndpoint (org.openkilda.DefaultParameters.trafficEndpoint)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 PathNode (org.openkilda.messaging.info.event.PathNode)1 FlowPathResponse (org.openkilda.messaging.info.flow.FlowPathResponse)1 Flow (org.openkilda.topology.domain.Flow)1 HttpHeaders (org.springframework.http.HttpHeaders)1 ResponseEntity (org.springframework.http.ResponseEntity)1 WithMockUser (org.springframework.security.test.context.support.WithMockUser)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1