modified some test files in file "User" and added one test file 85/30285/1
authorsaomenmen <zhangmroy@163.com>
Fri, 27 Nov 2015 09:37:49 +0000 (17:37 +0800)
committersaomenmen <zhangmroy@163.com>
Fri, 27 Nov 2015 09:42:45 +0000 (17:42 +0800)
Change-Id: Ic7933060781ccb10344eca809b29e73cdd9329a5
Signed-off-by: saomenmen <zhangmroy@163.com>
nemo-impl/src/test/java/org/opendaylight/nemo/intent/IntentResolverUtilsTest.java [new file with mode: 0644]
nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/instancecheck/ConnectionInstanceCheckTest.java
nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/instancecheck/FlowInstanceCheckTest.java
nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/instancecheck/NodeInstanceCheckTest.java
nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/instancecheck/OperationInstanceCheckTest.java

diff --git a/nemo-impl/src/test/java/org/opendaylight/nemo/intent/IntentResolverUtilsTest.java b/nemo-impl/src/test/java/org/opendaylight/nemo/intent/IntentResolverUtilsTest.java
new file mode 100644 (file)
index 0000000..c8e977e
--- /dev/null
@@ -0,0 +1,756 @@
+package org.opendaylight.nemo.intent;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.nemo.intent.IntentResolverUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.VirtualResourceEntityId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.VirtualResourceInstance.VirtualResourceType;
+import static org.junit.Assert.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.network.physical.hosts.PhysicalHost;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.links.VirtualLink;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.networks.virtual.network.virtual.nodes.VirtualNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.user.intent.vn.mapping.IntentVnMappingResult;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.intent.mapping.result.rev151010.intent.vn.mapping.results.user.intent.vn.mapping.intent.vn.mapping.result.VirtualResource;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalHostId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.PhysicalNodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.engine.common.rev151010.VirtualNodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Connection;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.Operation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.flow.instance.MatchItem;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.node.instance.Property;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.node.instance.SubNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.property.instance.property.values.StringValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.operation.instance.Action;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.match.item.instance.MatchItemValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.property.instance.PropertyValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.NodeId;
+//import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.connection.instance.Property;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import static org.mockito.Mockito.*;
+
+/**
+ * Created by zhangmeng on 2015/11/26.
+ */
+public class IntentResolverUtilsTest extends IntentResolverUtils {
+
+    @Before
+    public void setUp() throws Exception {
+
+    }
+
+    @Test
+    public void testCheckExternalLayer3Group() throws Exception {
+        Node node = mock(Node.class);
+        List<Property> properties = new LinkedList<Property>();
+        Property property = mock(Property.class);
+        properties.add(property);
+
+        when(node.getProperty()).thenReturn(null);//avoid testing method "getNodeProperty"
+        IntentResolverUtils.checkExternalLayer3Group(node);
+        verify(node).getProperty();
+
+        //test method "getNodeProperty". and method "CheckExternalLayer3Group"`s another branch
+//        when(node.getProperty()).thenReturn(properties);
+//        when(property.getPropertyName()).thenReturn(new PropertyName("ac-info-network"));
+
+        /* anther branch can`t be tested. The reason is that I cannot known the method property.getPropertyValues() returns what object.
+           So I cant`t mock the needed object
+        */
+    }
+
+    @Test
+    public void testGetPhysicalHost() throws Exception {
+        List<PhysicalHost> physicalHosts = new LinkedList<PhysicalHost>();
+        Node node =  mock(Node.class);
+        NodeId nodeId = mock(NodeId.class);
+
+        when(node.getNodeId()).thenReturn(nodeId);
+        when(nodeId.getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222"));
+
+        // test private method "getPhysicalHost"
+        PhysicalHost physicalHost = mock(PhysicalHost.class);
+        physicalHosts.add(physicalHost);
+        when(physicalHost.getHostId())
+                .thenReturn(new PhysicalHostId("00001111-0000-0000-0000-000011112222"))
+                .thenReturn(new PhysicalHostId("00001111-0000-0000-0000-000011112221"));
+
+        IntentResolverUtils.getPhysicalHost(physicalHosts, node);
+        IntentResolverUtils.getPhysicalHost(physicalHosts,node);
+        verify(node,times(2)).getNodeId();
+        verify(nodeId,times(2)).getValue();
+        verify(physicalHost,times(2)).getHostId();
+    }
+
+    @Test
+    public void testGetNodeProperty() throws Exception {
+        List<Property> properties = new LinkedList<Property>();
+        PropertyName propertyName = new PropertyName("test");
+        Property property = mock(Property.class);
+        properties.add(property);
+
+        when(property.getPropertyName()).thenReturn(propertyName);
+        IntentResolverUtils.getNodeProperty(properties, propertyName);
+        verify(property).getPropertyName();
+
+        IntentResolverUtils.getNodeProperty(null, propertyName);
+    }
+
+    @Test
+    public void testGeneratePhysicalNodeIdFromNodeLocationProperty() throws Exception {
+        //method can`t be tested because of "String propertyValue = property.getPropertyValues().getStringValue().get(0).getValue();"
+
+    }
+
+    @Test
+    public void testGetIntentVnMappingResult() throws Exception {
+        List<IntentVnMappingResult> intentVnMappingResults =  new LinkedList<IntentVnMappingResult>();
+        IntentId intentId = mock(IntentId.class);
+        IntentVnMappingResult intentVnMappingResult = mock(IntentVnMappingResult.class);
+        intentVnMappingResults.add(intentVnMappingResult);
+
+        when(intentVnMappingResult.getIntentId())
+                .thenReturn(intentId)
+                .thenReturn(new IntentId("00001111-0000-0000-0000-000011112222"));
+
+        IntentResolverUtils.getIntentVnMappingResult(intentVnMappingResults, intentId);
+        IntentResolverUtils.getIntentVnMappingResult(intentVnMappingResults, intentId);
+        verify(intentVnMappingResult,times(2)).getIntentId();
+    }
+
+    @Test
+    public void testGetVirtualNode() throws Exception {
+        List<VirtualNode> virtualNodes =  new LinkedList<VirtualNode>();
+        VirtualNodeId virtualNodeId = mock(VirtualNodeId.class);
+        VirtualNode virtualNode = mock(VirtualNode.class);
+        virtualNodes.add(virtualNode);
+
+        when(virtualNode.getNodeId())
+                .thenReturn(virtualNodeId)
+                .thenReturn(new VirtualNodeId("00001111-0000-0000-0000-000011112222"));
+
+        IntentResolverUtils.getVirtualNode(virtualNodes, virtualNodeId);
+        IntentResolverUtils.getVirtualNode(virtualNodes, virtualNodeId);
+        verify(virtualNode,times(2)).getNodeId();
+    }
+
+    @Test
+    public void testGetNode() throws Exception {
+        List<Node> nodes = new LinkedList<Node>();
+        NodeId nodeId = mock(NodeId.class);
+        Node node = mock(Node.class);
+        nodes.add(node);
+
+        when(node.getNodeId())
+                .thenReturn(nodeId)
+                .thenReturn(new NodeId("00001111-0000-0000-0000-000011112222"));
+
+        IntentResolverUtils.getNode(nodes, nodeId);
+        IntentResolverUtils.getNode(nodes, nodeId);
+        verify(node,times(2)).getNodeId();
+    }
+
+    @Test
+    public void testGetConnectionProperty() throws Exception {
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.connection.instance.Property>
+                properties = new LinkedList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.connection.instance.Property>();
+        PropertyName propertyName = mock(PropertyName.class);
+        org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.connection.instance.Property
+                property = mock(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.object.rev151010.connection.instance.Property.class);
+        properties.add(property);
+
+        when(property.getPropertyName()).thenReturn(propertyName);
+
+        IntentResolverUtils.getConnectionProperty(properties, propertyName);
+        verify(property).getPropertyName();
+
+        IntentResolverUtils.getConnectionProperty(null,propertyName);
+    }
+
+    @Test
+    public void testSortSubNodes() throws Exception {
+        List<SubNode> subNodes = new LinkedList<SubNode>();
+        SubNode subNode = mock(SubNode.class);
+        SubNode subNode1 = mock(SubNode.class);
+        long first = 0;
+        long second = 1;
+
+        //test empty
+        Assert.assertTrue(subNodes.size() == 0);
+        IntentResolverUtils.sortSubNodes(subNodes);
+        //test size = 1;
+        subNodes.add(subNode);
+        Assert.assertTrue(subNodes.size() == 1);
+        IntentResolverUtils.sortSubNodes(subNodes);
+        //test size > 1
+        subNodes.add(subNode1);
+        when(subNode.getOrder()).thenReturn(first);
+        when(subNode1.getOrder()).thenReturn(second);
+
+    }
+
+    @Test
+    public void testCheckAllLayer2OperatingMode() throws Exception {
+        List<SubNode> subNodes = new LinkedList<SubNode>();
+        List<Node> nodes = new LinkedList<Node>();
+        List<Property> properties = new LinkedList<Property>();
+        //List<StringValue> stringValues = new LinkedList<StringValue>();
+        List<StringValue> stringValues = mock(List.class);
+        Property property = mock(Property.class);
+        NodeId nodeId = mock(NodeId.class);
+        Node node = mock(Node.class);
+        SubNode subNode = mock(SubNode.class);
+        PropertyName propertyName = mock(PropertyName.class);
+        PropertyValues propertyValues = mock(PropertyValues.class);
+        StringValue stringValue = mock(StringValue.class);
+
+        //test empty
+        Assert.assertTrue(subNodes.size() == 0);
+        Assert.assertFalse(IntentResolverUtils.checkAllLayer2OperatingMode(subNodes, nodes));
+
+        //test not empty
+        subNodes.add(subNode);
+        nodes.add(node);
+        properties.add(property);
+        //stringValues.add(stringValue);
+        when(subNode.getNodeId()).thenReturn(nodeId);
+        when(node.getNodeId())
+                .thenReturn(new NodeId("00001111-0000-0000-0000-000011112222"))
+                .thenReturn(nodeId)
+                .thenReturn(nodeId)
+                .thenReturn(nodeId);
+        Assert.assertFalse(IntentResolverUtils.checkAllLayer2OperatingMode(subNodes, nodes));
+        when(node.getProperty()).thenReturn(properties);
+        when(property.getPropertyName())
+                .thenReturn(propertyName)
+                .thenReturn(new PropertyName("operating-mode"))
+                .thenReturn(new PropertyName("operating-mode"));
+        Assert.assertFalse(IntentResolverUtils.checkAllLayer2OperatingMode(subNodes, nodes));
+        when(property.getPropertyValues()).thenReturn(propertyValues);
+        when(propertyValues.getStringValue()).thenReturn(stringValues);
+        when(stringValues.get(anyInt())).thenReturn(stringValue);
+        when(stringValue.getValue())
+                .thenReturn(new String("layer2"))
+                .thenReturn(new String("test"));
+
+        Assert.assertTrue(IntentResolverUtils.checkAllLayer2OperatingMode(subNodes, nodes));
+        Assert.assertFalse(IntentResolverUtils.checkAllLayer2OperatingMode(subNodes, nodes));
+
+        verify(subNode,times(4)).getNodeId();
+        verify(node,times(4)).getNodeId();
+        verify(node,times(3)).getProperty();
+        verify(property,times(3)).getPropertyName();
+        verify(property, times(2)).getPropertyValues();
+        verify(propertyValues,times(2)).getStringValue();
+        verify(stringValues,times(2)).get(anyInt());
+        verify(stringValue,times(2)).getValue();
+
+    }
+
+    @Test
+    public void testCheckAllLayer3OperatingMode() throws Exception {
+        List<SubNode> subNodes = new LinkedList<SubNode>();
+        List<Node> nodes = new LinkedList<Node>();
+        List<Property> properties = new LinkedList<Property>();
+        //List<StringValue> stringValues = new LinkedList<StringValue>();
+        List<StringValue> stringValues = mock(List.class);
+        Property property = mock(Property.class);
+        NodeId nodeId = mock(NodeId.class);
+        Node node = mock(Node.class);
+        SubNode subNode = mock(SubNode.class);
+        PropertyName propertyName = mock(PropertyName.class);
+        PropertyValues propertyValues = mock(PropertyValues.class);
+        StringValue stringValue = mock(StringValue.class);
+
+        //test empty
+        Assert.assertTrue(subNodes.size() == 0);
+        Assert.assertFalse(IntentResolverUtils.checkAllLayer3OperatingMode(subNodes, nodes));
+
+        //test not empty
+        subNodes.add(subNode);
+        nodes.add(node);
+        properties.add(property);
+        //stringValues.add(stringValue);
+        when(subNode.getNodeId()).thenReturn(nodeId);
+        when(node.getNodeId())
+                .thenReturn(new NodeId("00001111-0000-0000-0000-000011112222"))
+                .thenReturn(nodeId)
+                .thenReturn(nodeId)
+                .thenReturn(nodeId);
+        Assert.assertFalse(IntentResolverUtils.checkAllLayer3OperatingMode(subNodes, nodes));
+        when(node.getProperty()).thenReturn(properties);
+        when(property.getPropertyName())
+                .thenReturn(propertyName)
+                .thenReturn(new PropertyName("operating-mode"))
+                .thenReturn(new PropertyName("operating-mode"));
+        Assert.assertFalse(IntentResolverUtils.checkAllLayer3OperatingMode(subNodes, nodes));
+        when(property.getPropertyValues()).thenReturn(propertyValues);
+        when(propertyValues.getStringValue()).thenReturn(stringValues);
+        when(stringValues.get(anyInt())).thenReturn(stringValue);
+        when(stringValue.getValue())
+                .thenReturn(new String("layer3"))
+                .thenReturn(new String("test"));
+
+        Assert.assertTrue(IntentResolverUtils.checkAllLayer3OperatingMode(subNodes, nodes));
+        Assert.assertFalse(IntentResolverUtils.checkAllLayer3OperatingMode(subNodes, nodes));
+
+        verify(subNode,times(4)).getNodeId();
+        verify(node,times(4)).getNodeId();
+        verify(node,times(3)).getProperty();
+        verify(property,times(3)).getPropertyName();
+        verify(property, times(2)).getPropertyValues();
+        verify(propertyValues,times(2)).getStringValue();
+        verify(stringValues,times(2)).get(anyInt());
+        verify(stringValue,times(2)).getValue();
+    }
+
+    @Test
+    public void testGetVirtualLink() throws Exception {
+        List<VirtualLink> virtualLinks = new LinkedList<VirtualLink>();
+        VirtualNodeId srcVirtualNodeId = mock(VirtualNodeId.class);
+        VirtualNodeId destVirtualNodeId = mock(VirtualNodeId.class);
+        VirtualLink virtualLink = mock(VirtualLink.class);
+        VirtualLink virtualLink_test ;
+        virtualLinks.add(virtualLink);
+        //test not null and null
+        when(virtualLink.getSrcNodeId())
+                .thenReturn(srcVirtualNodeId)
+                .thenReturn(new VirtualNodeId("00001111-0000-0000-0000-000011112222"));
+        when(virtualLink.getDestNodeId())
+                .thenReturn(destVirtualNodeId)
+                .thenReturn(new VirtualNodeId("00001111-0000-0000-0000-000011112222"));
+        virtualLink_test = IntentResolverUtils.getVirtualLink(virtualLinks, srcVirtualNodeId, destVirtualNodeId);
+        Assert.assertTrue(virtualLink_test != null);
+        virtualLink_test = IntentResolverUtils.getVirtualLink(virtualLinks,srcVirtualNodeId,destVirtualNodeId);
+        Assert.assertTrue(virtualLink_test == null);
+        verify(virtualLink,times(2)).getSrcNodeId();
+        verify(virtualLink).getDestNodeId();
+
+    }
+
+    @Test
+    public void testGetObject() throws Exception {
+        DataObject dataObject ;
+        Objects objects = mock(Objects.class);
+        ObjectId objectId = mock(ObjectId.class);
+        Node node = mock(Node.class);
+        Connection connection = mock(Connection.class);
+        Flow flow = mock(Flow.class);
+        List<Node> nodes = new LinkedList<Node>();
+        List<Connection> connections = new LinkedList<Connection>();
+        List<Flow> flows = new LinkedList<Flow>();
+
+        when(objects.getNode()).thenReturn(nodes);
+        when(objects.getConnection()).thenReturn(connections);
+        when(objects.getFlow()).thenReturn(flows);
+        when(objectId.getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222"));
+        // when nodes and connections and flows are all empty
+        dataObject = IntentResolverUtils.getObject(objects, objectId);
+        Assert.assertTrue(dataObject == null);
+        //test  flow
+        flows.add(flow);
+        when(flow.getFlowId())
+                .thenReturn(new FlowId(new String("00001111-0000-0000-0000-000011112222")))
+                .thenReturn(mock(FlowId.class));
+        //return true
+        dataObject = IntentResolverUtils.getObject(objects, objectId);
+        Assert.assertTrue(dataObject != null);
+        //return null
+        dataObject = IntentResolverUtils.getObject(objects, objectId);
+        Assert.assertTrue(dataObject == null);
+
+        //test connection
+        connections.add(connection);
+        when(connection.getConnectionId())
+                .thenReturn(new ConnectionId(new String("00001111-0000-0000-0000-000011112222")))
+                .thenReturn(mock(ConnectionId.class));
+        //return true
+        dataObject = IntentResolverUtils.getObject(objects, objectId);
+        Assert.assertTrue(dataObject != null);
+        //return null
+        dataObject = IntentResolverUtils.getObject(objects, objectId);
+        Assert.assertTrue(dataObject == null);
+
+        //test node
+        nodes.add(node);
+        when(node.getNodeId())
+                .thenReturn(new NodeId(new String("00001111-0000-0000-0000-000011112222")))
+                .thenReturn(mock(NodeId.class));
+        //return true
+        dataObject = IntentResolverUtils.getObject(objects, objectId);
+        Assert.assertTrue(dataObject != null);
+        //return null
+        dataObject = IntentResolverUtils.getObject(objects, objectId);
+        Assert.assertTrue(dataObject == null);
+
+    }
+
+    @Test
+    public void testGetSameTargetObjectOperations() throws Exception {
+        List<Operation> operations = new LinkedList<Operation>();
+        Operation operation = mock(Operation.class);
+
+        List<Operation> list ;
+        list = IntentResolverUtils.getSameTargetObjectOperations(operations,operation);
+        Assert.assertTrue(list.size() == 0);
+    }
+
+    @Test
+    public void testGetGreaterAndEqualPriorityOperations() throws Exception {
+        List<Operation> operations = new LinkedList<Operation>();
+        Operation operation = mock(Operation.class);
+        List<Operation> greaterPriorityOperations = new LinkedList<Operation>();
+        List<Operation> equalPriorityOperations = new LinkedList<Operation>();
+
+        IntentResolverUtils.getGreaterAndEqualPriorityOperations(operations,operation,greaterPriorityOperations,equalPriorityOperations);
+    }
+
+    @Test
+    public void testGetConflictingOperation() throws Exception {
+        List<Operation> operations = new LinkedList<Operation>();
+        Operation operation = mock(Operation.class);
+
+        Operation operation1 = IntentResolverUtils.getConflictingOperation(operations,operation);
+        Assert.assertTrue(operation1 == null);
+    }
+
+    @Test
+    public void testGetConflictingOperations() throws Exception {
+        List<Operation> operations = new LinkedList<Operation>();
+        Operation operation = mock(Operation.class);
+
+        List<Operation> operations1 = IntentResolverUtils.getConflictingOperations(operations, operation);
+        Assert.assertTrue(operations1 == null);
+    }
+
+    @Test
+    public void testGetAction() throws Exception {
+        List<Action> actions = new LinkedList<Action>();
+        ActionName actionName = mock(ActionName.class);
+        Action action = mock(Action.class);
+        Action action_test ;
+
+        actions.add(action);
+        when(action.getActionName())
+                .thenReturn(actionName)
+                .thenReturn(new ActionName("a"));
+        action_test = IntentResolverUtils.getAction(actions,actionName);
+        Assert.assertTrue(action_test != null);
+        action_test = IntentResolverUtils.getAction(actions,actionName);
+        Assert.assertTrue(action_test == null);
+        verify(action,times(2)).getActionName();
+    }
+
+    @Test
+    public void testGetSourceVirtualRouterOfFlow() throws Exception {
+        VirtualNode virtualNode_test;
+        VirtualNode virtualNode = mock(VirtualNode.class);
+        Flow flow = mock(Flow.class);
+        MatchItemName matchItemName = mock(MatchItemName.class);
+        MatchItem matchItem = mock(MatchItem.class);
+        MatchItemValue matchItemValue = mock(MatchItemValue.class);
+        Node node = mock(Node.class);
+        IntentVnMappingResult intentVnMappingResult = mock(IntentVnMappingResult.class);
+        List<VirtualNode> virtualNodes = new ArrayList<VirtualNode>();
+        List<MatchItem> matchItems = new ArrayList<MatchItem>();
+        List<Node> nodes = new ArrayList<Node>();
+        List<IntentVnMappingResult> intentVnMappingResults = new ArrayList<IntentVnMappingResult>();
+
+        virtualNodes.add(virtualNode);
+        nodes.add(node);
+        intentVnMappingResults.add(intentVnMappingResult);
+        //test private method "getMatchItem"
+        when(flow.getMatchItem())
+                .thenReturn(null) //test null
+                .thenReturn(matchItems) //not null since this time
+                .thenReturn(matchItems);
+
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes,flow,nodes,intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        matchItems.add(matchItem);
+        when(matchItem.getMatchItemName())
+                .thenReturn(matchItemName)//not same as matchItemName , the value to be return is null
+                .thenReturn(new MatchItemName("src-ip"));//same as matchItemName, value to be return is not null
+
+        when(matchItem.getMatchItemValue()).thenReturn(matchItemValue);
+        when(matchItemValue.getStringValue()).thenReturn(new String("test"));
+
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes,flow,nodes,intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        ///////////////////////////////////////////////////////
+        //test private method "getVirtualRouterWithIpPrefix"
+        //test null
+        nodes.clear();
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes,flow,nodes,intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        //test not null
+        NodeType layer2GroupNodeType = new NodeType("l2-group");
+        NodeType externalGroupNodeType = new NodeType("ext-group");
+        org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.VirtualNodeInstance.NodeType VrouterNodeType =
+                VirtualNode.NodeType.Vrouter;
+        NodeId nodeId = mock(NodeId.class);
+        IntentId intentId = new IntentId(new String("00001111-0000-0000-0000-000011112222"));
+        List<Property> properties = new ArrayList<Property>();
+        List<StringValue> propertyValues_list = new ArrayList<StringValue>();
+        List<VirtualResource> virtualResources = new ArrayList<VirtualResource>();
+        StringValue stringValue = mock(StringValue.class);
+        Property property = mock(Property.class);
+        PropertyName propertyName = new PropertyName("ip-prefix");
+        PropertyValues propertyValues = mock(PropertyValues.class);
+        VirtualResource virtualResource = mock(VirtualResource.class);
+        VirtualResourceType virtualResourceType_Vport = VirtualResource.VirtualResourceType.Vport;
+        VirtualResourceType virtualResourceType_Vnode = VirtualResource.VirtualResourceType.Vnode;
+        VirtualResourceType virtualResourceType_Other = null;
+        VirtualResourceEntityId virtualResourceEntityId = mock(VirtualResourceEntityId.class);
+
+        virtualResources.add(virtualResource);
+        nodes.add(node);
+        properties.add(property);
+        propertyValues_list.add(stringValue);
+
+        when(node.getNodeType())
+                .thenReturn(mock(NodeType.class))
+                .thenReturn(layer2GroupNodeType)
+                .thenReturn(externalGroupNodeType);
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes, flow, nodes,intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+
+        when(node.getProperty()).thenReturn(properties);
+        when(property.getPropertyName())
+                .thenReturn(mock(PropertyName.class))
+                .thenReturn(propertyName);
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes,flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        when(property.getPropertyValues()).thenReturn(propertyValues);
+        when(propertyValues.getStringValue()).thenReturn(propertyValues_list);
+        when(stringValue.getValue())
+                .thenReturn(new String("test1"))
+                .thenReturn(new String("test"));
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+        verify(stringValue).getValue();
+
+        when(node.getNodeId()).thenReturn(nodeId);
+        when(nodeId.getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222"));
+        when(intentVnMappingResult.getIntentId())
+                .thenReturn(mock(IntentId.class))
+                .thenReturn(intentId);
+
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes,flow,nodes,intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        when(intentVnMappingResult.getVirtualResource()).thenReturn(virtualResources);
+        Assert.assertTrue(virtualResources.get(0) == virtualResource);
+        when(virtualResource.getVirtualResourceType())
+                .thenReturn(virtualResourceType_Other)
+                .thenReturn(virtualResourceType_Vport)
+                .thenReturn(virtualResourceType_Vnode);
+        when(virtualResource.getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);
+        when(virtualResource.getVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);
+        when(virtualResourceEntityId.getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222"));
+
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes,flow,nodes,intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        when(virtualNode.getNodeId())
+                .thenReturn(mock(VirtualNodeId.class))
+                .thenReturn(new VirtualNodeId(new String("00001111-0000-0000-0000-000011112222")));
+
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes,flow,nodes,intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+        verify(virtualNode).getNodeId();
+
+        when(virtualNode.getNodeType())
+                .thenReturn(null)
+                .thenReturn(VrouterNodeType);
+
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes,flow,nodes,intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+        verify(virtualNode).getNodeType();
+
+        virtualNode_test = IntentResolverUtils.getSourceVirtualRouterOfFlow(virtualNodes,flow,nodes,intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == virtualNode);
+        verify(virtualNode,times(2)).getNodeType();
+
+    }
+
+    @Test
+    public void testGetDestinationVirtualRouterOfFlow() throws Exception {
+        VirtualNode virtualNode_test;
+        VirtualNode virtualNode = mock(VirtualNode.class);
+        Flow flow = mock(Flow.class);
+        MatchItemName matchItemName = mock(MatchItemName.class);
+        MatchItem matchItem = mock(MatchItem.class);
+        MatchItemValue matchItemValue = mock(MatchItemValue.class);
+        Node node = mock(Node.class);
+        IntentVnMappingResult intentVnMappingResult = mock(IntentVnMappingResult.class);
+        List<VirtualNode> virtualNodes = new ArrayList<VirtualNode>();
+        List<MatchItem> matchItems = new ArrayList<MatchItem>();
+        List<Node> nodes = new ArrayList<Node>();
+        List<IntentVnMappingResult> intentVnMappingResults = new ArrayList<IntentVnMappingResult>();
+
+        virtualNodes.add(virtualNode);
+        nodes.add(node);
+        intentVnMappingResults.add(intentVnMappingResult);
+        //test private method "getMatchItem"
+        when(flow.getMatchItem())
+                .thenReturn(null) //test null
+                .thenReturn(matchItems) //not null since this time
+                .thenReturn(matchItems);
+
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        matchItems.add(matchItem);
+        when(matchItem.getMatchItemName())
+                .thenReturn(matchItemName)//not same as matchItemName , the value to be return is null
+                .thenReturn(new MatchItemName("dst-ip"));//same as matchItemName, value to be return is not null
+
+        when(matchItem.getMatchItemValue()).thenReturn(matchItemValue);
+        when(matchItemValue.getStringValue()).thenReturn(new String("test"));
+
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        ///////////////////////////////////////////////////////
+        //test private method "getVirtualRouterWithIpPrefix"
+        //test null
+        nodes.clear();
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        //test not null
+        NodeType layer2GroupNodeType = new NodeType("l2-group");
+        NodeType externalGroupNodeType = new NodeType("ext-group");
+        org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.VirtualNodeInstance.NodeType VrouterNodeType =
+                VirtualNode.NodeType.Vrouter;
+        NodeId nodeId = mock(NodeId.class);
+        IntentId intentId = new IntentId(new String("00001111-0000-0000-0000-000011112222"));
+        List<Property> properties = new ArrayList<Property>();
+        List<StringValue> propertyValues_list = new ArrayList<StringValue>();
+        List<VirtualResource> virtualResources = new ArrayList<VirtualResource>();
+        StringValue stringValue = mock(StringValue.class);
+        Property property = mock(Property.class);
+        PropertyName propertyName = new PropertyName("ip-prefix");
+        PropertyValues propertyValues = mock(PropertyValues.class);
+        VirtualResource virtualResource = mock(VirtualResource.class);
+        VirtualResourceType virtualResourceType_Vport = VirtualResource.VirtualResourceType.Vport;
+        VirtualResourceType virtualResourceType_Vnode = VirtualResource.VirtualResourceType.Vnode;
+        VirtualResourceType virtualResourceType_Other = null;
+        VirtualResourceEntityId virtualResourceEntityId = mock(VirtualResourceEntityId.class);
+
+        virtualResources.add(virtualResource);
+        nodes.add(node);
+        properties.add(property);
+        propertyValues_list.add(stringValue);
+
+        when(node.getNodeType())
+                .thenReturn(mock(NodeType.class))
+                .thenReturn(layer2GroupNodeType)
+                .thenReturn(externalGroupNodeType);
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+
+        when(node.getProperty()).thenReturn(properties);
+        when(property.getPropertyName())
+                .thenReturn(mock(PropertyName.class))
+                .thenReturn(propertyName);
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        when(property.getPropertyValues()).thenReturn(propertyValues);
+        when(propertyValues.getStringValue()).thenReturn(propertyValues_list);
+        when(stringValue.getValue())
+                .thenReturn(new String("test1"))
+                .thenReturn(new String("test"));
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+        verify(stringValue).getValue();
+
+        when(node.getNodeId()).thenReturn(nodeId);
+        when(nodeId.getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222"));
+        when(intentVnMappingResult.getIntentId())
+                .thenReturn(mock(IntentId.class))
+                .thenReturn(intentId);
+
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        when(intentVnMappingResult.getVirtualResource()).thenReturn(virtualResources);
+        Assert.assertTrue(virtualResources.get(0) == virtualResource);
+        when(virtualResource.getVirtualResourceType())
+                .thenReturn(virtualResourceType_Other)
+                .thenReturn(virtualResourceType_Vport)
+                .thenReturn(virtualResourceType_Vnode);
+        when(virtualResource.getParentVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);
+        when(virtualResource.getVirtualResourceEntityId()).thenReturn(virtualResourceEntityId);
+        when(virtualResourceEntityId.getValue()).thenReturn(new String("00001111-0000-0000-0000-000011112222"));
+
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+
+        when(virtualNode.getNodeId())
+                .thenReturn(mock(VirtualNodeId.class))
+                .thenReturn(new VirtualNodeId(new String("00001111-0000-0000-0000-000011112222")));
+
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+        verify(virtualNode).getNodeId();
+
+        when(virtualNode.getNodeType())
+                .thenReturn(null)
+                .thenReturn(VrouterNodeType);
+
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes, flow, nodes, intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == null);
+        verify(virtualNode).getNodeType();
+
+        virtualNode_test = IntentResolverUtils.getDestinationVirtualRouterOfFlow(virtualNodes,flow,nodes,intentVnMappingResults);
+        Assert.assertTrue(virtualNode_test == virtualNode);
+        verify(virtualNode,times(2)).getNodeType();
+    }
+
+    @Test
+    public void testSortVirtualResources() throws Exception {
+        List<VirtualResource> virtualResources = new ArrayList<VirtualResource>();
+        VirtualResource virtualResource = mock(VirtualResource.class);
+        VirtualResource virtualResource1 = mock(VirtualResource.class);
+        List<VirtualResource> result ;
+        long first = 0;
+        long second = 1;
+
+        //test empty
+        Assert.assertTrue(virtualResources.size() == 0);
+        result = IntentResolverUtils.sortVirtualResources(virtualResources);
+        Assert.assertTrue(result.size() == 0);
+
+        //test 1
+        virtualResources.add(virtualResource);
+        Assert.assertTrue(virtualResources.size() == 1);
+        result = IntentResolverUtils.sortVirtualResources(virtualResources);
+        Assert.assertNotNull(result);
+
+        //test >1
+        virtualResources.add(virtualResource1);
+        Assert.assertTrue(virtualResources.size() == 2);
+        when(virtualResource.getOrder()).thenReturn(first);
+        when(virtualResource1.getOrder()).thenReturn(second);
+        result = IntentResolverUtils.sortVirtualResources(virtualResources);
+        Assert.assertTrue(result.size() == 2);
+        Assert.assertTrue(result.get(0) == virtualResource);
+
+    }
+}
\ No newline at end of file
index ac101e261314b7c3aaba5eacc708e7e7e3521ad8..8b18cde29d091ec9aa2d9167444e5baba3767bfc 100644 (file)
@@ -160,14 +160,33 @@ public class ConnectionInstanceCheckTest extends junit.framework.TestCase {
         verify(user,times(16)).getObjects();\r
         verify(connection,times(2)).getEndNode();\r
 \r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(user);\r
+        when(user.getObjects()).thenReturn(null);\r
+        when(connection.getEndNode()).thenReturn(null);\r
+        connectionInstanceCheckTest.checkConnInstance(userId,connection);\r
+        verify(tenantManage,times(4)).fetchVNSpace(userId);\r
+        verify(tenantManage,times(6)).getUser();\r
+        verify(user,times(17)).getObjects();\r
+        verify(connection,times(3)).getEndNode();\r
+\r
 \r
 \r
         doNothing().when(tenantManage).fetchVNSpace(userId);\r
         when(tenantManage.getUser()).thenReturn(null);\r
         when(connection.getEndNode()).thenReturn(endnodes);\r
         connectionInstanceCheckTest.checkConnInstance(userId,connection);\r
-        verify(tenantManage,times(4)).fetchVNSpace(userId);\r
-        verify(tenantManage,times(6)).getUser();\r
-        verify(connection,times(3)).getEndNode();\r
+        verify(tenantManage,times(5)).fetchVNSpace(userId);\r
+        verify(tenantManage,times(7)).getUser();\r
+        verify(connection,times(4)).getEndNode();\r
+\r
+\r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(null);\r
+        when(connection.getEndNode()).thenReturn(null);\r
+        connectionInstanceCheckTest.checkConnInstance(userId,connection);\r
+        verify(tenantManage,times(6)).fetchVNSpace(userId);\r
+        verify(tenantManage,times(8)).getUser();\r
+        verify(connection,times(5)).getEndNode();\r
     }\r
 }
\ No newline at end of file
index 855c6c1832b07cd5f45327439dd1447a3efc5d5c..8c6ad57184bc5b346b9334919e493d759cd089b7 100644 (file)
@@ -69,5 +69,41 @@ public class FlowInstanceCheckTest extends junit.framework.TestCase {
         verify(flowList.get(0)).getFlowName();\r
         verify(flow).getFlowName();\r
 \r
+\r
+\r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(null);\r
+        flowInstanceCheckTest.checkFlowInstance(userId,flow);\r
+        verify(tenantManage,times(2)).fetchVNSpace(userId);\r
+        verify(tenantManage,times(4)).getUser();\r
+\r
+\r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(user);\r
+        when(user.getObjects()).thenReturn(null);\r
+        flowInstanceCheckTest.checkFlowInstance(userId,flow);\r
+        verify(tenantManage,times(3)).fetchVNSpace(userId);\r
+        verify(tenantManage,times(5)).getUser();\r
+        verify(user,times(7)).getObjects();\r
+\r
+\r
+\r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(user);\r
+        when(user.getObjects()).thenReturn(object);\r
+        when(user.getObjects().getFlow()).thenReturn(null);\r
+        flowInstanceCheckTest.checkFlowInstance(userId,flow);\r
+        verify(tenantManage,times(4)).fetchVNSpace(userId);\r
+        verify(tenantManage,times(6)).getUser();\r
+        verify(user,times(10)).getObjects();\r
+        verify(user.getObjects(),times(3)).getFlow();\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
     }\r
 }
\ No newline at end of file
index f2cb6894ba17c6fb0c4927bfd835dea76bafe1be..6cdfe51c9f2d3db618d3443d29f696a0e395d346 100644 (file)
@@ -56,7 +56,6 @@ public class NodeInstanceCheckTest extends junit.framework.TestCase {
     @org.junit.Test\r
     public void testCheckNodeInstance() throws Exception {\r
         doNothing().when(tenantManage).fetchVNSpace(userId);\r
-        //doThrow(new SomeException()).when(tenantManage).fetchVNSpace(userId);\r
         when(tenantManage.getUser()).thenReturn(user);\r
         when(user.getObjects()).thenReturn(object);\r
         when(object.getNode()).thenReturn(nodeList);\r
@@ -73,10 +72,30 @@ public class NodeInstanceCheckTest extends junit.framework.TestCase {
         verify(object,times(2)).getNode();\r
         verify(nodeList.get(0)).getNodeId();\r
         verify(node).getNodeId();\r
-        //verify(nodeList.get(0)).getNodeName();\r
-        //verify(node).getNodeName();\r
-        //verify(nodeList.get(0)).getNodeType();\r
-        //verify(node).getNodeType();\r
+\r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(null);\r
+        nodeInstanceCheckTest.checkNodeInstance(userId,node);\r
+        verify(tenantManage,times(2)).getUser();\r
+\r
+\r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(user);\r
+        when(user.getObjects()).thenReturn(null);\r
+        nodeInstanceCheckTest.checkNodeInstance(userId,node);\r
+        verify(tenantManage,times(3)).getUser();\r
+        verify(user,times(2)).getObjects();\r
+\r
+\r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(user);\r
+        when(user.getObjects()).thenReturn(object);\r
+        when(object.getNode()).thenReturn(null);\r
+        nodeInstanceCheckTest.checkNodeInstance(userId,node);\r
+        verify(tenantManage,times(4)).getUser();\r
+        verify(user,times(3)).getObjects();\r
+        verify(object,times(3)).getNode();\r
+\r
 \r
     }\r
 }
\ No newline at end of file
index 1df909a8c1809bc53707cc89cdcb59b617bf77cd..39c4d55a97c11ada62a7219ec068f470592b632a 100644 (file)
@@ -207,6 +207,60 @@ public class OperationInstanceCheckTest extends junit.framework.TestCase {
         verify(tenantManage,times(4)).getUser();\r
         verify(operation,times(16)).getTargetObject();\r
 \r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(null);\r
+        when(operation.getTargetObject()).thenReturn(null);\r
+        perationInstanceCheckTest.checkOperationInstance(userId,operation);\r
+        verify(tenantManage,times(5)).fetchVNSpace(userId);\r
+        verify(tenantManage,times(5)).getUser();\r
+        verify(operation,times(17)).getTargetObject();\r
+\r
+\r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(null);\r
+        when(operation.getTargetObject()).thenReturn(null);\r
+        perationInstanceCheckTest.checkOperationInstance(userId,operation);\r
+        verify(tenantManage,times(6)).fetchVNSpace(userId);\r
+        verify(tenantManage,times(6)).getUser();\r
+        verify(operation,times(18)).getTargetObject();\r
+\r
+\r
+\r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(user);\r
+        when(operation.getTargetObject()).thenReturn(null);\r
+        when(user.getObjects()).thenReturn(object);\r
+        when(user.getOperations()).thenReturn(null);\r
+        perationInstanceCheckTest.checkOperationInstance(userId,operation);\r
+        verify(tenantManage,times(7)).fetchVNSpace(userId);\r
+        verify(tenantManage,times(7)).getUser();\r
+        verify(operation,times(20)).getTargetObject();\r
+        verify(user,times(8)).getObjects();\r
+        verify(user,times(2)).getOperations();\r
+\r
+\r
+\r
+\r
+        doNothing().when(tenantManage).fetchVNSpace(userId);\r
+        when(tenantManage.getUser()).thenReturn(user);\r
+        when(operation.getTargetObject()).thenReturn(objectId);\r
+        when(user.getObjects()).thenReturn(object);\r
+        when(user.getObjects()).thenReturn(object);\r
+\r
+        when(object.getNode()).thenReturn(null);\r
+        when(object.getConnection()).thenReturn(null);\r
+        when(object.getFlow()).thenReturn(null);\r
+\r
+        perationInstanceCheckTest.checkOperationInstance(userId,operation);\r
+        verify(tenantManage,times(8)).fetchVNSpace(userId);\r
+        verify(tenantManage,times(8)).getUser();\r
+        verify(operation,times(22)).getTargetObject();\r
+        verify(user,times(11)).getObjects();\r
+        verify(object,times(5)).getNode();\r
+        verify(object,times(5)).getConnection();\r
+        verify(object,times(5)).getFlow();\r
+\r
+\r
 \r
     }\r
 }
\ No newline at end of file