@Test public void testFlowRequestV2Mapping() { FlowRequestV2 flowRequestV2 = FlowRequestV2.builder() .flowId(FLOW_ID) .encapsulationType(ENCAPSULATION_TYPE) .source(new FlowEndpointV2(SRC_SWITCH_ID, SRC_PORT, SRC_VLAN, SRC_DETECT_CONNECTED_DEVICES)) .destination(new FlowEndpointV2(DST_SWITCH_ID, DST_PORT, DST_VLAN, DST_DETECT_CONNECTED_DEVICES)) .description(DESCRIPTION) .maximumBandwidth(BANDWIDTH) .maxLatency(LATENCY) .priority(PRIORITY) .diverseFlowId(DIVERSE_FLOW_ID) .build(); FlowRequest flowRequest = flowMapper.toFlowRequest(flowRequestV2); assertEquals(FLOW_ID, flowRequest.getFlowId()); assertEquals(SRC_SWITCH_ID, flowRequest.getSource().getSwitchId()); assertEquals(SRC_PORT, (int) flowRequest.getSource().getPortNumber()); assertEquals(SRC_VLAN, flowRequest.getSource().getOuterVlanId()); assertEquals(DST_SWITCH_ID, flowRequest.getDestination().getSwitchId()); assertEquals(DST_PORT, (int) flowRequest.getDestination().getPortNumber()); assertEquals(DST_VLAN, flowRequest.getDestination().getOuterVlanId()); assertEquals(FlowEncapsulationType.TRANSIT_VLAN, flowRequest.getEncapsulationType()); assertEquals(DESCRIPTION, flowRequest.getDescription()); assertEquals(BANDWIDTH, flowRequest.getBandwidth()); assertEquals(LATENCY * 1000000L, (long) flowRequest.getMaxLatency()); assertEquals(PRIORITY, flowRequest.getPriority()); assertEquals(DIVERSE_FLOW_ID, flowRequest.getDiverseFlowId()); assertEquals(SRC_DETECT_CONNECTED_DEVICES.isLldp(), flowRequest.getDetectConnectedDevices().isSrcLldp()); assertEquals(SRC_DETECT_CONNECTED_DEVICES.isArp(), flowRequest.getDetectConnectedDevices().isSrcArp()); assertEquals(DST_DETECT_CONNECTED_DEVICES.isLldp(), flowRequest.getDetectConnectedDevices().isDstLldp()); assertEquals(DST_DETECT_CONNECTED_DEVICES.isArp(), flowRequest.getDetectConnectedDevices().isDstArp()); }
@Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request);
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request); }
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request);  }
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request);  FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request);  FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error);  }