### Question:
DataSourceUtil { @Nonnull public static Optional<List<String>> getPaths(@Nonnull final DataSource dataSource) { List<String> paths = new ArrayList<>(); if (dataSource.getTemplate() != null && dataSource.getTemplate().getOptions() != null && dataSource.getTemplate().getOptions().get("path") != null) { paths.add(dataSource.getTemplate().getOptions().get("path")); } else { Optional.of(dataSource).map(DataSource::getConnector).map(Connector::getTemplate).map(DataSetTemplate::getOptions).map(options -> options.get("path")).ifPresent(paths::add); } if (dataSource.getTemplate() != null && dataSource.getTemplate().getPaths() != null) { paths.addAll(dataSource.getTemplate().getPaths()); } else if (dataSource.getConnector() != null && dataSource.getConnector().getTemplate() != null && dataSource.getConnector().getTemplate().getPaths() != null) { paths.addAll(dataSource.getConnector().getTemplate().getPaths()); } else if (paths.isEmpty()) { paths = null; } return Optional.ofNullable(paths); } private  DataSourceUtil(); @Nonnull static Optional<List<String>> getPaths(@Nonnull final DataSource dataSource); @Nonnull static DefaultDataSetTemplate mergeTemplates(@Nonnull final DataSource dataSource);  }### Answer:
@Test public void getPaths() { final DefaultDataSetTemplate connectorTemplate = new DefaultDataSetTemplate(); connectorTemplate.setOptions(Collections.singletonMap("path", "connector1.txt")); connectorTemplate.setPaths(Collections.singletonList("connector2.txt")); final Connector connector = new Connector(); connector.setTemplate(connectorTemplate); final DefaultDataSetTemplate dataSourceTemplate = new DefaultDataSetTemplate(); dataSourceTemplate.setOptions(Collections.singletonMap("path", "datasource1.txt")); dataSourceTemplate.setPaths(Collections.singletonList("datasource2.txt")); final DataSource dataSource = new DataSource(); dataSource.setConnector(connector); dataSource.setTemplate(dataSourceTemplate); Assert.assertEquals(Arrays.asList("datasource1.txt", "datasource2.txt"), DataSourceUtil.getPaths(dataSource).orElse(null)); dataSourceTemplate.setOptions(null); Assert.assertEquals(Arrays.asList("connector1.txt", "datasource2.txt"), DataSourceUtil.getPaths(dataSource).orElse(null)); dataSourceTemplate.setPaths(null); Assert.assertEquals(Arrays.asList("connector1.txt", "connector2.txt"), DataSourceUtil.getPaths(dataSource).orElse(null)); connectorTemplate.setOptions(null); connectorTemplate.setPaths(null); Assert.assertEquals(Optional.empty(), DataSourceUtil.getPaths(dataSource)); }