@Test public void testDeleteConnectionHandling() throws Exception { Class<DeleteConnectionLang> class1 = DeleteConnectionLang.class; Field field = class1.getDeclaredField("deleteConnection"); field.setAccessible(true); UserId userId = mock(UserId.class); String connectionname = new String("test"); DeleteConnection deleteConnection = mock(DeleteConnection.class); when(tenantManage.getObjectId(userId,connectionname)) .thenReturn(null) .thenReturn(new String("00001111-0000-0000-0000-000011112222")); field.set(deleteConnectionLang, deleteConnection); when(deleteConnection.DeleteConnectionHandling(any(UserId.class),any(ConnectionId.class))).thenReturn(new String("test")); Assert.assertTrue(deleteConnectionLang.DeleteConnectionHandling(userId, connectionname).equals("The connection " + connectionname + " is not exist.")); Assert.assertTrue(deleteConnectionLang.DeleteConnectionHandling(userId,connectionname).equals("test")); verify(tenantManage,times(3)).getObjectId(userId,connectionname); }
public String DeleteConnectionHandling(UserId userId, String connectionname){ if (tenantManage.getObjectId(userId,connectionname)!=null){ ConnectionId connectionId = new ConnectionId(tenantManage.getObjectId(userId,connectionname)); return deleteConnection.DeleteConnectionHandling(userId,connectionId); } else { return "The connection " + connectionname + " is not exist."; } }
DeleteConnectionLang { public String DeleteConnectionHandling(UserId userId, String connectionname){ if (tenantManage.getObjectId(userId,connectionname)!=null){ ConnectionId connectionId = new ConnectionId(tenantManage.getObjectId(userId,connectionname)); return deleteConnection.DeleteConnectionHandling(userId,connectionId); } else { return "The connection " + connectionname + " is not exist."; } } }
DeleteConnectionLang { public String DeleteConnectionHandling(UserId userId, String connectionname){ if (tenantManage.getObjectId(userId,connectionname)!=null){ ConnectionId connectionId = new ConnectionId(tenantManage.getObjectId(userId,connectionname)); return deleteConnection.DeleteConnectionHandling(userId,connectionId); } else { return "The connection " + connectionname + " is not exist."; } } DeleteConnectionLang(DataBroker dataBroker, TenantManage tenantManage); }
DeleteConnectionLang { public String DeleteConnectionHandling(UserId userId, String connectionname){ if (tenantManage.getObjectId(userId,connectionname)!=null){ ConnectionId connectionId = new ConnectionId(tenantManage.getObjectId(userId,connectionname)); return deleteConnection.DeleteConnectionHandling(userId,connectionId); } else { return "The connection " + connectionname + " is not exist."; } } DeleteConnectionLang(DataBroker dataBroker, TenantManage tenantManage); String DeleteConnectionHandling(UserId userId, String connectionname); }
DeleteConnectionLang { public String DeleteConnectionHandling(UserId userId, String connectionname){ if (tenantManage.getObjectId(userId,connectionname)!=null){ ConnectionId connectionId = new ConnectionId(tenantManage.getObjectId(userId,connectionname)); return deleteConnection.DeleteConnectionHandling(userId,connectionId); } else { return "The connection " + connectionname + " is not exist."; } } DeleteConnectionLang(DataBroker dataBroker, TenantManage tenantManage); String DeleteConnectionHandling(UserId userId, String connectionname);  }