@Test public void testResolveNode3() throws Exception { User user = mock(User.class); Node node = mock(Node.class); VirtualNetwork virtualNetwork = mock(VirtualNetwork.class); UserIntentVnMapping userIntentVnMapping = mock(UserIntentVnMapping.class); NodeId nodeId = mock(NodeId.class); Property property = mock(Property.class); Property property1 = mock(Property.class); StringValue stringValue = mock(StringValue.class); PhysicalNodeId physicalNodeId = mock(PhysicalNodeId.class); VirtualNodes virtualNodes_temp = mock(VirtualNodes.class); PropertyValues propertyValues = mock(PropertyValues.class); List<VirtualNode> virtualNodes = new ArrayList<VirtualNode>(); List<StringValue> stringValueList = new ArrayList<StringValue>(); List<IntentVnMappingResult> intentVnMappingResultList = new ArrayList<IntentVnMappingResult>(); stringValueList.add(stringValue); PowerMockito.mockStatic(IntentResolverUtils.class); PowerMockito.when(IntentResolverUtils.checkExternalLayer3Group(node)) .thenReturn(false) .thenReturn(true); when(node.getNodeType()).thenReturn(new NodeType("ext-group")); nodeMapper.resolveNode(user, node, virtualNetwork, userIntentVnMapping); when(node.getProperty()).thenReturn(new ArrayList<Property>()); PowerMockito.when(IntentResolverUtils.getNodeProperty(node.getProperty(), new PropertyName("location"))) .thenReturn(property); PowerMockito.when(IntentResolverUtils.generatePhysicalNodeIdFromNodeLocationProperty(property)) .thenReturn(physicalNodeId); when(physicalNodeId.getValue()).thenReturn(new String("test")); when(virtualNetwork.getVirtualNodes()).thenReturn(virtualNodes_temp); when(virtualNodes_temp.getVirtualNode()).thenReturn(virtualNodes); PowerMockito.when(IntentResolverUtils.getNodeProperty(node.getProperty(), new PropertyName("ip-prefix"))) .thenReturn(property1); when(property1.getPropertyValues()).thenReturn(propertyValues); when(propertyValues.getStringValue()).thenReturn(stringValueList); when(stringValue.getValue()) .thenReturn("192.168.1.1/24") .thenReturn("Test"); when(property.getPropertyValues()).thenReturn(propertyValues); when(node.getNodeId()).thenReturn(nodeId); when(nodeId.getValue()).thenReturn(new String("00001111-1111-0000-0000-000011112222")); when(userIntentVnMapping.getIntentVnMappingResult()).thenReturn(intentVnMappingResultList); nodeMapper.resolveNode(user, node, virtualNetwork, userIntentVnMapping); verify(stringValue,times(2)).getValue(); }
protected void resolveNode(User user, Node node, VirtualNetwork virtualNetwork, UserIntentVnMapping userIntentVnMapping) throws IntentResolutionException { NodeType nodeType = node.getNodeType(); if ( nodeType.equals(new NodeType("host")) ) { resolveHost(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType(("l2-group"))) ) { resolveLayer2Group(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("l3-group")) ) { resolveLayer3Group(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("ext-group")) ) { if ( IntentResolverUtils.checkExternalLayer3Group(node) ) { resolveExternalLayer3Group(user, node, virtualNetwork, userIntentVnMapping); } return; } if ( nodeType.equals(new NodeType("chain-group")) ) { resolveServiceChainGroup(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("fw")) || nodeType.equals(new NodeType("lb")) || nodeType.equals(new NodeType("cache")) ) { resolveServiceFunction(user, node, virtualNetwork, userIntentVnMapping); return; } throw new IntentResolutionException("Unknown node type."); }
NodeMapper { protected void resolveNode(User user, Node node, VirtualNetwork virtualNetwork, UserIntentVnMapping userIntentVnMapping) throws IntentResolutionException { NodeType nodeType = node.getNodeType(); if ( nodeType.equals(new NodeType("host")) ) { resolveHost(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType(("l2-group"))) ) { resolveLayer2Group(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("l3-group")) ) { resolveLayer3Group(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("ext-group")) ) { if ( IntentResolverUtils.checkExternalLayer3Group(node) ) { resolveExternalLayer3Group(user, node, virtualNetwork, userIntentVnMapping); } return; } if ( nodeType.equals(new NodeType("chain-group")) ) { resolveServiceChainGroup(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("fw")) || nodeType.equals(new NodeType("lb")) || nodeType.equals(new NodeType("cache")) ) { resolveServiceFunction(user, node, virtualNetwork, userIntentVnMapping); return; } throw new IntentResolutionException("Unknown node type."); } }
NodeMapper { protected void resolveNode(User user, Node node, VirtualNetwork virtualNetwork, UserIntentVnMapping userIntentVnMapping) throws IntentResolutionException { NodeType nodeType = node.getNodeType(); if ( nodeType.equals(new NodeType("host")) ) { resolveHost(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType(("l2-group"))) ) { resolveLayer2Group(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("l3-group")) ) { resolveLayer3Group(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("ext-group")) ) { if ( IntentResolverUtils.checkExternalLayer3Group(node) ) { resolveExternalLayer3Group(user, node, virtualNetwork, userIntentVnMapping); } return; } if ( nodeType.equals(new NodeType("chain-group")) ) { resolveServiceChainGroup(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("fw")) || nodeType.equals(new NodeType("lb")) || nodeType.equals(new NodeType("cache")) ) { resolveServiceFunction(user, node, virtualNetwork, userIntentVnMapping); return; } throw new IntentResolutionException("Unknown node type."); } NodeMapper(DataBroker dataBroker); }
NodeMapper { protected void resolveNode(User user, Node node, VirtualNetwork virtualNetwork, UserIntentVnMapping userIntentVnMapping) throws IntentResolutionException { NodeType nodeType = node.getNodeType(); if ( nodeType.equals(new NodeType("host")) ) { resolveHost(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType(("l2-group"))) ) { resolveLayer2Group(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("l3-group")) ) { resolveLayer3Group(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("ext-group")) ) { if ( IntentResolverUtils.checkExternalLayer3Group(node) ) { resolveExternalLayer3Group(user, node, virtualNetwork, userIntentVnMapping); } return; } if ( nodeType.equals(new NodeType("chain-group")) ) { resolveServiceChainGroup(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("fw")) || nodeType.equals(new NodeType("lb")) || nodeType.equals(new NodeType("cache")) ) { resolveServiceFunction(user, node, virtualNetwork, userIntentVnMapping); return; } throw new IntentResolutionException("Unknown node type."); } NodeMapper(DataBroker dataBroker);  }
NodeMapper { protected void resolveNode(User user, Node node, VirtualNetwork virtualNetwork, UserIntentVnMapping userIntentVnMapping) throws IntentResolutionException { NodeType nodeType = node.getNodeType(); if ( nodeType.equals(new NodeType("host")) ) { resolveHost(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType(("l2-group"))) ) { resolveLayer2Group(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("l3-group")) ) { resolveLayer3Group(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("ext-group")) ) { if ( IntentResolverUtils.checkExternalLayer3Group(node) ) { resolveExternalLayer3Group(user, node, virtualNetwork, userIntentVnMapping); } return; } if ( nodeType.equals(new NodeType("chain-group")) ) { resolveServiceChainGroup(user, node, virtualNetwork, userIntentVnMapping); return; } if ( nodeType.equals(new NodeType("fw")) || nodeType.equals(new NodeType("lb")) || nodeType.equals(new NodeType("cache")) ) { resolveServiceFunction(user, node, virtualNetwork, userIntentVnMapping); return; } throw new IntentResolutionException("Unknown node type."); } NodeMapper(DataBroker dataBroker);   }