use of org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint in project open-kilda by telstra.
the class FlowOperationsBolt method processFlowMirrorPointsDumpRequest.
private List<FlowMirrorPointsDumpResponse> processFlowMirrorPointsDumpRequest(FlowMirrorPointsDumpRequest readRequest) {
try {
String flowId = readRequest.getFlowId();
List<FlowMirrorPoint> points = flowOperationsService.getFlowMirrorPoints(flowId);
FlowMirrorPointsDumpResponse response = FlowMirrorPointsDumpResponse.builder().flowId(flowId).points(points).build();
return Collections.singletonList(response);
} catch (FlowNotFoundException e) {
throw new MessageException(ErrorType.NOT_FOUND, "Can not get flow mirror points: " + e.getMessage(), "Flow not found");
} catch (Exception e) {
throw new MessageException(ErrorType.INTERNAL_ERROR, "Can not get flow mirror points: " + e.getMessage(), "Internal Error");
}
}
use of org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint in project open-kilda by telstra.
the class FlowMapperTest method testFlowMirrorPointsDumpResponseToFlowMirrorPointsResponseV2.
@Test
public void testFlowMirrorPointsDumpResponseToFlowMirrorPointsResponseV2() {
FlowMirrorPoint firstPoint = FlowMirrorPoint.builder().mirrorPointId(MIRROR_POINT_ID_A).mirrorPointDirection(MIRROR_POINT_DIRECTION_A).mirrorPointSwitchId(SRC_SWITCH_ID).sinkEndpoint(FlowEndpoint.builder().switchId(SRC_SWITCH_ID).portNumber(SRC_PORT).outerVlanId(SRC_VLAN).innerVlanId(SRC_INNER_VLAN).build()).build();
FlowMirrorPoint secondPoint = FlowMirrorPoint.builder().mirrorPointId(MIRROR_POINT_ID_B).mirrorPointDirection(MIRROR_POINT_DIRECTION_B).mirrorPointSwitchId(SRC_SWITCH_ID).sinkEndpoint(FlowEndpoint.builder().switchId(DST_SWITCH_ID).portNumber(DST_PORT).outerVlanId(DST_VLAN).innerVlanId(DST_INNER_VLAN).build()).build();
List<FlowMirrorPoint> points = Lists.newArrayList(firstPoint, secondPoint);
FlowMirrorPointsDumpResponse response = FlowMirrorPointsDumpResponse.builder().flowId(FLOW_ID).points(points).build();
FlowMirrorPointsResponseV2 apiResponse = flowMapper.toFlowMirrorPointsResponseV2(response);
assertEquals(response.getFlowId(), apiResponse.getFlowId());
assertEquals(2, apiResponse.getPoints().size());
FlowMirrorPointPayload firstPayload = apiResponse.getPoints().get(0);
assertEquals(firstPoint.getMirrorPointId(), firstPayload.getMirrorPointId());
assertEquals(firstPoint.getMirrorPointDirection(), firstPayload.getMirrorPointDirection());
assertEquals(firstPoint.getMirrorPointSwitchId(), firstPayload.getMirrorPointSwitchId());
assertEquals(firstPoint.getSinkEndpoint().getSwitchId(), firstPayload.getSinkEndpoint().getSwitchId());
assertEquals(firstPoint.getSinkEndpoint().getPortNumber(), firstPayload.getSinkEndpoint().getPortNumber());
assertEquals(firstPoint.getSinkEndpoint().getOuterVlanId(), firstPayload.getSinkEndpoint().getVlanId());
assertEquals(firstPoint.getSinkEndpoint().getInnerVlanId(), firstPayload.getSinkEndpoint().getInnerVlanId());
FlowMirrorPointPayload secondPayload = apiResponse.getPoints().get(1);
assertEquals(secondPoint.getMirrorPointId(), secondPayload.getMirrorPointId());
assertEquals(secondPoint.getMirrorPointDirection(), secondPayload.getMirrorPointDirection());
assertEquals(secondPoint.getMirrorPointSwitchId(), secondPayload.getMirrorPointSwitchId());
assertEquals(secondPoint.getSinkEndpoint().getSwitchId(), secondPayload.getSinkEndpoint().getSwitchId());
assertEquals(secondPoint.getSinkEndpoint().getPortNumber(), secondPayload.getSinkEndpoint().getPortNumber());
assertEquals(secondPoint.getSinkEndpoint().getOuterVlanId(), secondPayload.getSinkEndpoint().getVlanId());
assertEquals(secondPoint.getSinkEndpoint().getInnerVlanId(), secondPayload.getSinkEndpoint().getInnerVlanId());
}
Aggregations