DeleteOperationLang { public String DeleteOperationHandling(UserId userId, String operationname){ if (tenantManage.getObjectId(userId,operationname)!=null){ OperationId operationId = new OperationId(tenantManage.getObjectId(userId,operationname)); return deleteOperation.DeleteOperationhandling(userId,operationId); } else { return "The operation " + operationname + " is not exist."; } } DeleteOperationLang(DataBroker dataBroker, TenantManage tenantManage); String DeleteOperationHandling(UserId userId, String operationname);  }
@Test public void testDeleteOperationHandling() throws Exception { Class<DeleteOperationLang> class1 = DeleteOperationLang.class; Field field = class1.getDeclaredField("deleteOperation"); field.setAccessible(true); UserId userId = mock(UserId.class); String operationname = new String("test"); DeleteOperation deleteOperation = mock(DeleteOperation.class); when(tenantManage.getObjectId(userId,operationname)) .thenReturn(null) .thenReturn(new String("00001111-0000-0000-0000-000011112222")); Assert.assertTrue(deleteOperationLang.DeleteOperationHandling(userId, operationname).equals("The operation " + operationname + " is not exist.")); verify(tenantManage).getObjectId(userId, operationname); field.set(deleteOperationLang, deleteOperation); when(deleteOperation.DeleteOperationhandling(any(UserId.class),any(OperationId.class))).thenReturn(new String("test")); Assert.assertTrue(deleteOperationLang.DeleteOperationHandling(userId, operationname).equals("test")); verify(tenantManage,times(3)).getObjectId(userId, operationname); }