@Test public void testDeleteNodeHandling() throws Exception { Class<DeleteNodeLang> class1 = DeleteNodeLang.class; Field field = class1.getDeclaredField("deleteNode"); field.setAccessible(true); UserId userId = mock(UserId.class); String nodename = new String("test"); DeleteNode deleteNode = mock(DeleteNode.class); when(tenantManage.getObjectId(userId,nodename)) .thenReturn(null) .thenReturn(new String("00001111-0000-0000-0000-000011112222")); Assert.assertTrue(deleteNodeLang.DeleteNodeHandling(userId, nodename).equals("The node " + nodename + " is not exist.")); verify(tenantManage).getObjectId(userId, nodename); field.set(deleteNodeLang, deleteNode); when(deleteNode.DeleNodeHandling(any(UserId.class),any(NodeId.class))).thenReturn(new String("test")); Assert.assertTrue(deleteNodeLang.DeleteNodeHandling(userId, nodename).equals("test")); verify(tenantManage,times(3)).getObjectId(userId, nodename); }
public String DeleteNodeHandling(UserId userId, String nodename){ if (tenantManage.getObjectId(userId,nodename)!=null){ NodeId nodeId = new NodeId(tenantManage.getObjectId(userId,nodename)); return deleteNode.DeleNodeHandling(userId,nodeId); } else { return "The node " + nodename + " is not exist."; } }
DeleteNodeLang { public String DeleteNodeHandling(UserId userId, String nodename){ if (tenantManage.getObjectId(userId,nodename)!=null){ NodeId nodeId = new NodeId(tenantManage.getObjectId(userId,nodename)); return deleteNode.DeleNodeHandling(userId,nodeId); } else { return "The node " + nodename + " is not exist."; } } }
DeleteNodeLang { public String DeleteNodeHandling(UserId userId, String nodename){ if (tenantManage.getObjectId(userId,nodename)!=null){ NodeId nodeId = new NodeId(tenantManage.getObjectId(userId,nodename)); return deleteNode.DeleNodeHandling(userId,nodeId); } else { return "The node " + nodename + " is not exist."; } } DeleteNodeLang(DataBroker dataBroker, TenantManage tenantManage); }
DeleteNodeLang { public String DeleteNodeHandling(UserId userId, String nodename){ if (tenantManage.getObjectId(userId,nodename)!=null){ NodeId nodeId = new NodeId(tenantManage.getObjectId(userId,nodename)); return deleteNode.DeleNodeHandling(userId,nodeId); } else { return "The node " + nodename + " is not exist."; } } DeleteNodeLang(DataBroker dataBroker, TenantManage tenantManage); String DeleteNodeHandling(UserId userId, String nodename); }
DeleteNodeLang { public String DeleteNodeHandling(UserId userId, String nodename){ if (tenantManage.getObjectId(userId,nodename)!=null){ NodeId nodeId = new NodeId(tenantManage.getObjectId(userId,nodename)); return deleteNode.DeleNodeHandling(userId,nodeId); } else { return "The node " + nodename + " is not exist."; } } DeleteNodeLang(DataBroker dataBroker, TenantManage tenantManage); String DeleteNodeHandling(UserId userId, String nodename);  }