### Question:
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; }  List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
                                                                     EncapsulationId encapsulationId,
                                                                     long flowMeterMinBurstSizeInKbits,
                                                                     double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
                                                                              SwitchMeterEntries meters);  }### Answer:
@Test public void shouldConvertFlowPathWithTransitVlanEncapToSimpleSwitchRules() { Flow flow = buildFlow(FlowEncapsulationType.TRANSIT_VLAN); List<SimpleSwitchRule> expectedSwitchRules = getSimpleSwitchRuleForTransitVlan(); List<SimpleSwitchRule> switchRules = simpleSwitchRuleConverter.convertFlowPathToSimpleSwitchRules(flow, flow.getForwardPath(), TransitVlan.builder() .flowId(TEST_FLOW_ID_A) .pathId(FLOW_A_FORWARD_PATH_ID) .vlan(FLOW_A_ENCAP_ID) .build(), MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT); assertEquals(expectedSwitchRules, switchRules); }
@Test public void convertFlowWithIngressVlanIdMatchesTransitVlanId() { Flow flow = buildFlow(FlowEncapsulationType.TRANSIT_VLAN); Assert.assertNotEquals(0, flow.getSrcVlan()); Assert.assertNotNull(flow.getForwardPath()); TransitVlan encapsulation = TransitVlan.builder() .flowId(flow.getFlowId()) .pathId(flow.getForwardPathId()) .vlan(flow.getSrcVlan()) .build(); List<SimpleSwitchRule> pathView = simpleSwitchRuleConverter.convertFlowPathToSimpleSwitchRules( flow, flow.getForwardPath(), encapsulation, MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT); Assert.assertFalse(pathView.isEmpty()); SimpleSwitchRule ingress = pathView.get(0); Assert.assertEquals(Collections.emptyList(), ingress.getOutVlan()); }
@Test public void shouldConvertFlowPathWithVxlanEncapToSimpleSwitchRules() { Flow flow = buildFlow(FlowEncapsulationType.VXLAN); List<SimpleSwitchRule> expectedSwitchRules = getSimpleSwitchRuleForVxlan(); List<SimpleSwitchRule> switchRules = simpleSwitchRuleConverter.convertFlowPathToSimpleSwitchRules(flow, flow.getForwardPath(), Vxlan.builder() .flowId(TEST_FLOW_ID_A) .pathId(FLOW_A_FORWARD_PATH_ID) .vni(FLOW_A_ENCAP_ID) .build(), MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT); assertEquals(expectedSwitchRules, switchRules); }
@Test public void shouldConvertFlowPathOneSwitchFlowToSimpleSwitchRules() { Flow flow = buildOneSwitchPortFlow(); List<SimpleSwitchRule> expectedSwitchRules = getSimpleSwitchRuleForOneSwitchFlow(); List<SimpleSwitchRule> switchRules = simpleSwitchRuleConverter.convertFlowPathToSimpleSwitchRules(flow, flow.getForwardPath(), null, MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT); assertEquals(expectedSwitchRules, switchRules); }