@Test public void startWithUsersFileLoadingError() { System.setProperty(SimpleUserSystemService.USERS_FILE, NON_EXISTING_PATH); String expectedMessage = String.format(USERS_INFO_LOADING_ERROR, NON_EXISTING_PATH, skillsPath, affinitiesPath); Assertions.assertThatThrownBy(() -> userSystem.start()) .hasMessage(expectedMessage); }
@Override public void start() { final String usersFile = System.getProperty(USERS_FILE); if (isEmpty(usersFile)) { String msg = String.format(USERS_FILE_NOT_CONFIGURED_ERROR, USERS_FILE); throw new SimpleUserSystemServiceException(msg); } final String skillsFile = System.getProperty(SKILLS_FILE); if (isNotEmpty(skillsFile)) { LOGGER.info("Using skills configuration from: {}", skillsFile); } final String affinitiesFile = System.getProperty(AFFINITIES_FILE); if (isNotEmpty(affinitiesFile)) { LOGGER.info("Using affinities configuration from: {}", affinitiesFile); } try { this.userGroupInfo = SimpleUserSystemServiceHelper.buildInfo(Paths.get(usersFile), isNotEmpty(skillsFile) ? Paths.get(skillsFile) : null, isNotEmpty(affinitiesFile) ? Paths.get(affinitiesFile) : null); this.userById = userGroupInfo.getUsers().stream().collect(Collectors.toMap(User::getId, Function.identity())); } catch (Exception e) { String msg = String.format(USERS_INFO_LOADING_ERROR, usersFile, skillsFile, affinitiesFile); throw new SimpleUserSystemServiceException(msg, e); } }
SimpleUserSystemService implements UserSystemService { @Override public void start() { final String usersFile = System.getProperty(USERS_FILE); if (isEmpty(usersFile)) { String msg = String.format(USERS_FILE_NOT_CONFIGURED_ERROR, USERS_FILE); throw new SimpleUserSystemServiceException(msg); } final String skillsFile = System.getProperty(SKILLS_FILE); if (isNotEmpty(skillsFile)) { LOGGER.info("Using skills configuration from: {}", skillsFile); } final String affinitiesFile = System.getProperty(AFFINITIES_FILE); if (isNotEmpty(affinitiesFile)) { LOGGER.info("Using affinities configuration from: {}", affinitiesFile); } try { this.userGroupInfo = SimpleUserSystemServiceHelper.buildInfo(Paths.get(usersFile), isNotEmpty(skillsFile) ? Paths.get(skillsFile) : null, isNotEmpty(affinitiesFile) ? Paths.get(affinitiesFile) : null); this.userById = userGroupInfo.getUsers().stream().collect(Collectors.toMap(User::getId, Function.identity())); } catch (Exception e) { String msg = String.format(USERS_INFO_LOADING_ERROR, usersFile, skillsFile, affinitiesFile); throw new SimpleUserSystemServiceException(msg, e); } } }
SimpleUserSystemService implements UserSystemService { @Override public void start() { final String usersFile = System.getProperty(USERS_FILE); if (isEmpty(usersFile)) { String msg = String.format(USERS_FILE_NOT_CONFIGURED_ERROR, USERS_FILE); throw new SimpleUserSystemServiceException(msg); } final String skillsFile = System.getProperty(SKILLS_FILE); if (isNotEmpty(skillsFile)) { LOGGER.info("Using skills configuration from: {}", skillsFile); } final String affinitiesFile = System.getProperty(AFFINITIES_FILE); if (isNotEmpty(affinitiesFile)) { LOGGER.info("Using affinities configuration from: {}", affinitiesFile); } try { this.userGroupInfo = SimpleUserSystemServiceHelper.buildInfo(Paths.get(usersFile), isNotEmpty(skillsFile) ? Paths.get(skillsFile) : null, isNotEmpty(affinitiesFile) ? Paths.get(affinitiesFile) : null); this.userById = userGroupInfo.getUsers().stream().collect(Collectors.toMap(User::getId, Function.identity())); } catch (Exception e) { String msg = String.format(USERS_INFO_LOADING_ERROR, usersFile, skillsFile, affinitiesFile); throw new SimpleUserSystemServiceException(msg, e); } } SimpleUserSystemService(); }
SimpleUserSystemService implements UserSystemService { @Override public void start() { final String usersFile = System.getProperty(USERS_FILE); if (isEmpty(usersFile)) { String msg = String.format(USERS_FILE_NOT_CONFIGURED_ERROR, USERS_FILE); throw new SimpleUserSystemServiceException(msg); } final String skillsFile = System.getProperty(SKILLS_FILE); if (isNotEmpty(skillsFile)) { LOGGER.info("Using skills configuration from: {}", skillsFile); } final String affinitiesFile = System.getProperty(AFFINITIES_FILE); if (isNotEmpty(affinitiesFile)) { LOGGER.info("Using affinities configuration from: {}", affinitiesFile); } try { this.userGroupInfo = SimpleUserSystemServiceHelper.buildInfo(Paths.get(usersFile), isNotEmpty(skillsFile) ? Paths.get(skillsFile) : null, isNotEmpty(affinitiesFile) ? Paths.get(affinitiesFile) : null); this.userById = userGroupInfo.getUsers().stream().collect(Collectors.toMap(User::getId, Function.identity())); } catch (Exception e) { String msg = String.format(USERS_INFO_LOADING_ERROR, usersFile, skillsFile, affinitiesFile); throw new SimpleUserSystemServiceException(msg, e); } } SimpleUserSystemService(); @Override void start(); @Override String getName(); @Override List<User> findAllUsers(); List<Group> findAllGroups(); @Override void test(); @Override User findUser(String id); }
SimpleUserSystemService implements UserSystemService { @Override public void start() { final String usersFile = System.getProperty(USERS_FILE); if (isEmpty(usersFile)) { String msg = String.format(USERS_FILE_NOT_CONFIGURED_ERROR, USERS_FILE); throw new SimpleUserSystemServiceException(msg); } final String skillsFile = System.getProperty(SKILLS_FILE); if (isNotEmpty(skillsFile)) { LOGGER.info("Using skills configuration from: {}", skillsFile); } final String affinitiesFile = System.getProperty(AFFINITIES_FILE); if (isNotEmpty(affinitiesFile)) { LOGGER.info("Using affinities configuration from: {}", affinitiesFile); } try { this.userGroupInfo = SimpleUserSystemServiceHelper.buildInfo(Paths.get(usersFile), isNotEmpty(skillsFile) ? Paths.get(skillsFile) : null, isNotEmpty(affinitiesFile) ? Paths.get(affinitiesFile) : null); this.userById = userGroupInfo.getUsers().stream().collect(Collectors.toMap(User::getId, Function.identity())); } catch (Exception e) { String msg = String.format(USERS_INFO_LOADING_ERROR, usersFile, skillsFile, affinitiesFile); throw new SimpleUserSystemServiceException(msg, e); } } SimpleUserSystemService(); @Override void start(); @Override String getName(); @Override List<User> findAllUsers(); List<Group> findAllGroups(); @Override void test(); @Override User findUser(String id); static final String USERS_FILE; static final String SKILLS_FILE; static final String AFFINITIES_FILE; static final String NAME; }