@Test void testUpdateMembership() { when(roleMembership.getId()).thenReturn("membershipId"); when(dataService.findOneById(ROLE_MEMBERSHIP, "membershipId", RoleMembership.class)) .thenReturn(roleMembership); roleMembershipService.updateMembership(roleMembership, editor); verify(roleMembership).setRole(editor); verify(dataService).update(ROLE_MEMBERSHIP, roleMembership); }
@RunAsSystem @Override public void updateMembership(RoleMembership roleMembership, Role newRole) { final RoleMembership membership = dataService.findOneById( RoleMembershipMetadata.ROLE_MEMBERSHIP, roleMembership.getId(), RoleMembership.class); if (membership == null) { throw new UnknownEntityException(roleMetadata, roleMembership.getId()); } membership.setRole(newRole); dataService.update(RoleMembershipMetadata.ROLE_MEMBERSHIP, membership); }
RoleMembershipServiceImpl implements RoleMembershipService { @RunAsSystem @Override public void updateMembership(RoleMembership roleMembership, Role newRole) { final RoleMembership membership = dataService.findOneById( RoleMembershipMetadata.ROLE_MEMBERSHIP, roleMembership.getId(), RoleMembership.class); if (membership == null) { throw new UnknownEntityException(roleMetadata, roleMembership.getId()); } membership.setRole(newRole); dataService.update(RoleMembershipMetadata.ROLE_MEMBERSHIP, membership); } }
RoleMembershipServiceImpl implements RoleMembershipService { @RunAsSystem @Override public void updateMembership(RoleMembership roleMembership, Role newRole) { final RoleMembership membership = dataService.findOneById( RoleMembershipMetadata.ROLE_MEMBERSHIP, roleMembership.getId(), RoleMembership.class); if (membership == null) { throw new UnknownEntityException(roleMetadata, roleMembership.getId()); } membership.setRole(newRole); dataService.update(RoleMembershipMetadata.ROLE_MEMBERSHIP, membership); } RoleMembershipServiceImpl(
      UserService userService,
      RoleMembershipFactory roleMembershipFactory,
      DataService dataService,
      UserMetadata userMetadata,
      RoleMetadata roleMetadata); }
RoleMembershipServiceImpl implements RoleMembershipService { @RunAsSystem @Override public void updateMembership(RoleMembership roleMembership, Role newRole) { final RoleMembership membership = dataService.findOneById( RoleMembershipMetadata.ROLE_MEMBERSHIP, roleMembership.getId(), RoleMembership.class); if (membership == null) { throw new UnknownEntityException(roleMetadata, roleMembership.getId()); } membership.setRole(newRole); dataService.update(RoleMembershipMetadata.ROLE_MEMBERSHIP, membership); } RoleMembershipServiceImpl(
      UserService userService,
      RoleMembershipFactory roleMembershipFactory,
      DataService dataService,
      UserMetadata userMetadata,
      RoleMetadata roleMetadata); @RunAsSystem @Override void addUserToRole(String username, String roleName); @RunAsSystem @Override void addUserToRole(final User user, final Role role); @RunAsSystem @Override void removeMembership(final RoleMembership roleMembership); @RunAsSystem @Override void updateMembership(RoleMembership roleMembership, Role newRole); @RunAsSystem @Override Collection<RoleMembership> getMemberships(Collection<Role> roles); }
RoleMembershipServiceImpl implements RoleMembershipService { @RunAsSystem @Override public void updateMembership(RoleMembership roleMembership, Role newRole) { final RoleMembership membership = dataService.findOneById( RoleMembershipMetadata.ROLE_MEMBERSHIP, roleMembership.getId(), RoleMembership.class); if (membership == null) { throw new UnknownEntityException(roleMetadata, roleMembership.getId()); } membership.setRole(newRole); dataService.update(RoleMembershipMetadata.ROLE_MEMBERSHIP, membership); } RoleMembershipServiceImpl(
      UserService userService,
      RoleMembershipFactory roleMembershipFactory,
      DataService dataService,
      UserMetadata userMetadata,
      RoleMetadata roleMetadata); @RunAsSystem @Override void addUserToRole(String username, String roleName); @RunAsSystem @Override void addUserToRole(final User user, final Role role); @RunAsSystem @Override void removeMembership(final RoleMembership roleMembership); @RunAsSystem @Override void updateMembership(RoleMembership roleMembership, Role newRole); @RunAsSystem @Override Collection<RoleMembership> getMemberships(Collection<Role> roles);  }