Search in sources :

Example 1 with FlowLoopResponse

use of org.openkilda.northbound.dto.v2.flows.FlowLoopResponse in project open-kilda by telstra.

the class NorthboundServiceV2Impl method getFlowLoop.

@Override
public List<FlowLoopResponse> getFlowLoop(String flowId, SwitchId switchId) {
    UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString("/api/v2/flows/loops");
    if (flowId != null) {
        uriBuilder.queryParam("flow_id", flowId);
    }
    if (switchId != null) {
        uriBuilder.queryParam("switch_id", switchId);
    }
    FlowLoopResponse[] flowLoopResponse = restTemplate.exchange(uriBuilder.build().toString(), HttpMethod.GET, new HttpEntity(buildHeadersWithCorrelationId()), FlowLoopResponse[].class).getBody();
    return Arrays.asList(flowLoopResponse);
}
Also used : HttpEntity(org.springframework.http.HttpEntity) FlowLoopResponse(org.openkilda.northbound.dto.v2.flows.FlowLoopResponse) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 2 with FlowLoopResponse

use of org.openkilda.northbound.dto.v2.flows.FlowLoopResponse in project open-kilda by telstra.

the class FlowServiceTest method createFlowLoop.

@Test
public void createFlowLoop() throws Exception {
    String correlationId = "correlation-id";
    RequestCorrelationId.create(correlationId);
    String flowId = "flow-id";
    SwitchId switchId = new SwitchId("1");
    FlowDto dto = FlowDto.builder().flowId(flowId).loopSwitchId(switchId).build();
    FlowResponse response = new FlowResponse(dto);
    messageExchanger.mockResponse(correlationId, response);
    FlowLoopResponse result = flowService.createFlowLoop(flowId, switchId).get();
    assertEquals(flowId, result.getFlowId());
    assertEquals(switchId, result.getSwitchId());
}
Also used : FlowDto(org.openkilda.messaging.model.FlowDto) FlowLoopResponse(org.openkilda.northbound.dto.v2.flows.FlowLoopResponse) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) SwapFlowResponse(org.openkilda.messaging.info.flow.SwapFlowResponse) SwitchId(org.openkilda.model.SwitchId) Test(org.junit.Test)

Aggregations

FlowLoopResponse (org.openkilda.northbound.dto.v2.flows.FlowLoopResponse)2 Test (org.junit.Test)1 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)1 SwapFlowResponse (org.openkilda.messaging.info.flow.SwapFlowResponse)1 FlowDto (org.openkilda.messaging.model.FlowDto)1 SwitchId (org.openkilda.model.SwitchId)1 HttpEntity (org.springframework.http.HttpEntity)1 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)1