@Test public void when_update_service_is_called_the_user_entity_is_persisted_after_changed() { AuthUser user = mock(AuthUser.class); when(authUserRepository.findOrFail("user")).thenReturn(user); serviceToTest.updateRoles("user", new LinkedHashSet<>(Arrays.asList(RoleConstants.ROLE_USER))); InOrder inOrder = inOrder(authUserRepository,user,user,user,user,authUserRepository); inOrder.verify(authUserRepository).findOrFail("user"); inOrder.verify(user).setRoleSuperAdmin(false); inOrder.verify(user).setRoleOwner(false); inOrder.verify(user).setRoleUser(false); inOrder.verify(user).setRoleUser(true); inOrder.verify(authUserRepository).save(user); }
@UseCaseAdministratorAssignsUserToProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer adds ROLE_USER")) @UseCaseAdministratorUnassignsUserFromProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer removes ROLE_USER")) public void updateRoles(String userId, Set<String> roles) { assertion.isValidUserId(userId); internalUpdateRoles(userId, roles,0); }
AuthUserUpdateRolesService { @UseCaseAdministratorAssignsUserToProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer adds ROLE_USER")) @UseCaseAdministratorUnassignsUserFromProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer removes ROLE_USER")) public void updateRoles(String userId, Set<String> roles) { assertion.isValidUserId(userId); internalUpdateRoles(userId, roles,0); } }
AuthUserUpdateRolesService { @UseCaseAdministratorAssignsUserToProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer adds ROLE_USER")) @UseCaseAdministratorUnassignsUserFromProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer removes ROLE_USER")) public void updateRoles(String userId, Set<String> roles) { assertion.isValidUserId(userId); internalUpdateRoles(userId, roles,0); }  }
AuthUserUpdateRolesService { @UseCaseAdministratorAssignsUserToProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer adds ROLE_USER")) @UseCaseAdministratorUnassignsUserFromProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer removes ROLE_USER")) public void updateRoles(String userId, Set<String> roles) { assertion.isValidUserId(userId); internalUpdateRoles(userId, roles,0); }  @UseCaseAdministratorAssignsUserToProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer adds ROLE_USER")) @UseCaseAdministratorUnassignsUserFromProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer removes ROLE_USER"))/* @formatter:on */ void updateRoles(String userId, Set<String> roles); }
AuthUserUpdateRolesService { @UseCaseAdministratorAssignsUserToProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer adds ROLE_USER")) @UseCaseAdministratorUnassignsUserFromProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer removes ROLE_USER")) public void updateRoles(String userId, Set<String> roles) { assertion.isValidUserId(userId); internalUpdateRoles(userId, roles,0); }  @UseCaseAdministratorAssignsUserToProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer adds ROLE_USER")) @UseCaseAdministratorUnassignsUserFromProject(@Step(number=4,next={Step.NO_NEXT_STEP} ,name="Roles changed in auth", description="Authorization layer removes ROLE_USER"))/* @formatter:on */ void updateRoles(String userId, Set<String> roles);  }