Search in sources :

Example 1 with FlowPairDto

use of org.openkilda.messaging.model.FlowPairDto in project open-kilda by telstra.

the class FlowMapperTest method testFlowPairToDto.

@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());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowDto(org.openkilda.messaging.model.FlowDto) DetectConnectedDevicesDto(org.openkilda.messaging.model.DetectConnectedDevicesDto) FlowPairDto(org.openkilda.messaging.model.FlowPairDto) PathNode(org.openkilda.messaging.info.event.PathNode) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)1 PathNode (org.openkilda.messaging.info.event.PathNode)1 DetectConnectedDevicesDto (org.openkilda.messaging.model.DetectConnectedDevicesDto)1 FlowDto (org.openkilda.messaging.model.FlowDto)1 FlowPairDto (org.openkilda.messaging.model.FlowPairDto)1 Flow (org.openkilda.model.Flow)1