@Test public void testStatusDetailsMapping() { Flow flow = Flow.builder() .flowId("test_flow") .srcSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()) .destSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()) .allocateProtectedPath(true) .build(); FlowPath forwardFlowPath = FlowPath.builder() .pathId(new PathId("forward_flow_path")) .srcSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()) .destSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()) .cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1)) .status(FlowPathStatus.ACTIVE) .build(); flow.setForwardPath(forwardFlowPath); FlowPath reverseFlowPath = FlowPath.builder() .pathId(new PathId("reverse_flow_path")) .srcSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()) .destSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()) .cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1)) .status(FlowPathStatus.ACTIVE) .build(); flow.setReversePath(reverseFlowPath); FlowPath forwardProtectedFlowPath = FlowPath.builder() .pathId(new PathId("forward_protected_flow_path")) .srcSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()) .destSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()) .cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 2)) .status(FlowPathStatus.INACTIVE) .build(); flow.setProtectedForwardPath(forwardProtectedFlowPath); FlowPath reverseProtectedFlowPath = FlowPath.builder() .pathId(new PathId("reverse_protected_flow_path")) .srcSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()) .destSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()) .cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 2)) .status(FlowPathStatus.INACTIVE) .build(); flow.setProtectedReversePath(reverseProtectedFlowPath); FlowDto flowDto = FlowMapper.INSTANCE.map(flow); assertNotNull(flowDto.getFlowStatusDetails()); assertEquals(FlowPathStatus.ACTIVE, flowDto.getFlowStatusDetails().getMainFlowPathStatus()); assertEquals(FlowPathStatus.INACTIVE, flowDto.getFlowStatusDetails().getProtectedFlowPathStatus()); assertDetectConnectedDevices(flowDto.getDetectConnectedDevices(), flow.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; }