@Test public void shouldThrowOnLoadIfNoFileSpecified() { IllegalArgumentException caughtException = null; try { plugin.load(new HashMap<>()); } catch (IllegalArgumentException ex) { caughtException = ex; } assertNotNull("caught IllegalArgumentException", caughtException); assertTrue("caughtException should mention 'Missing parameter'", caughtException.getMessage().contains("Missing parameter")); }
@Override public void load(Map<String, Object> parameters) { String filePath; if ((filePath = (String) parameters.get(FILE_PARAM)) == null) { throw new IllegalArgumentException("Missing parameter [" + FILE_PARAM + "] in the configuration"); } try (Stream<String> stream = Files.lines(Paths.get(filePath))) { stream.forEach(whitelist::add); } catch (IOException e) { throw new IllegalArgumentException(String.format("Unable to read the file \"%s\"", filePath), e); } }
UserWhiteListPlugin implements IAuthorizationPlugin { @Override public void load(Map<String, Object> parameters) { String filePath; if ((filePath = (String) parameters.get(FILE_PARAM)) == null) { throw new IllegalArgumentException("Missing parameter [" + FILE_PARAM + "] in the configuration"); } try (Stream<String> stream = Files.lines(Paths.get(filePath))) { stream.forEach(whitelist::add); } catch (IOException e) { throw new IllegalArgumentException(String.format("Unable to read the file \"%s\"", filePath), e); } } }
UserWhiteListPlugin implements IAuthorizationPlugin { @Override public void load(Map<String, Object> parameters) { String filePath; if ((filePath = (String) parameters.get(FILE_PARAM)) == null) { throw new IllegalArgumentException("Missing parameter [" + FILE_PARAM + "] in the configuration"); } try (Stream<String> stream = Files.lines(Paths.get(filePath))) { stream.forEach(whitelist::add); } catch (IOException e) { throw new IllegalArgumentException(String.format("Unable to read the file \"%s\"", filePath), e); } }  }
UserWhiteListPlugin implements IAuthorizationPlugin { @Override public void load(Map<String, Object> parameters) { String filePath; if ((filePath = (String) parameters.get(FILE_PARAM)) == null) { throw new IllegalArgumentException("Missing parameter [" + FILE_PARAM + "] in the configuration"); } try (Stream<String> stream = Files.lines(Paths.get(filePath))) { stream.forEach(whitelist::add); } catch (IOException e) { throw new IllegalArgumentException(String.format("Unable to read the file \"%s\"", filePath), e); } }  @Override void load(Map<String, Object> parameters); @Override void unload(); @Override boolean isAllowed(HttpServletRequest request, Project project); @Override boolean isAllowed(HttpServletRequest request, Group group); }
UserWhiteListPlugin implements IAuthorizationPlugin { @Override public void load(Map<String, Object> parameters) { String filePath; if ((filePath = (String) parameters.get(FILE_PARAM)) == null) { throw new IllegalArgumentException("Missing parameter [" + FILE_PARAM + "] in the configuration"); } try (Stream<String> stream = Files.lines(Paths.get(filePath))) { stream.forEach(whitelist::add); } catch (IOException e) { throw new IllegalArgumentException(String.format("Unable to read the file \"%s\"", filePath), e); } }  @Override void load(Map<String, Object> parameters); @Override void unload(); @Override boolean isAllowed(HttpServletRequest request, Project project); @Override boolean isAllowed(HttpServletRequest request, Group group);  }