From 5f4d60811629b16749ef4ece66fdb31fcef6e067 Mon Sep 17 00:00:00 2001 From: GaoJie Date: Mon, 30 Nov 2015 17:50:19 +0800 Subject: [PATCH] Modify nemo-impl partical test files Change-Id: Ie2d24658cd471d8b20d45331fb0a231a48fe6828 Signed-off-by: GaoJie --- .../deleteintent/DeleteConnectionTest.java | 84 +++++++++++++++++-- .../deleteintent/DeleteFlowTest.java | 81 +++++++++++++++--- .../deleteintent/DeleteNodeTest.java | 79 ++++++++++++++--- .../deleteintent/DeleteOperationTest.java | 79 ++++++++++++++--- .../deleteintent/DeleteResultTest.java | 11 +-- 5 files changed, 288 insertions(+), 46 deletions(-) diff --git a/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteConnectionTest.java b/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteConnectionTest.java index 9719a45..5eecf5b 100644 --- a/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteConnectionTest.java +++ b/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteConnectionTest.java @@ -1,24 +1,46 @@ -/* - * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ package org.opendaylight.nemo.user.vnspacemanager.structurestyle.deleteintent; +import org.opendaylight.nemo.user.vnspacemanager.structurestyle.*; import static org.mockito.Mockito.mock; import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.nemo.user.tenantmanager.TenantManage; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.ConnectionId; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.Users; +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.ConnectionKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.User; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.UserKey; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.List; +import java.util.*; +import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; +import static org.mockito.Mockito.*; public class DeleteConnectionTest{ private DataBroker dataBroker; private TenantManage tenantManage; private DeleteConnection deleteconnection; private UserId userId; private ConnectionId connectionID; + private User user; + private Objects objects; + private Connection connection; + private List connectionList; + private ConnectionId NotconnectionID; + private ConnectionId connectionID2; + private WriteTransaction writetransaction; @org.junit.Before public void setUp() throws Exception { dataBroker=mock(DataBroker.class); @@ -26,9 +48,55 @@ public void setUp() throws Exception { deleteconnection=mock(DeleteConnection.class); userId=mock(UserId.class); connectionID=mock(ConnectionId.class); + NotconnectionID=mock(ConnectionId.class); + connectionID2=connectionID; + user=mock(User.class); + objects=mock(Objects.class); + connection=mock(Connection.class); + connectionList=new ArrayList(3); + connectionList.add(connection); + deleteconnection=new DeleteConnection(dataBroker,tenantManage); + writetransaction=mock(WriteTransaction.class); } @org.junit.Test public void DeleteConnectionHandlingTest() throws Exception{ - Assert.assertNull(deleteconnection.DeleteConnectionHandling(userId,connectionID)); + //no data test + CheckedFuture connectiondefinitionFuture = mock(CheckedFuture.class); + ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); + when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); + + when(tenantManage.getUser()).thenReturn(null); + Assert.assertEquals(deleteconnection.DeleteConnectionHandling(userId,connectionID),"There are no connection instances in data store."); + //data exists and other branches + // branch 1 + when (tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(null); + Assert.assertEquals(deleteconnection.DeleteConnectionHandling(userId,connectionID),null); + //branch 2 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(objects); + when(user.getObjects().getConnection()).thenReturn(null); + Assert.assertEquals(deleteconnection.DeleteConnectionHandling(userId,connectionID),"There are no connection instances in data store."); + //branch 3 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(objects); + when(objects.getConnection()).thenReturn(connectionList); + when(connection.getConnectionId()).thenReturn(NotconnectionID); + Assert.assertEquals(deleteconnection.DeleteConnectionHandling(userId,connectionID),"The connection instance"+connectionID.toString()+ "is not exit. Could not be deleted."); + //branch 4 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(objects); + when(objects.getConnection()).thenReturn(connectionList); + when(connection.getConnectionId()).thenReturn(connectionID); + when(dataBroker.newWriteOnlyTransaction()).thenReturn(writetransaction); + CheckedFuture f; + f=mock(CheckedFuture.class); + when(writetransaction.submit()).thenReturn(f); + Assert.assertEquals(deleteconnection.DeleteConnectionHandling(userId,connectionID),null); + //------- + Assert.assertNotNull(deleteconnection); + Assert.assertNotNull(tenantManage); + //Assert.assertNull(deleteconnection.DeleteConnectionHandling(userId,connectionID)); } + } \ No newline at end of file diff --git a/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteFlowTest.java b/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteFlowTest.java index 54b83be..3a5daa5 100644 --- a/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteFlowTest.java +++ b/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteFlowTest.java @@ -1,34 +1,95 @@ -/* - * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ package org.opendaylight.nemo.user.vnspacemanager.structurestyle.deleteintent; +import org.opendaylight.nemo.user.vnspacemanager.structurestyle.*; import static org.mockito.Mockito.mock; - import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.nemo.user.tenantmanager.TenantManage; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.FlowId; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.Users; +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.Flow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.FlowKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.User; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.UserKey; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.*; +import java.util.List; +import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; public class DeleteFlowTest{ private DataBroker dataBroker; private TenantManage tenantManage; private DeleteFlow deleteflow; private UserId userId; private FlowId flowId; + private Objects objects; + private User user; + private List flowlist; + private Flow flow; + private FlowId notflowId; + private WriteTransaction writetransaction; @org.junit.Before public void setUp() throws Exception { dataBroker=mock(DataBroker.class); tenantManage=mock(TenantManage.class); - deleteflow=mock(DeleteFlow.class); + deleteflow=new DeleteFlow(dataBroker,tenantManage); userId=mock(UserId.class); flowId=mock(FlowId.class); + objects=mock(Objects.class); + user=mock(User.class); + flow=mock(Flow.class); + notflowId=mock(FlowId.class); + flowlist=new ArrayList(1); + flowlist.add(flow); + writetransaction=mock(WriteTransaction.class); } @org.junit.Test public void DeleteFlowHandlingTest() throws Exception{ - Assert.assertNull(deleteflow.DeleteFlowHandling(userId,flowId)); + CheckedFuture connectiondefinitionFuture = mock(CheckedFuture.class); + ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); + when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); + + //no data test + when(tenantManage.getUser()).thenReturn(null); + Assert.assertEquals(deleteflow.DeleteFlowHandling(userId,flowId),"There are no user in the data store."); + //data exists and other branches + //branch 1 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(null); + Assert.assertEquals(deleteflow.DeleteFlowHandling(userId,flowId),null); + //branch 2 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(objects); + when(user.getObjects().getFlow()).thenReturn(null); + Assert.assertEquals(deleteflow.DeleteFlowHandling(userId,flowId),"There are no flow instances in the data store."); + //branch 3 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(objects); + when(user.getObjects().getFlow()).thenReturn(flowlist); + when(flow.getFlowId()).thenReturn(notflowId); + Assert.assertEquals(deleteflow.DeleteFlowHandling(userId,flowId),"The flow instance" +flowId.toString()+"is not exist. Could not be deleted."); + //branch 4 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(objects); + when(user.getObjects().getFlow()).thenReturn(flowlist); + when(flow.getFlowId()).thenReturn(flowId); + when(dataBroker.newWriteOnlyTransaction()).thenReturn(writetransaction); + CheckedFuture f; + f=mock(CheckedFuture.class); + when(writetransaction.submit()).thenReturn(f); + Assert.assertEquals(deleteflow.DeleteFlowHandling(userId,flowId),null); } } diff --git a/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteNodeTest.java b/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteNodeTest.java index 901dc66..264bf59 100644 --- a/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteNodeTest.java +++ b/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteNodeTest.java @@ -1,34 +1,93 @@ -/* - * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ package org.opendaylight.nemo.user.vnspacemanager.structurestyle.deleteintent; +import org.opendaylight.nemo.user.vnspacemanager.structurestyle.*; import static org.mockito.Mockito.mock; - import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.nemo.user.tenantmanager.TenantManage; 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.common.rev151010.UserId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.Users; +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.Node; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.NodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.User; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.UserKey; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.List; +import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; +import java.util.*; public class DeleteNodeTest{ private DataBroker dataBroker; private TenantManage tenantManage; private UserId userid; private NodeId nodeid; private DeleteNode deletenode; + private User user; + private Objects objects; + private Node node; + private NodeId notnodeid; + private List nodeList; + private WriteTransaction writetransaction; @org.junit.Before public void setUp() throws Exception{ dataBroker=mock(DataBroker.class); tenantManage=mock(TenantManage.class); userid=mock(UserId.class); nodeid=mock(NodeId.class); - deletenode=mock(DeleteNode.class); + deletenode=new DeleteNode(dataBroker,tenantManage); + user=mock(User.class); + objects=mock(Objects.class); + node=mock(Node.class); + notnodeid=mock(NodeId.class); + nodeList=new ArrayList(1); + nodeList.add(node); + writetransaction=mock(WriteTransaction.class); } @org.junit.Test public void DeleNodeHandlingTest(){ - Assert.assertNull(deletenode.DeleNodeHandling(userid,nodeid)); + CheckedFuture connectiondefinitionFuture = mock(CheckedFuture.class); + ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); + when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); + //branch 1 + when(tenantManage.getUser()).thenReturn(null); + Assert.assertEquals(deletenode.DeleNodeHandling(userid,nodeid),"There are no user in data store."); + //branch 2 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(null); + Assert.assertEquals(deletenode.DeleNodeHandling(userid,nodeid),null); + //branch 3 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(objects); + when(objects.getNode()).thenReturn(null); + Assert.assertEquals(deletenode.DeleNodeHandling(userid,nodeid),"There are no nodes instances in data store."); + //branch 4 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(objects); + when(objects.getNode()).thenReturn(nodeList); + when(node.getNodeId()).thenReturn(notnodeid); + Assert.assertEquals(deletenode.DeleNodeHandling(userid,nodeid),"The node instance" +nodeid.toString()+"is not exist.Could not be deleted"); + //branch 5 + when(tenantManage.getUser()).thenReturn(user); + when(user.getObjects()).thenReturn(objects); + when(objects.getNode()).thenReturn(nodeList); + when(node.getNodeId()).thenReturn(nodeid); + when(dataBroker.newWriteOnlyTransaction()).thenReturn(writetransaction); + CheckedFuture f; + f=mock(CheckedFuture.class); + when(writetransaction.submit()).thenReturn(f); + Assert.assertEquals(deletenode.DeleNodeHandling(userid,nodeid),null); } } diff --git a/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteOperationTest.java b/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteOperationTest.java index 4ead7bf..4c97735 100644 --- a/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteOperationTest.java +++ b/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteOperationTest.java @@ -1,34 +1,93 @@ -/* - * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ package org.opendaylight.nemo.user.vnspacemanager.structurestyle.deleteintent; +import org.opendaylight.nemo.user.vnspacemanager.structurestyle.*; import static org.mockito.Mockito.mock; - import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.nemo.user.tenantmanager.TenantManage; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.OperationId; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.Users; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.Operations; +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.intent.rev151010.user.intent.operations.OperationKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.User; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.UserKey; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.List; +import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; +import java.util.*; public class DeleteOperationTest{ private DataBroker dataBroker; private TenantManage tenantManage; private UserId userId; + private User user; private OperationId operationId; private DeleteOperation deleteoperation; + private Operations operations; + private Operation operation; + private OperationId notoperationId; + private List operationList; + private WriteTransaction writetransaction; @org.junit.Before public void setUp() throws Exception{ dataBroker=mock(DataBroker.class); tenantManage=mock(TenantManage.class); userId=mock(UserId.class); operationId=mock(OperationId.class); - deleteoperation=mock(DeleteOperation.class); + user=mock(User.class); + operation=mock(Operation.class); + notoperationId=mock(OperationId.class); + deleteoperation=new DeleteOperation(dataBroker,tenantManage); + operations=mock(Operations.class); + operationList=new ArrayList(1); + operationList.add(operation); + writetransaction=mock(WriteTransaction.class); } @org.junit.Test public void DeleteOperationhandlingTest(){ - Assert.assertNull(deleteoperation.DeleteOperationhandling(userId,operationId)); + CheckedFuture connectiondefinitionFuture = mock(CheckedFuture.class); + ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); + when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); + //branch 1 + when(tenantManage.getUser()).thenReturn(null); + Assert.assertEquals(deleteoperation.DeleteOperationhandling(userId,operationId),"There are no user in the data store."); + //branch 2 + when(tenantManage.getUser()).thenReturn(user); + when(user.getOperations()).thenReturn(null); + Assert.assertEquals(deleteoperation.DeleteOperationhandling(userId,operationId),null); + //branch 3 + when(tenantManage.getUser()).thenReturn(user); + when(user.getOperations()).thenReturn(operations); + when(operations.getOperation()).thenReturn(null); + Assert.assertEquals(deleteoperation.DeleteOperationhandling(userId,operationId),"There are no operation instances in the data store."); + //branch 4 + when(tenantManage.getUser()).thenReturn(user); + when(user.getOperations()).thenReturn(operations); + when(operations.getOperation()).thenReturn(operationList); + when(operation.getOperationId()).thenReturn(notoperationId); + Assert.assertEquals(deleteoperation.DeleteOperationhandling(userId,operationId),"The operation instance" +operationId.toString()+"is not exist. Could not be deleted."); + //branch 5 + when(tenantManage.getUser()).thenReturn(user); + when(user.getOperations()).thenReturn(operations); + when(operations.getOperation()).thenReturn(operationList); + when(operation.getOperationId()).thenReturn(operationId); + when(dataBroker.newWriteOnlyTransaction()).thenReturn(writetransaction); + CheckedFuture f; + f=mock(CheckedFuture.class); + when(writetransaction.submit()).thenReturn(f); + Assert.assertEquals(deleteoperation.DeleteOperationhandling(userId,operationId),null); } } \ No newline at end of file diff --git a/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteResultTest.java b/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteResultTest.java index da879ce..b2cce97 100644 --- a/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteResultTest.java +++ b/nemo-impl/src/test/java/org/opendaylight/nemo/user/vnspacemanager/structurestyle/deleteintent/DeleteResultTest.java @@ -1,14 +1,9 @@ -/* - * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ package org.opendaylight.nemo.user.vnspacemanager.structurestyle.deleteintent; +import org.opendaylight.nemo.user.vnspacemanager.structurestyle.*; import static org.mockito.Mockito.mock; - import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.structure.style.nemo.delete.input.Results; public class DeleteResultTest{ -- 2.36.6