MavenScmUtil { public static Optional<String> calcProviderName(MavenProject project) { String providerName = null; Scm scm = project.getScm(); if (scm != null) { String connection = StringUtils.trimToNull(scm.getDeveloperConnection()); connection = connection != null ? connection : StringUtils.trimToNull(scm.getConnection()); if (connection != null) { connection = connection.substring(4); int nextPipe = connection.indexOf('|'); if (nextPipe > -1) { connection = connection.substring(0, nextPipe); } int nextColon = connection.indexOf(':'); if (nextColon > -1) { providerName = connection.substring(0, nextColon); } else { providerName = connection; } } } return Optional.fromNullable(providerName); } private  MavenScmUtil(); static Optional<String> calcProviderName(MavenProject project);  }
@Test @UseDataProvider("calcProviderName") public void testCalcProviderName(String devConnection, String connection, String expectedProviderName) { MavenProject p = new MavenProject(); p.setScm(new Scm()); p.getScm().setDeveloperConnection(devConnection); p.getScm().setConnection(connection); Optional<String> providerName = MavenScmUtil.calcProviderName(p); if (expectedProviderName == null) { Assert.assertFalse(providerName.isPresent()); } else { Assert.assertTrue(providerName.isPresent()); Assert.assertEquals(expectedProviderName, providerName.get()); } }