@Test public void testGetSourceVirtualRouterOfFlow() throws Exception { List<VirtualNode> virtualNodes = new ArrayList<VirtualNode>(); VirtualNode virtualNode = mock(VirtualNode.class); Flow flow = mock(Flow.class); NodeId nodeId = mock(NodeId.class); Node node = mock(Node.class); Property property = mock(Property.class); VirtualResource virtualResource = mock(VirtualResource.class); PropertyValues propertyValues_temp = mock(PropertyValues.class); MatchItem matchItem = mock(MatchItem.class); StringValue stringValue = mock(StringValue.class); MatchItemValue matchItemValue = mock(MatchItemValue.class); IntentVnMappingResult intentVnMappingResult = mock(IntentVnMappingResult.class); VirtualResourceEntityId virtualResourceEntityId = mock(VirtualResourceEntityId.class); List<Property> propertyList = new ArrayList<Property>(); List<Node> nodes = new ArrayList<Node>(); List<IntentVnMappingResult> intentVnMappingResults = new ArrayList<IntentVnMappingResult>(); List<MatchItem> matchItems = new ArrayList<MatchItem>(); List<StringValue> propertyValues = new ArrayList<StringValue>(); List<VirtualResource> virtualResourceList = new ArrayList<VirtualResource>(); matchItems.add(matchItem); intentVnMappingResults.add(intentVnMappingResult); nodes.add(node); virtualNodes.add(virtualNode); propertyValues.add(stringValue); virtualResourceList.add(virtualResource); propertyList.add(property); when(flow.getMatchItem()).thenReturn(matchItems); when(matchItem.getMatchItemName()) .thenReturn(mock(MatchItemName.class)) .thenReturn(new MatchItemName("src-ip")); Assert.assertTrue(ActionResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults) == null); when(matchItem.getMatchItemValue()).thenReturn(matchItemValue); when(matchItemValue.getStringValue()).thenReturn(new String("test")); when(node.getNodeType()).thenReturn(new NodeType("l2-group")); when(node.getProperty()).thenReturn(propertyList); when(property.getPropertyName()).thenReturn(new PropertyName("ip-prefix")); when(property.getPropertyValues()).thenReturn(propertyValues_temp); when(propertyValues_temp.getStringValue()).thenReturn(propertyValues); when(stringValue.getValue()).thenReturn(new String("test")); when(node.getNodeId()).thenReturn(nodeId); when(nodeId.getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222")); when(intentVnMappingResult.getIntentId()).thenReturn(new IntentId(new String("00001111-0000-0000-0000-000011112222"))); when(intentVnMappingResult.getVirtualResource()).thenReturn(virtualResourceList); when(virtualResource.getVirtualResourceType()).thenReturn(VirtualResource.VirtualResourceType.Vport); when(virtualResource.getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId); when(virtualResourceEntityId.getValue()).thenReturn(new String("00001111-1111-0000-0000-000011112222")); when(virtualNode.getNodeId()).thenReturn(new VirtualNodeId(new String("00001111-1111-0000-0000-000011112222"))); when(virtualNode.getNodeType()).thenReturn(VirtualNode.NodeType.Vrouter); Assert.assertTrue(ActionResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults) != null); }
protected static VirtualNode getSourceVirtualRouterOfFlow(List<VirtualNode> virtualNodes, Flow flow, List<Node> nodes, List<IntentVnMappingResult> intentVnMappingResults) { MatchItemName matchItemName = new MatchItemName("src-ip"); MatchItem matchItem = getMatchItem(flow.getMatchItem(), matchItemName); if ( null == matchItem ) { return null; } String matchItemValue = matchItem.getMatchItemValue().getStringValue(); VirtualNode virtualNode = getVirtualRouterWithIpPrefix(virtualNodes, matchItemValue, nodes, intentVnMappingResults); return virtualNode; }
ActionResolverUtils { protected static VirtualNode getSourceVirtualRouterOfFlow(List<VirtualNode> virtualNodes, Flow flow, List<Node> nodes, List<IntentVnMappingResult> intentVnMappingResults) { MatchItemName matchItemName = new MatchItemName("src-ip"); MatchItem matchItem = getMatchItem(flow.getMatchItem(), matchItemName); if ( null == matchItem ) { return null; } String matchItemValue = matchItem.getMatchItemValue().getStringValue(); VirtualNode virtualNode = getVirtualRouterWithIpPrefix(virtualNodes, matchItemValue, nodes, intentVnMappingResults); return virtualNode; } }
ActionResolverUtils { protected static VirtualNode getSourceVirtualRouterOfFlow(List<VirtualNode> virtualNodes, Flow flow, List<Node> nodes, List<IntentVnMappingResult> intentVnMappingResults) { MatchItemName matchItemName = new MatchItemName("src-ip"); MatchItem matchItem = getMatchItem(flow.getMatchItem(), matchItemName); if ( null == matchItem ) { return null; } String matchItemValue = matchItem.getMatchItemValue().getStringValue(); VirtualNode virtualNode = getVirtualRouterWithIpPrefix(virtualNodes, matchItemValue, nodes, intentVnMappingResults); return virtualNode; }  }
ActionResolverUtils { protected static VirtualNode getSourceVirtualRouterOfFlow(List<VirtualNode> virtualNodes, Flow flow, List<Node> nodes, List<IntentVnMappingResult> intentVnMappingResults) { MatchItemName matchItemName = new MatchItemName("src-ip"); MatchItem matchItem = getMatchItem(flow.getMatchItem(), matchItemName); if ( null == matchItem ) { return null; } String matchItemValue = matchItem.getMatchItemValue().getStringValue(); VirtualNode virtualNode = getVirtualRouterWithIpPrefix(virtualNodes, matchItemValue, nodes, intentVnMappingResults); return virtualNode; }   }
ActionResolverUtils { protected static VirtualNode getSourceVirtualRouterOfFlow(List<VirtualNode> virtualNodes, Flow flow, List<Node> nodes, List<IntentVnMappingResult> intentVnMappingResults) { MatchItemName matchItemName = new MatchItemName("src-ip"); MatchItem matchItem = getMatchItem(flow.getMatchItem(), matchItemName); if ( null == matchItem ) { return null; } String matchItemValue = matchItem.getMatchItemValue().getStringValue(); VirtualNode virtualNode = getVirtualRouterWithIpPrefix(virtualNodes, matchItemValue, nodes, intentVnMappingResults); return virtualNode; }    }