@Test public void testRegisterUser() throws Exception { RegisterUserInput input = mock(RegisterUserInput.class); UserRoleName userRoleName = mock(UserRoleName.class); UserRole userRole = mock(UserRole.class); UserId userId = mock(UserId.class); User user = mock(User.class); Map<UserRoleName, UserRole> userRoles = new HashMap<UserRoleName, UserRole>(); Map<UserId, User> users = new HashMap<UserId, User>(); when(tenantManage.getUsers()).thenReturn(users); when(tenantManage.getUserRoles()).thenReturn(userRoles); Assert.assertTrue(userRoles.isEmpty()); Assert.assertTrue(registerUser.registerUser(input).equals("There are no roles be defined.")); userRoles.put(userRoleName, userRole); when(input.getUserRole()) .thenReturn(new UserRoleName("admin")) .thenReturn(userRoleName); Assert.assertTrue(registerUser.registerUser(input).equals("The role is not defined in the data store.")); verify(input).getUserRole(); Assert.assertTrue(!userRoles.containsKey(new UserRoleName("admin"))); users.put(userId,user); when(input.getUserId()) .thenReturn(userId) .thenReturn(new UserId("00001111-0000-0000-0000-000011112222")); Assert.assertTrue(registerUser.registerUser(input).equals("The user has been registered.")); doNothing().when(tenantManage).addUser(any(RegisterUserInput.class)); Assert.assertTrue(registerUser.registerUser(input) == null); verify(tenantManage).addUser(any(RegisterUserInput.class)); }
public RegisterUser(TenantManage tenantManage) { this.tenantManage = tenantManage; }
RegisterUser { public RegisterUser(TenantManage tenantManage) { this.tenantManage = tenantManage; } }
RegisterUser { public RegisterUser(TenantManage tenantManage) { this.tenantManage = tenantManage; } RegisterUser(TenantManage tenantManage); }
RegisterUser { public RegisterUser(TenantManage tenantManage) { this.tenantManage = tenantManage; } RegisterUser(TenantManage tenantManage); String registerUser(RegisterUserInput input); }
RegisterUser { public RegisterUser(TenantManage tenantManage) { this.tenantManage = tenantManage; } RegisterUser(TenantManage tenantManage); String registerUser(RegisterUserInput input);  }