@Test public void testFlowPatchDtoToFlowDto() { FlowPatchDto flowPatchDto = new FlowPatchDto(LATENCY, PRIORITY, PERIODIC_PINGS, TARGET_PATH_COMPUTATION_STRATEGY); FlowPatch flowPatch = flowMapper.toFlowPatch(flowPatchDto); assertEquals(flowPatchDto.getMaxLatency() * 1000000L, (long) flowPatch.getMaxLatency()); assertEquals(flowPatchDto.getPriority(), flowPatch.getPriority()); assertEquals(flowPatchDto.getPeriodicPings(), flowPatch.getPeriodicPings()); assertEquals(flowPatchDto.getTargetPathComputationStrategy(), flowPatch.getTargetPathComputationStrategy().name().toLowerCase()); }
@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) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto);
FlowMapper { @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) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); }
FlowMapper { @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) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto);  }
FlowMapper { @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) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto);  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 = "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) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto);  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);  }