@Test public void shouldSaveFulfillmentRolesForUser() throws Exception { User user = new User(); FulfillmentRoleAssignment fulfillmentRoleAssignment = new FulfillmentRoleAssignment(1L, 2L, asList(3L)); user.setFulfillmentRoles(asList(fulfillmentRoleAssignment)); fulfillmentRoleAssignmentRepository.insertFulfillmentRoles(user); verify(fulfillmentRoleAssignmentMapper).insertFulfillmentRole(user, fulfillmentRoleAssignment.getFacilityId(), fulfillmentRoleAssignment.getRoleIds().get(0)); }
public void insertFulfillmentRoles(final User user) { if (user.getFulfillmentRoles() == null) return; fulfillmentRoleAssignmentMapper.deleteAllFulfillmentRoles(user); for (final FulfillmentRoleAssignment fulfillmentRoleAssignment : user.getFulfillmentRoles()) { if (fulfillmentRoleAssignment == null) continue; forAllDo(fulfillmentRoleAssignment.getRoleIds(), new Closure() { @Override public void execute(Object o) { final Long roleId = (Long) o; fulfillmentRoleAssignmentMapper.insertFulfillmentRole(user, fulfillmentRoleAssignment.getFacilityId(), roleId); } }); } }
FulfillmentRoleAssignmentRepository { public void insertFulfillmentRoles(final User user) { if (user.getFulfillmentRoles() == null) return; fulfillmentRoleAssignmentMapper.deleteAllFulfillmentRoles(user); for (final FulfillmentRoleAssignment fulfillmentRoleAssignment : user.getFulfillmentRoles()) { if (fulfillmentRoleAssignment == null) continue; forAllDo(fulfillmentRoleAssignment.getRoleIds(), new Closure() { @Override public void execute(Object o) { final Long roleId = (Long) o; fulfillmentRoleAssignmentMapper.insertFulfillmentRole(user, fulfillmentRoleAssignment.getFacilityId(), roleId); } }); } } }
FulfillmentRoleAssignmentRepository { public void insertFulfillmentRoles(final User user) { if (user.getFulfillmentRoles() == null) return; fulfillmentRoleAssignmentMapper.deleteAllFulfillmentRoles(user); for (final FulfillmentRoleAssignment fulfillmentRoleAssignment : user.getFulfillmentRoles()) { if (fulfillmentRoleAssignment == null) continue; forAllDo(fulfillmentRoleAssignment.getRoleIds(), new Closure() { @Override public void execute(Object o) { final Long roleId = (Long) o; fulfillmentRoleAssignmentMapper.insertFulfillmentRole(user, fulfillmentRoleAssignment.getFacilityId(), roleId); } }); } }  }
FulfillmentRoleAssignmentRepository { public void insertFulfillmentRoles(final User user) { if (user.getFulfillmentRoles() == null) return; fulfillmentRoleAssignmentMapper.deleteAllFulfillmentRoles(user); for (final FulfillmentRoleAssignment fulfillmentRoleAssignment : user.getFulfillmentRoles()) { if (fulfillmentRoleAssignment == null) continue; forAllDo(fulfillmentRoleAssignment.getRoleIds(), new Closure() { @Override public void execute(Object o) { final Long roleId = (Long) o; fulfillmentRoleAssignmentMapper.insertFulfillmentRole(user, fulfillmentRoleAssignment.getFacilityId(), roleId); } }); } }  List<FulfillmentRoleAssignment> getFulfillmentRolesForUser(Long userId); void insertFulfillmentRoles(final User user); List<FulfillmentRoleAssignment> getRolesWithRight(Long userId, String rightName); }
FulfillmentRoleAssignmentRepository { public void insertFulfillmentRoles(final User user) { if (user.getFulfillmentRoles() == null) return; fulfillmentRoleAssignmentMapper.deleteAllFulfillmentRoles(user); for (final FulfillmentRoleAssignment fulfillmentRoleAssignment : user.getFulfillmentRoles()) { if (fulfillmentRoleAssignment == null) continue; forAllDo(fulfillmentRoleAssignment.getRoleIds(), new Closure() { @Override public void execute(Object o) { final Long roleId = (Long) o; fulfillmentRoleAssignmentMapper.insertFulfillmentRole(user, fulfillmentRoleAssignment.getFacilityId(), roleId); } }); } }  List<FulfillmentRoleAssignment> getFulfillmentRolesForUser(Long userId); void insertFulfillmentRoles(final User user); List<FulfillmentRoleAssignment> getRolesWithRight(Long userId, String rightName);  }