@Test public void testVirtualPortMapping() throws Exception{ method = class1.getDeclaredMethod("virtualPortMapping", new Class[]{ VirtualNetworkId.class, VirtualNodeId.class, VirtualPort.class, PhysicalNode.class }); method.setAccessible(true); VirtualNetworkId virtualNetworkId = mock(VirtualNetworkId.class); VirtualNodeId virtualNodeId = mock(VirtualNodeId.class); VirtualPort virtualPort = mock(VirtualPort.class); PhysicalNode physicalNode = mock(PhysicalNode.class); VirtualPort.PortType portType = VirtualPort.PortType.Internal; PhysicalPort physicalPort = mock(PhysicalPort.class); List<PhysicalPort> physicalPorts = new ArrayList<PhysicalPort>(); List<PhysicalResourceRequirement> physicalResourceRequirements = new ArrayList<PhysicalResourceRequirement>(); physicalPorts.add(physicalPort); when(virtualPort.getPortType()) .thenReturn(null) .thenReturn(portType); Assert.assertTrue(method.invoke(vnMappingUnit, virtualNetworkId, virtualNodeId, virtualPort, physicalNode) == null); when(physicalNode.getPhysicalPort()).thenReturn(physicalPorts); when(virtualPort.getPhysicalResourceRequirement()).thenReturn(physicalResourceRequirements); when(physicalPort.getPortType()) .thenReturn(null) .thenReturn(PhysicalPort.PortType.External); Assert.assertTrue(method.invoke(vnMappingUnit, virtualNetworkId, virtualNodeId, virtualPort, physicalNode) == null); Assert.assertTrue(method.invoke(vnMappingUnit,virtualNetworkId,virtualNodeId,virtualPort,physicalNode) == null); }
private PhysicalPort virtualPortMapping(VirtualNetworkId virtualNetworkId, VirtualNodeId virtualNodeId, VirtualPort virtualPort, PhysicalNode physicalNode) throws VNMappingException { if ( VirtualPort.PortType.Internal == virtualPort.getPortType() ) { return null; } List<PhysicalPort> physicalPorts = physicalNode.getPhysicalPort(); List<PhysicalResourceRequirement> physicalResourceRequirements = virtualPort.getPhysicalResourceRequirement(); for ( PhysicalPort physicalPort : physicalPorts ) { if ( PhysicalPort.PortType.External == physicalPort.getPortType() && checkPhysicalPortSatisfied(physicalPort, physicalResourceRequirements) ) { return physicalPort; } } return null; }
VNMappingUnit implements AutoCloseable { private PhysicalPort virtualPortMapping(VirtualNetworkId virtualNetworkId, VirtualNodeId virtualNodeId, VirtualPort virtualPort, PhysicalNode physicalNode) throws VNMappingException { if ( VirtualPort.PortType.Internal == virtualPort.getPortType() ) { return null; } List<PhysicalPort> physicalPorts = physicalNode.getPhysicalPort(); List<PhysicalResourceRequirement> physicalResourceRequirements = virtualPort.getPhysicalResourceRequirement(); for ( PhysicalPort physicalPort : physicalPorts ) { if ( PhysicalPort.PortType.External == physicalPort.getPortType() && checkPhysicalPortSatisfied(physicalPort, physicalResourceRequirements) ) { return physicalPort; } } return null; } }
VNMappingUnit implements AutoCloseable { private PhysicalPort virtualPortMapping(VirtualNetworkId virtualNetworkId, VirtualNodeId virtualNodeId, VirtualPort virtualPort, PhysicalNode physicalNode) throws VNMappingException { if ( VirtualPort.PortType.Internal == virtualPort.getPortType() ) { return null; } List<PhysicalPort> physicalPorts = physicalNode.getPhysicalPort(); List<PhysicalResourceRequirement> physicalResourceRequirements = virtualPort.getPhysicalResourceRequirement(); for ( PhysicalPort physicalPort : physicalPorts ) { if ( PhysicalPort.PortType.External == physicalPort.getPortType() && checkPhysicalPortSatisfied(physicalPort, physicalResourceRequirements) ) { return physicalPort; } } return null; } VNMappingUnit(DataBroker dataBroker,
                         PNComputationUnit pnComputationUnit,
                         PNResourcesTracker pnResourcesTracker); }
VNMappingUnit implements AutoCloseable { private PhysicalPort virtualPortMapping(VirtualNetworkId virtualNetworkId, VirtualNodeId virtualNodeId, VirtualPort virtualPort, PhysicalNode physicalNode) throws VNMappingException { if ( VirtualPort.PortType.Internal == virtualPort.getPortType() ) { return null; } List<PhysicalPort> physicalPorts = physicalNode.getPhysicalPort(); List<PhysicalResourceRequirement> physicalResourceRequirements = virtualPort.getPhysicalResourceRequirement(); for ( PhysicalPort physicalPort : physicalPorts ) { if ( PhysicalPort.PortType.External == physicalPort.getPortType() && checkPhysicalPortSatisfied(physicalPort, physicalResourceRequirements) ) { return physicalPort; } } return null; } VNMappingUnit(DataBroker dataBroker,
                         PNComputationUnit pnComputationUnit,
                         PNResourcesTracker pnResourcesTracker); void virtualNetworkMapping(VirtualNetwork virtualNetwork, UserVnPnMapping userVnPnMapping,
                                      List<PhysicalPath> physicalPaths); void virtualNetworkMapping(VirtualNetwork virtualNetwork, List<VirtualLink> unmappedVirtualLinks,
                                      UserVnPnMapping userVnPnMapping, List<PhysicalPath> physicalPaths); @Override void close(); }
VNMappingUnit implements AutoCloseable { private PhysicalPort virtualPortMapping(VirtualNetworkId virtualNetworkId, VirtualNodeId virtualNodeId, VirtualPort virtualPort, PhysicalNode physicalNode) throws VNMappingException { if ( VirtualPort.PortType.Internal == virtualPort.getPortType() ) { return null; } List<PhysicalPort> physicalPorts = physicalNode.getPhysicalPort(); List<PhysicalResourceRequirement> physicalResourceRequirements = virtualPort.getPhysicalResourceRequirement(); for ( PhysicalPort physicalPort : physicalPorts ) { if ( PhysicalPort.PortType.External == physicalPort.getPortType() && checkPhysicalPortSatisfied(physicalPort, physicalResourceRequirements) ) { return physicalPort; } } return null; } VNMappingUnit(DataBroker dataBroker,
                         PNComputationUnit pnComputationUnit,
                         PNResourcesTracker pnResourcesTracker); void virtualNetworkMapping(VirtualNetwork virtualNetwork, UserVnPnMapping userVnPnMapping,
                                      List<PhysicalPath> physicalPaths); void virtualNetworkMapping(VirtualNetwork virtualNetwork, List<VirtualLink> unmappedVirtualLinks,
                                      UserVnPnMapping userVnPnMapping, List<PhysicalPath> physicalPaths); @Override void close();  }