use of org.openkilda.northbound.dto.v2.flows.FlowRequestV2 in project open-kilda by telstra.
the class FlowMapperTest method testFlowRequestV2Mapping.
@Test
public void testFlowRequestV2Mapping() {
FlowRequestV2 flowRequestV2 = FlowRequestV2.builder().flowId(FLOW_ID).encapsulationType(ENCAPSULATION_TYPE).source(new FlowEndpointV2(SRC_SWITCH_ID, SRC_PORT, SRC_VLAN, SRC_DETECT_CONNECTED_DEVICES)).destination(new FlowEndpointV2(DST_SWITCH_ID, DST_PORT, DST_VLAN, DST_DETECT_CONNECTED_DEVICES)).description(DESCRIPTION).maximumBandwidth(BANDWIDTH).maxLatency(LATENCY).maxLatencyTier2(LATENCY_TIER2).priority(PRIORITY).diverseFlowId(DIVERSE_FLOW_ID).build();
FlowRequest flowRequest = flowMapper.toFlowRequest(flowRequestV2);
assertEquals(FLOW_ID, flowRequest.getFlowId());
assertEquals(SRC_SWITCH_ID, flowRequest.getSource().getSwitchId());
assertEquals(SRC_PORT, (int) flowRequest.getSource().getPortNumber());
assertEquals(SRC_VLAN, flowRequest.getSource().getOuterVlanId());
assertEquals(DST_SWITCH_ID, flowRequest.getDestination().getSwitchId());
assertEquals(DST_PORT, (int) flowRequest.getDestination().getPortNumber());
assertEquals(DST_VLAN, flowRequest.getDestination().getOuterVlanId());
assertEquals(FlowEncapsulationType.TRANSIT_VLAN, flowRequest.getEncapsulationType());
assertEquals(DESCRIPTION, flowRequest.getDescription());
assertEquals(BANDWIDTH, flowRequest.getBandwidth());
// ms to ns
assertEquals(LATENCY * MS_TO_NS_MULTIPLIER, (long) flowRequest.getMaxLatency());
assertEquals(LATENCY_TIER2 * MS_TO_NS_MULTIPLIER, (long) flowRequest.getMaxLatencyTier2());
assertEquals(PRIORITY, flowRequest.getPriority());
assertEquals(DIVERSE_FLOW_ID, flowRequest.getDiverseFlowId());
assertEquals(SRC_DETECT_CONNECTED_DEVICES.isLldp(), flowRequest.getDetectConnectedDevices().isSrcLldp());
assertEquals(SRC_DETECT_CONNECTED_DEVICES.isArp(), flowRequest.getDetectConnectedDevices().isSrcArp());
assertEquals(DST_DETECT_CONNECTED_DEVICES.isLldp(), flowRequest.getDetectConnectedDevices().isDstLldp());
assertEquals(DST_DETECT_CONNECTED_DEVICES.isArp(), flowRequest.getDetectConnectedDevices().isDstArp());
}
use of org.openkilda.northbound.dto.v2.flows.FlowRequestV2 in project open-kilda by telstra.
the class FlowMapperTest method testFlowRequestV2InvalidEncapsulation.
@Test(expected = IllegalArgumentException.class)
public void testFlowRequestV2InvalidEncapsulation() {
FlowRequestV2 flowRequestV2 = FlowRequestV2.builder().flowId(FLOW_ID).encapsulationType("abc").source(new FlowEndpointV2(SRC_SWITCH_ID, SRC_PORT, SRC_VLAN, SRC_DETECT_CONNECTED_DEVICES)).destination(new FlowEndpointV2(DST_SWITCH_ID, DST_PORT, DST_VLAN, DST_DETECT_CONNECTED_DEVICES)).build();
flowMapper.toFlowRequest(flowRequestV2);
}
Aggregations