### Question:
PacketService { @VisibleForTesting FlowRelatedData findFlowRelatedDataForVlanFlow(ConnectedDevicePacketBase data) { if (data.getVlans().isEmpty()) { log.warn("Got {} packet without transit VLAN: {}", getPacketName(data), data); return null; } int transitVlan = data.getVlans().get(0); Flow flow = findFlowByTransitVlan(transitVlan); if (flow == null) { return null; } int customerVlan = data.getVlans().size() > 1 ? data.getVlans().get(1) : 0; if (data.getSwitchId().equals(flow.getSrcSwitchId())) { if (flow.getSrcVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(customerVlan, flow.getFlowId(), true); } else { return new FlowRelatedData(flow.getSrcVlan(), flow.getFlowId(), true); } } else if (data.getSwitchId().equals(flow.getDestSwitchId())) { if (flow.getDestVlan() == FULL_PORT_VLAN) { return new FlowRelatedData(customerVlan, flow.getFlowId(), false); } else { return new FlowRelatedData(flow.getDestVlan(), flow.getFlowId(), false); } } else { log.warn("Got {} packet from Flow {} on non-src/non-dst switch {}. Transit vlan: {}", getPacketName(data), flow.getFlowId(), data.getSwitchId(), transitVlan); return null; } } PacketService(PersistenceManager persistenceManager); void handleLldpData(LldpInfoData data); void handleArpData(ArpInfoData data); static final int FULL_PORT_VLAN; }### Answer:
@Test @Parameters(method = "getVlanFlowParameters") public void findFlowRelatedDataForVlanFlowTest( int inVlan, int srcVlan, int dstVlan, int transitVlan, List<Integer> vlansInPacket, boolean source) { createFlow(FLOW_ID, srcVlan, dstVlan, transitVlan, false, false); LldpInfoData data = createLldpInfoDataData( source ? SWITCH_ID_1 : SWITCH_ID_2, vlansInPacket, source ? PORT_NUMBER_1 : PORT_NUMBER_2); FlowRelatedData flowRelatedData = packetService.findFlowRelatedDataForVlanFlow(data); assertEquals(FLOW_ID, flowRelatedData.getFlowId()); assertEquals(inVlan, flowRelatedData.getOriginalVlan()); assertEquals(source, flowRelatedData.getSource()); }