@Test public void testResolveNode4() throws Exception { User user = mock(User.class); Node node = mock(Node.class); VirtualNetwork virtualNetwork = mock(VirtualNetwork.class); UserIntentVnMapping userIntentVnMapping = mock(UserIntentVnMapping.class); SubNode subNode = mock(SubNode.class); SubNode subNode1 = mock(SubNode.class); NodeId nodeId = mock(NodeId.class); Objects objects = mock(Objects.class); IntentVnMappingResult intentVnMappingResult = mock(IntentVnMappingResult.class); IntentVnMappingResult intentVnMappingResult_elseif = mock(IntentVnMappingResult.class); VirtualResource virtualResource = mock(VirtualResource.class); VirtualLink virtualLink = mock(VirtualLink.class); VirtualNode virtualNode = mock(VirtualNode.class); VirtualNodes virtualNodes_temp = mock(VirtualNodes.class); VirtualPaths virtualPaths_temp = mock(VirtualPaths.class); VirtualLinks virtualLinks_temp = mock(VirtualLinks.class); VirtualResourceEntityId virtualResourceEntityId = mock(VirtualResourceEntityId.class); List<Node> nodes = new ArrayList<Node>(); List<SubNode> subNodes = new ArrayList<SubNode>(); List<IntentVnMappingResult> intentVnMappingResults = new ArrayList<IntentVnMappingResult>(); List<VirtualResource> virtualResourceList = new ArrayList<VirtualResource>(); List<VirtualNode> virtualNodes = new ArrayList<VirtualNode>(); List<VirtualLink> virtualLinks = new ArrayList<VirtualLink>(); List<VirtualPath> virtualPaths = new ArrayList<VirtualPath>(); List<VirtualPort> virtualPortList = new ArrayList<VirtualPort>(); virtualResourceList.add(virtualResource); when(node.getNodeType()).thenReturn(new NodeType("chain-group")); when(node.getSubNode()).thenReturn(subNodes); when(node.getNodeId()).thenReturn(nodeId); Assert.assertTrue(subNodes.isEmpty()); nodeMapper.resolveNode(user, node, virtualNetwork, userIntentVnMapping); subNodes.add(subNode); when(userIntentVnMapping.getIntentVnMappingResult()).thenReturn(intentVnMappingResults); when(subNode.getNodeId()).thenReturn(nodeId); when(subNode1.getNodeId()).thenReturn(nodeId); when(nodeId.getValue()).thenReturn("00001111-0000-0000-0000-000011112222"); PowerMockito.mockStatic(IntentResolverUtils.class); PowerMockito.when(IntentResolverUtils.getIntentVnMappingResult(intentVnMappingResults, new IntentId(subNode.getNodeId().getValue()))) .thenReturn(intentVnMappingResult); when(intentVnMappingResult.getVirtualResource()).thenReturn(virtualResourceList); nodeMapper.resolveNode(user, node, virtualNetwork, userIntentVnMapping); verify(node).getNodeId(); subNodes.add(subNode1); PowerMockito.when(IntentResolverUtils.sortSubNodes(subNodes)).thenReturn(subNodes); when(user.getObjects()).thenReturn(objects); when(objects.getNode()).thenReturn(nodes); PowerMockito.when(IntentResolverUtils.checkAllLayer2OperatingMode(subNodes, nodes)) .thenReturn(true) .thenReturn(false); PowerMockito.when(IntentResolverUtils.checkAllLayer3OperatingMode(subNodes, nodes)) .thenReturn(false) .thenReturn(true); nodeMapper.resolveNode(user, node, virtualNetwork, userIntentVnMapping); nodeMapper.resolveNode(user, node, virtualNetwork, userIntentVnMapping); verify(node, times(3)).getNodeId(); when(virtualNetwork.getVirtualNodes()).thenReturn(virtualNodes_temp); when(virtualNodes_temp.getVirtualNode()).thenReturn(virtualNodes); when(virtualNetwork.getVirtualLinks()).thenReturn(virtualLinks_temp); when(virtualLinks_temp.getVirtualLink()).thenReturn(virtualLinks); when(virtualNetwork.getVirtualPaths()).thenReturn(virtualPaths_temp); when(virtualPaths_temp.getVirtualPath()).thenReturn(virtualPaths); PowerMockito.when(IntentResolverUtils.getIntentVnMappingResult(intentVnMappingResults, new IntentId(subNode1.getNodeId().getValue()))) .thenReturn(intentVnMappingResult); when(virtualResource.getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId); when(virtualResourceEntityId.getValue()).thenReturn(new String("00001111-1111-0000-0000-000011112222")); PowerMockito.when(IntentResolverUtils.getVirtualLink(any(List.class), any(VirtualNodeId.class), any(VirtualNodeId.class))) .thenReturn(null); PowerMockito.when(IntentResolverUtils.getVirtualNode(any(List.class), any(VirtualNodeId.class))) .thenReturn(virtualNode); when(virtualNode.getVirtualPort()).thenReturn(virtualPortList); nodeMapper.resolveNode(user, node, virtualNetwork, userIntentVnMapping); }
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);   }