@Test public void mapSwapDtoToRequesterFlowTest() { SwapFlowDto swapFlowDto = SwapFlowDto.builder() .flowId(FLOW_ID) .sourceSwitch(SRC_SWITCH_ID) .sourcePort(SRC_PORT) .sourceVlan(SRC_VLAN) .destinationSwitch(DST_SWITCH_ID) .destinationPort(DST_PORT) .destinationVlan(DST_VLAN) .build(); RequestedFlow requestedFlow = RequestedFlowMapper.INSTANCE.toRequestedFlow(swapFlowDto); assertEquals(FLOW_ID, requestedFlow.getFlowId()); assertEquals(SRC_SWITCH_ID, requestedFlow.getSrcSwitch()); assertEquals(SRC_PORT, requestedFlow.getSrcPort()); assertEquals(SRC_VLAN, requestedFlow.getSrcVlan()); assertEquals(DST_SWITCH_ID, requestedFlow.getDestSwitch()); assertEquals(DST_PORT, requestedFlow.getDestPort()); assertEquals(DST_VLAN, requestedFlow.getDestVlan()); }
public RequestedFlow toRequestedFlow(FlowRequest request) { RequestedFlow flow = generatedMap(request); RequestedFlowIncrementalMapper.INSTANCE.mapSource(flow, request.getSource()); RequestedFlowIncrementalMapper.INSTANCE.mapDestination(flow, request.getDestination()); return flow; }
RequestedFlowMapper { public RequestedFlow toRequestedFlow(FlowRequest request) { RequestedFlow flow = generatedMap(request); RequestedFlowIncrementalMapper.INSTANCE.mapSource(flow, request.getSource()); RequestedFlowIncrementalMapper.INSTANCE.mapDestination(flow, request.getDestination()); return flow; } }
RequestedFlowMapper { public RequestedFlow toRequestedFlow(FlowRequest request) { RequestedFlow flow = generatedMap(request); RequestedFlowIncrementalMapper.INSTANCE.mapSource(flow, request.getSource()); RequestedFlowIncrementalMapper.INSTANCE.mapDestination(flow, request.getDestination()); return flow; }  }
RequestedFlowMapper { public RequestedFlow toRequestedFlow(FlowRequest request) { RequestedFlow flow = generatedMap(request); RequestedFlowIncrementalMapper.INSTANCE.mapSource(flow, request.getSource()); RequestedFlowIncrementalMapper.INSTANCE.mapDestination(flow, request.getDestination()); return flow; }  RequestedFlow toRequestedFlow(FlowRequest request); @Mapping(source = "flowId", target = "flowId") @Mapping(target = "srcSwitch", expression = "java(flow.getSrcSwitchId())") @Mapping(source = "srcPort", target = "srcPort") @Mapping(source = "srcVlan", target = "srcVlan") @Mapping(target = "destSwitch", expression = "java(flow.getDestSwitchId())") @Mapping(source = "destPort", target = "destPort") @Mapping(source = "destVlan", target = "destVlan") @Mapping(source = "encapsulationType", target = "flowEncapsulationType") @Mapping(target = "diverseFlowId", ignore = true) abstract RequestedFlow toRequestedFlow(Flow flow); @Mapping(source = "flowId", target = "flowId") @Mapping(source = "sourceSwitch", target = "srcSwitch") @Mapping(source = "sourcePort", target = "srcPort") @Mapping(source = "sourceVlan", target = "srcVlan") @Mapping(source = "destinationSwitch", target = "destSwitch") @Mapping(source = "destinationPort", target = "destPort") @Mapping(source = "destinationVlan", target = "destVlan") @Mapping(target = "priority", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "periodicPings", ignore = true) @Mapping(target = "maxLatency", ignore = true) @Mapping(target = "flowEncapsulationType", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "srcWithMultiTable", ignore = true) @Mapping(target = "destWithMultiTable", ignore = true) @Mapping(target = "srcInnerVlan", ignore = true) @Mapping(target = "destInnerVlan", ignore = true) abstract RequestedFlow toRequestedFlow(SwapFlowDto flow); @Mapping(source = "flowId", target = "flowId") @Mapping(target = "srcSwitch", expression = "java(org.openkilda.model.Switch.builder().switchId(requestedFlow.getSrcSwitch()).build())") @Mapping(source = "srcPort", target = "srcPort") @Mapping(source = "srcVlan", target = "srcVlan") @Mapping(target = "destSwitch", expression = "java(org.openkilda.model.Switch.builder().switchId(requestedFlow.getDestSwitch()).build())") @Mapping(source = "destPort", target = "destPort") @Mapping(source = "destVlan", target = "destVlan") @Mapping(source = "flowEncapsulationType", target = "encapsulationType") @Mapping(target = "groupId", ignore = true) @Mapping(target = "status", ignore = true) @Mapping(target = "statusInfo", ignore = true) @Mapping(target = "targetPathComputationStrategy", ignore = true) abstract Flow toFlow(RequestedFlow requestedFlow); abstract FlowEncapsulationType map(org.openkilda.messaging.payload.flow.FlowEncapsulationType source); FlowEndpoint mapSource(RequestedFlow flow); FlowEndpoint mapDest(RequestedFlow flow); PathComputationStrategy mapComputationStrategy(String raw); @Mapping(target = "flowId", source = "flowId") @Mapping(target = "source", expression = "java(new FlowEndpoint(flow.getSrcSwitchId(), " + "flow.getSrcPort(), flow.getSrcVlan()))") @Mapping(target = "destination", expression = "java(new FlowEndpoint(flow.getDestSwitchId(), " + "flow.getDestPort(), flow.getDestVlan()))") @Mapping(target = "encapsulationType", source = "encapsulationType") @Mapping(target = "pathComputationStrategy", expression = "java(java.util.Optional.ofNullable(flow.getPathComputationStrategy())" + ".map(pcs -> pcs.toString().toLowerCase())" + ".orElse(null))") @Mapping(target = "bandwidth", source = "bandwidth") @Mapping(target = "ignoreBandwidth", source = "ignoreBandwidth") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "description", source = "description") @Mapping(target = "maxLatency", source = "maxLatency") @Mapping(target = "priority", source = "priority") @Mapping(target = "pinned", source = "pinned") @Mapping(target = "detectConnectedDevices", source = "detectConnectedDevices") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) abstract FlowRequest toFlowRequest(Flow flow); abstract DetectConnectedDevicesDto toDetectConnectedDevices(DetectConnectedDevices detectConnectedDevices); @Mapping(target = "flowId", source = "flowId") @Mapping(target = "source.datapath", source = "srcSwitch") @Mapping(target = "source.portNumber", source = "srcPort") @Mapping(target = "source.vlanId", source = "srcVlan") @Mapping(target = "source.innerVlanId", source = "srcInnerVlan") @Mapping(target = "destination.datapath", source = "destSwitch") @Mapping(target = "destination.portNumber", source = "destPort") @Mapping(target = "destination.vlanId", source = "destVlan") @Mapping(target = "destination.innerVlanId", source = "destInnerVlan") abstract ActivateFlowMonitoringInfoData toActivateFlowMonitoringInfoData(RequestedFlow flow); }
RequestedFlowMapper { public RequestedFlow toRequestedFlow(FlowRequest request) { RequestedFlow flow = generatedMap(request); RequestedFlowIncrementalMapper.INSTANCE.mapSource(flow, request.getSource()); RequestedFlowIncrementalMapper.INSTANCE.mapDestination(flow, request.getDestination()); return flow; }  RequestedFlow toRequestedFlow(FlowRequest request); @Mapping(source = "flowId", target = "flowId") @Mapping(target = "srcSwitch", expression = "java(flow.getSrcSwitchId())") @Mapping(source = "srcPort", target = "srcPort") @Mapping(source = "srcVlan", target = "srcVlan") @Mapping(target = "destSwitch", expression = "java(flow.getDestSwitchId())") @Mapping(source = "destPort", target = "destPort") @Mapping(source = "destVlan", target = "destVlan") @Mapping(source = "encapsulationType", target = "flowEncapsulationType") @Mapping(target = "diverseFlowId", ignore = true) abstract RequestedFlow toRequestedFlow(Flow flow); @Mapping(source = "flowId", target = "flowId") @Mapping(source = "sourceSwitch", target = "srcSwitch") @Mapping(source = "sourcePort", target = "srcPort") @Mapping(source = "sourceVlan", target = "srcVlan") @Mapping(source = "destinationSwitch", target = "destSwitch") @Mapping(source = "destinationPort", target = "destPort") @Mapping(source = "destinationVlan", target = "destVlan") @Mapping(target = "priority", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "periodicPings", ignore = true) @Mapping(target = "maxLatency", ignore = true) @Mapping(target = "flowEncapsulationType", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "srcWithMultiTable", ignore = true) @Mapping(target = "destWithMultiTable", ignore = true) @Mapping(target = "srcInnerVlan", ignore = true) @Mapping(target = "destInnerVlan", ignore = true) abstract RequestedFlow toRequestedFlow(SwapFlowDto flow); @Mapping(source = "flowId", target = "flowId") @Mapping(target = "srcSwitch", expression = "java(org.openkilda.model.Switch.builder().switchId(requestedFlow.getSrcSwitch()).build())") @Mapping(source = "srcPort", target = "srcPort") @Mapping(source = "srcVlan", target = "srcVlan") @Mapping(target = "destSwitch", expression = "java(org.openkilda.model.Switch.builder().switchId(requestedFlow.getDestSwitch()).build())") @Mapping(source = "destPort", target = "destPort") @Mapping(source = "destVlan", target = "destVlan") @Mapping(source = "flowEncapsulationType", target = "encapsulationType") @Mapping(target = "groupId", ignore = true) @Mapping(target = "status", ignore = true) @Mapping(target = "statusInfo", ignore = true) @Mapping(target = "targetPathComputationStrategy", ignore = true) abstract Flow toFlow(RequestedFlow requestedFlow); abstract FlowEncapsulationType map(org.openkilda.messaging.payload.flow.FlowEncapsulationType source); FlowEndpoint mapSource(RequestedFlow flow); FlowEndpoint mapDest(RequestedFlow flow); PathComputationStrategy mapComputationStrategy(String raw); @Mapping(target = "flowId", source = "flowId") @Mapping(target = "source", expression = "java(new FlowEndpoint(flow.getSrcSwitchId(), " + "flow.getSrcPort(), flow.getSrcVlan()))") @Mapping(target = "destination", expression = "java(new FlowEndpoint(flow.getDestSwitchId(), " + "flow.getDestPort(), flow.getDestVlan()))") @Mapping(target = "encapsulationType", source = "encapsulationType") @Mapping(target = "pathComputationStrategy", expression = "java(java.util.Optional.ofNullable(flow.getPathComputationStrategy())" + ".map(pcs -> pcs.toString().toLowerCase())" + ".orElse(null))") @Mapping(target = "bandwidth", source = "bandwidth") @Mapping(target = "ignoreBandwidth", source = "ignoreBandwidth") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "description", source = "description") @Mapping(target = "maxLatency", source = "maxLatency") @Mapping(target = "priority", source = "priority") @Mapping(target = "pinned", source = "pinned") @Mapping(target = "detectConnectedDevices", source = "detectConnectedDevices") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) abstract FlowRequest toFlowRequest(Flow flow); abstract DetectConnectedDevicesDto toDetectConnectedDevices(DetectConnectedDevices detectConnectedDevices); @Mapping(target = "flowId", source = "flowId") @Mapping(target = "source.datapath", source = "srcSwitch") @Mapping(target = "source.portNumber", source = "srcPort") @Mapping(target = "source.vlanId", source = "srcVlan") @Mapping(target = "source.innerVlanId", source = "srcInnerVlan") @Mapping(target = "destination.datapath", source = "destSwitch") @Mapping(target = "destination.portNumber", source = "destPort") @Mapping(target = "destination.vlanId", source = "destVlan") @Mapping(target = "destination.innerVlanId", source = "destInnerVlan") abstract ActivateFlowMonitoringInfoData toActivateFlowMonitoringInfoData(RequestedFlow flow); static final RequestedFlowMapper INSTANCE; }