@Test @DisplayName("Parses sample settings.xml correctly") public void parsesSampleSettingsCorrectly() throws Exception { List<ServerCredentials> credentials = new ArrayList<>(); List<Repository> repositories = new ArrayList<>(); new MavenSettingsXmlParser(sampleSettingsFile, credentials::add, repositories::add).parse(); Optional<ServerCredentials> server1 = credentials.stream().filter((s) -> s.id.equals("server1")).findFirst(); assertTrue(server1.isPresent(), "server1 not found"); assertEquals("server1", server1.get().id); assertEquals("abc", server1.get().username); assertEquals("def", server1.get().password); Optional<ServerCredentials> central = credentials.stream().filter((s) -> s.id.equals("central")).findFirst(); assertTrue(central.isPresent(), "central not found"); assertEquals("central", central.get().id); assertEquals("123", central.get().username); assertEquals("456", central.get().password); assertEquals(2, credentials.size(), "two credentials should be in list"); }
public void parse() throws XMLStreamException, IOException { if (!isRegularFile(settingsXmlFile)) throw new IllegalArgumentException(format("'%s' not found. Please specify correct path to Maven's settings.xml!", settingsXmlFile)); try (InputStream in = newInputStream(settingsXmlFile)) { readSettingsXml(new BufferedInputStream(in)); } }
MavenSettingsXmlParser { public void parse() throws XMLStreamException, IOException { if (!isRegularFile(settingsXmlFile)) throw new IllegalArgumentException(format("'%s' not found. Please specify correct path to Maven's settings.xml!", settingsXmlFile)); try (InputStream in = newInputStream(settingsXmlFile)) { readSettingsXml(new BufferedInputStream(in)); } } }
MavenSettingsXmlParser { public void parse() throws XMLStreamException, IOException { if (!isRegularFile(settingsXmlFile)) throw new IllegalArgumentException(format("'%s' not found. Please specify correct path to Maven's settings.xml!", settingsXmlFile)); try (InputStream in = newInputStream(settingsXmlFile)) { readSettingsXml(new BufferedInputStream(in)); } } MavenSettingsXmlParser(Path settingsXmlFile, ServerCredentialsHandler credentialsHandler, RepositoryHandler repositoryHandler); }
MavenSettingsXmlParser { public void parse() throws XMLStreamException, IOException { if (!isRegularFile(settingsXmlFile)) throw new IllegalArgumentException(format("'%s' not found. Please specify correct path to Maven's settings.xml!", settingsXmlFile)); try (InputStream in = newInputStream(settingsXmlFile)) { readSettingsXml(new BufferedInputStream(in)); } } MavenSettingsXmlParser(Path settingsXmlFile, ServerCredentialsHandler credentialsHandler, RepositoryHandler repositoryHandler); void parse(); }
MavenSettingsXmlParser { public void parse() throws XMLStreamException, IOException { if (!isRegularFile(settingsXmlFile)) throw new IllegalArgumentException(format("'%s' not found. Please specify correct path to Maven's settings.xml!", settingsXmlFile)); try (InputStream in = newInputStream(settingsXmlFile)) { readSettingsXml(new BufferedInputStream(in)); } } MavenSettingsXmlParser(Path settingsXmlFile, ServerCredentialsHandler credentialsHandler, RepositoryHandler repositoryHandler); void parse();  }