@Test public void testFlowPairToDto() { PathInfoData pathInfoData = new PathInfoData(); pathInfoData.setLatency(1L); pathInfoData.setPath(asList( new PathNode(SRC_SWITCH_ID, 1, 1, 1L, 1L), new PathNode(DST_SWITCH_ID, 2, 2, 2L, 2L) )); FlowDto forwardFlow = new FlowDto(); forwardFlow.setSourceSwitch(SRC_SWITCH_ID); forwardFlow.setDestinationSwitch(DST_SWITCH_ID); forwardFlow.setFlowId("12"); forwardFlow.setCookie(11); forwardFlow.setSourcePort(113); forwardFlow.setSourceVlan(1112); forwardFlow.setDestinationPort(113); forwardFlow.setDestinationVlan(1112); forwardFlow.setBandwidth(23); forwardFlow.setDescription("SOME FLOW"); forwardFlow.setLastUpdated("2011-12-03T10:15:30Z"); forwardFlow.setTransitEncapsulationId(87); forwardFlow.setMeterId(65); forwardFlow.setIgnoreBandwidth(true); forwardFlow.setPeriodicPings(true); forwardFlow.setEncapsulationType(FlowEncapsulationType.TRANSIT_VLAN); forwardFlow.setDetectConnectedDevices(new DetectConnectedDevicesDto( false, true, true, false, false, false, true, true)); PathInfoData reversePathInfoData = new PathInfoData(); reversePathInfoData.setLatency(1L); reversePathInfoData.setPath(asList( new PathNode(DST_SWITCH_ID, 2, 2, 2L, 2L), new PathNode(SRC_SWITCH_ID, 1, 1, 1L, 1L) )); FlowDto reverseFlow = new FlowDto(); reverseFlow.setSourceSwitch(forwardFlow.getDestinationSwitch()); reverseFlow.setDestinationSwitch(SRC_SWITCH_ID); reverseFlow.setFlowId("12"); reverseFlow.setCookie(12); reverseFlow.setSourcePort(113); reverseFlow.setSourceVlan(1112); reverseFlow.setDestinationPort(113); reverseFlow.setDestinationVlan(1112); reverseFlow.setBandwidth(23); reverseFlow.setDescription("SOME FLOW"); reverseFlow.setLastUpdated("2011-12-03T10:15:30Z"); reverseFlow.setTransitEncapsulationId(88); reverseFlow.setMeterId(66); reverseFlow.setIgnoreBandwidth(true); reverseFlow.setPeriodicPings(true); reverseFlow.setEncapsulationType(FlowEncapsulationType.TRANSIT_VLAN); reverseFlow.setDetectConnectedDevices(new DetectConnectedDevicesDto( true, false, false, true, false, false, true, true)); FlowPairDto<FlowDto, FlowDto> pair = new FlowPairDto<>(forwardFlow, reverseFlow); Flow p = FlowMapper.INSTANCE.map(pair, () -> KildaConfiguration.DEFAULTS); assertEquals(p.getFlowId(), pair.getLeft().getFlowId()); assertDetectConnectedDevices(forwardFlow.getDetectConnectedDevices(), p.getDetectConnectedDevices()); }
@Mapping(source = "srcPort", target = "sourcePort") @Mapping(source = "srcVlan", target = "sourceVlan") @Mapping(source = "srcInnerVlan", target = "sourceInnerVlan") @Mapping(source = "destPort", target = "destinationPort") @Mapping(source = "destVlan", target = "destinationVlan") @Mapping(source = "destInnerVlan", target = "destinationInnerVlan") @Mapping(target = "sourceSwitch", expression = "java(flow.getSrcSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(flow.getDestSwitchId())") @Mapping(source = "status", target = "state") @Mapping(source = "timeModify", target = "lastUpdated") @Mapping(source = "timeCreate", target = "createdTime") @Mapping(target = "flowStatusDetails", expression = "java(flow.isAllocateProtectedPath() ? " + "new FlowStatusDetails(flow.getMainFlowPrioritizedPathsStatus(), " + "flow.getProtectedFlowPrioritizedPathsStatus()) : null)") @Mapping(target = "cookie", ignore = true) @Mapping(target = "meterId", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseWith", ignore = true) public abstract FlowDto map(Flow flow);
FlowMapper { @Mapping(source = "srcPort", target = "sourcePort") @Mapping(source = "srcVlan", target = "sourceVlan") @Mapping(source = "srcInnerVlan", target = "sourceInnerVlan") @Mapping(source = "destPort", target = "destinationPort") @Mapping(source = "destVlan", target = "destinationVlan") @Mapping(source = "destInnerVlan", target = "destinationInnerVlan") @Mapping(target = "sourceSwitch", expression = "java(flow.getSrcSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(flow.getDestSwitchId())") @Mapping(source = "status", target = "state") @Mapping(source = "timeModify", target = "lastUpdated") @Mapping(source = "timeCreate", target = "createdTime") @Mapping(target = "flowStatusDetails", expression = "java(flow.isAllocateProtectedPath() ? " + "new FlowStatusDetails(flow.getMainFlowPrioritizedPathsStatus(), " + "flow.getProtectedFlowPrioritizedPathsStatus()) : null)") @Mapping(target = "cookie", ignore = true) @Mapping(target = "meterId", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseWith", ignore = true) public abstract FlowDto map(Flow flow); }
FlowMapper { @Mapping(source = "srcPort", target = "sourcePort") @Mapping(source = "srcVlan", target = "sourceVlan") @Mapping(source = "srcInnerVlan", target = "sourceInnerVlan") @Mapping(source = "destPort", target = "destinationPort") @Mapping(source = "destVlan", target = "destinationVlan") @Mapping(source = "destInnerVlan", target = "destinationInnerVlan") @Mapping(target = "sourceSwitch", expression = "java(flow.getSrcSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(flow.getDestSwitchId())") @Mapping(source = "status", target = "state") @Mapping(source = "timeModify", target = "lastUpdated") @Mapping(source = "timeCreate", target = "createdTime") @Mapping(target = "flowStatusDetails", expression = "java(flow.isAllocateProtectedPath() ? " + "new FlowStatusDetails(flow.getMainFlowPrioritizedPathsStatus(), " + "flow.getProtectedFlowPrioritizedPathsStatus()) : null)") @Mapping(target = "cookie", ignore = true) @Mapping(target = "meterId", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseWith", ignore = true) public abstract FlowDto map(Flow flow);  }
FlowMapper { @Mapping(source = "srcPort", target = "sourcePort") @Mapping(source = "srcVlan", target = "sourceVlan") @Mapping(source = "srcInnerVlan", target = "sourceInnerVlan") @Mapping(source = "destPort", target = "destinationPort") @Mapping(source = "destVlan", target = "destinationVlan") @Mapping(source = "destInnerVlan", target = "destinationInnerVlan") @Mapping(target = "sourceSwitch", expression = "java(flow.getSrcSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(flow.getDestSwitchId())") @Mapping(source = "status", target = "state") @Mapping(source = "timeModify", target = "lastUpdated") @Mapping(source = "timeCreate", target = "createdTime") @Mapping(target = "flowStatusDetails", expression = "java(flow.isAllocateProtectedPath() ? " + "new FlowStatusDetails(flow.getMainFlowPrioritizedPathsStatus(), " + "flow.getProtectedFlowPrioritizedPathsStatus()) : null)") @Mapping(target = "cookie", ignore = true) @Mapping(target = "meterId", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseWith", ignore = true) public abstract FlowDto map(Flow flow);  @Mapping(source = "srcPort", target = "sourcePort") @Mapping(source = "srcVlan", target = "sourceVlan") @Mapping(source = "srcInnerVlan", target = "sourceInnerVlan") @Mapping(source = "destPort", target = "destinationPort") @Mapping(source = "destVlan", target = "destinationVlan") @Mapping(source = "destInnerVlan", target = "destinationInnerVlan") @Mapping(target = "sourceSwitch", expression = "java(flow.getSrcSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(flow.getDestSwitchId())") @Mapping(source = "status", target = "state") @Mapping(source = "timeModify", target = "lastUpdated") @Mapping(source = "timeCreate", target = "createdTime") @Mapping(target = "flowStatusDetails", expression = "java(flow.isAllocateProtectedPath() ? " + "new FlowStatusDetails(flow.getMainFlowPrioritizedPathsStatus(), " + "flow.getProtectedFlowPrioritizedPathsStatus()) : null)") @Mapping(target = "cookie", ignore = true) @Mapping(target = "meterId", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseWith", ignore = true) abstract FlowDto map(Flow flow); FlowDto map(Flow flow, Set<String> diverseWith); Flow map(FlowPairDto<FlowDto, FlowDto> flowPair, Supplier<KildaConfiguration> kildaConfiguration); Flow map(FlowDto flow, Supplier<KildaConfiguration> kildaConfiguration); Instant map(String value); String map(Instant value); FlowState map(FlowStatus status); FlowStatus map(FlowState status); org.openkilda.messaging.payload.flow.FlowEncapsulationType map(FlowEncapsulationType encapsulationType); Flow buildFlow(SwapFlowDto flow); }
FlowMapper { @Mapping(source = "srcPort", target = "sourcePort") @Mapping(source = "srcVlan", target = "sourceVlan") @Mapping(source = "srcInnerVlan", target = "sourceInnerVlan") @Mapping(source = "destPort", target = "destinationPort") @Mapping(source = "destVlan", target = "destinationVlan") @Mapping(source = "destInnerVlan", target = "destinationInnerVlan") @Mapping(target = "sourceSwitch", expression = "java(flow.getSrcSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(flow.getDestSwitchId())") @Mapping(source = "status", target = "state") @Mapping(source = "timeModify", target = "lastUpdated") @Mapping(source = "timeCreate", target = "createdTime") @Mapping(target = "flowStatusDetails", expression = "java(flow.isAllocateProtectedPath() ? " + "new FlowStatusDetails(flow.getMainFlowPrioritizedPathsStatus(), " + "flow.getProtectedFlowPrioritizedPathsStatus()) : null)") @Mapping(target = "cookie", ignore = true) @Mapping(target = "meterId", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseWith", ignore = true) public abstract FlowDto map(Flow flow);  @Mapping(source = "srcPort", target = "sourcePort") @Mapping(source = "srcVlan", target = "sourceVlan") @Mapping(source = "srcInnerVlan", target = "sourceInnerVlan") @Mapping(source = "destPort", target = "destinationPort") @Mapping(source = "destVlan", target = "destinationVlan") @Mapping(source = "destInnerVlan", target = "destinationInnerVlan") @Mapping(target = "sourceSwitch", expression = "java(flow.getSrcSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(flow.getDestSwitchId())") @Mapping(source = "status", target = "state") @Mapping(source = "timeModify", target = "lastUpdated") @Mapping(source = "timeCreate", target = "createdTime") @Mapping(target = "flowStatusDetails", expression = "java(flow.isAllocateProtectedPath() ? " + "new FlowStatusDetails(flow.getMainFlowPrioritizedPathsStatus(), " + "flow.getProtectedFlowPrioritizedPathsStatus()) : null)") @Mapping(target = "cookie", ignore = true) @Mapping(target = "meterId", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseWith", ignore = true) abstract FlowDto map(Flow flow); FlowDto map(Flow flow, Set<String> diverseWith); Flow map(FlowPairDto<FlowDto, FlowDto> flowPair, Supplier<KildaConfiguration> kildaConfiguration); Flow map(FlowDto flow, Supplier<KildaConfiguration> kildaConfiguration); Instant map(String value); String map(Instant value); FlowState map(FlowStatus status); FlowStatus map(FlowState status); org.openkilda.messaging.payload.flow.FlowEncapsulationType map(FlowEncapsulationType encapsulationType); Flow buildFlow(SwapFlowDto flow); static final FlowMapper INSTANCE; }