@Test public void testWhenPropertyIsMissingShouldDisableSecurity() { given(propertyHolder.get(WILMA_ADMIN_HOSTS_FILE)).willReturn(null); underTest.parseFile(); verify(wilmaAdminHostsDTO).setSecurityEnabled(false); }
public void parseFile() { String filePath = propertyHolder.get(WILMA_ADMIN_HOSTS_FILE); List<String> wilmaAdminHosts = new ArrayList<>(); boolean securityEnabled = !"".equals(filePath) && filePath != null; if (securityEnabled) { try (BufferedReader bufferedReader = bufferedReaderFactory.createBufferedReaderFromFilePath(filePath)) { while (bufferedReader.ready()) { String host = bufferedReader.readLine(); wilmaAdminHosts.add(host); } } catch (IOException e) { throw new CannotParseExternalResourceException(String.format(ERROR_TEMPLATE, filePath), e); } } wilmaAdminHostsDTO.setWilmaAdminHosts(wilmaAdminHosts); wilmaAdminHostsDTO.setSecurityEnabled(securityEnabled); }
WilmaAdminHostsFileParser { public void parseFile() { String filePath = propertyHolder.get(WILMA_ADMIN_HOSTS_FILE); List<String> wilmaAdminHosts = new ArrayList<>(); boolean securityEnabled = !"".equals(filePath) && filePath != null; if (securityEnabled) { try (BufferedReader bufferedReader = bufferedReaderFactory.createBufferedReaderFromFilePath(filePath)) { while (bufferedReader.ready()) { String host = bufferedReader.readLine(); wilmaAdminHosts.add(host); } } catch (IOException e) { throw new CannotParseExternalResourceException(String.format(ERROR_TEMPLATE, filePath), e); } } wilmaAdminHostsDTO.setWilmaAdminHosts(wilmaAdminHosts); wilmaAdminHostsDTO.setSecurityEnabled(securityEnabled); } }
WilmaAdminHostsFileParser { public void parseFile() { String filePath = propertyHolder.get(WILMA_ADMIN_HOSTS_FILE); List<String> wilmaAdminHosts = new ArrayList<>(); boolean securityEnabled = !"".equals(filePath) && filePath != null; if (securityEnabled) { try (BufferedReader bufferedReader = bufferedReaderFactory.createBufferedReaderFromFilePath(filePath)) { while (bufferedReader.ready()) { String host = bufferedReader.readLine(); wilmaAdminHosts.add(host); } } catch (IOException e) { throw new CannotParseExternalResourceException(String.format(ERROR_TEMPLATE, filePath), e); } } wilmaAdminHostsDTO.setWilmaAdminHosts(wilmaAdminHosts); wilmaAdminHostsDTO.setSecurityEnabled(securityEnabled); }  }
WilmaAdminHostsFileParser { public void parseFile() { String filePath = propertyHolder.get(WILMA_ADMIN_HOSTS_FILE); List<String> wilmaAdminHosts = new ArrayList<>(); boolean securityEnabled = !"".equals(filePath) && filePath != null; if (securityEnabled) { try (BufferedReader bufferedReader = bufferedReaderFactory.createBufferedReaderFromFilePath(filePath)) { while (bufferedReader.ready()) { String host = bufferedReader.readLine(); wilmaAdminHosts.add(host); } } catch (IOException e) { throw new CannotParseExternalResourceException(String.format(ERROR_TEMPLATE, filePath), e); } } wilmaAdminHostsDTO.setWilmaAdminHosts(wilmaAdminHosts); wilmaAdminHostsDTO.setSecurityEnabled(securityEnabled); }  void parseFile(); }
WilmaAdminHostsFileParser { public void parseFile() { String filePath = propertyHolder.get(WILMA_ADMIN_HOSTS_FILE); List<String> wilmaAdminHosts = new ArrayList<>(); boolean securityEnabled = !"".equals(filePath) && filePath != null; if (securityEnabled) { try (BufferedReader bufferedReader = bufferedReaderFactory.createBufferedReaderFromFilePath(filePath)) { while (bufferedReader.ready()) { String host = bufferedReader.readLine(); wilmaAdminHosts.add(host); } } catch (IOException e) { throw new CannotParseExternalResourceException(String.format(ERROR_TEMPLATE, filePath), e); } } wilmaAdminHostsDTO.setWilmaAdminHosts(wilmaAdminHosts); wilmaAdminHostsDTO.setSecurityEnabled(securityEnabled); }  void parseFile();  }