+ //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<Void, TransactionCommitFailedException> 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));