@Test void testValidateRoleMembershipWithoutGroup() { RoleMembership roleMembership = mock(RoleMembership.class); Role roleWithoutGroup = mock(Role.class); when(roleMembership.getRole()).thenReturn(roleWithoutGroup); roleMembershipValidatorImpl.validate(roleMembership); verifyZeroInteractions(dataService); }
@Override public void validate(RoleMembership roleMembership) { Group group = roleMembership.getRole().getGroup(); if (group != null) { getUserRoleMemberships(roleMembership.getUser()) .filter( userRoleMembership -> isDifferentRoleMembership(userRoleMembership, roleMembership)) .forEach(otherUserRoleMembership -> validateGroup(otherUserRoleMembership, group)); } }
RoleMembershipValidatorImpl implements RoleMembershipValidator { @Override public void validate(RoleMembership roleMembership) { Group group = roleMembership.getRole().getGroup(); if (group != null) { getUserRoleMemberships(roleMembership.getUser()) .filter( userRoleMembership -> isDifferentRoleMembership(userRoleMembership, roleMembership)) .forEach(otherUserRoleMembership -> validateGroup(otherUserRoleMembership, group)); } } }
RoleMembershipValidatorImpl implements RoleMembershipValidator { @Override public void validate(RoleMembership roleMembership) { Group group = roleMembership.getRole().getGroup(); if (group != null) { getUserRoleMemberships(roleMembership.getUser()) .filter( userRoleMembership -> isDifferentRoleMembership(userRoleMembership, roleMembership)) .forEach(otherUserRoleMembership -> validateGroup(otherUserRoleMembership, group)); } } RoleMembershipValidatorImpl(DataService dataService); }
RoleMembershipValidatorImpl implements RoleMembershipValidator { @Override public void validate(RoleMembership roleMembership) { Group group = roleMembership.getRole().getGroup(); if (group != null) { getUserRoleMemberships(roleMembership.getUser()) .filter( userRoleMembership -> isDifferentRoleMembership(userRoleMembership, roleMembership)) .forEach(otherUserRoleMembership -> validateGroup(otherUserRoleMembership, group)); } } RoleMembershipValidatorImpl(DataService dataService); @Override void validate(RoleMembership roleMembership); }
RoleMembershipValidatorImpl implements RoleMembershipValidator { @Override public void validate(RoleMembership roleMembership) { Group group = roleMembership.getRole().getGroup(); if (group != null) { getUserRoleMemberships(roleMembership.getUser()) .filter( userRoleMembership -> isDifferentRoleMembership(userRoleMembership, roleMembership)) .forEach(otherUserRoleMembership -> validateGroup(otherUserRoleMembership, group)); } } RoleMembershipValidatorImpl(DataService dataService); @Override void validate(RoleMembership roleMembership);  }