use of org.guvnor.ala.build.maven.config.impl.MavenDependencyConfigImpl in project kie-wb-common by kiegroup.
the class MavenDependencyConfigExecutorTest method testMavenDependencyAPI.
@Test
public void testMavenDependencyAPI() throws Exception {
final String groupId = "org.guvnor.ala";
final String artifactId = "maven-ala-artifact-test";
final String version = "1";
final String artifactPath = "/org/guvnor/ala/maven-ala-artifact-test/1/maven-ala-artifact-test-1.pom";
final String oldSettingsXmlPath = System.getProperty(CUSTOM_SETTINGS_PROPERTY);
try {
final Path settingsXmlPath = generateSettingsXml();
System.setProperty(CUSTOM_SETTINGS_PROPERTY, settingsXmlPath.toString());
MavenSettings.reinitSettings();
installArtifactLocally(groupId, artifactId, version);
final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Maven Artifact", new MavenDependencyConfigImpl()).buildAs("my pipe");
final PipelineExecutor executor = new PipelineExecutor(singletonList(new MavenDependencyConfigExecutor(buildRegistry)));
executor.execute(new Input() {
{
put("artifact", groupId + ":" + artifactId + ":pom:" + version);
}
}, pipe, System.out::println);
final List<Binary> allBinaries = buildRegistry.getAllBinaries();
assertNotNull(allBinaries);
assertEquals(1, allBinaries.size());
assertTrue(allBinaries.get(0) instanceof MavenBinary);
final MavenBinary binary = (MavenBinary) allBinaries.get(0);
assertEquals("Maven", binary.getType());
assertEquals(artifactId, binary.getName());
assertEquals(groupId, binary.getGroupId());
assertEquals(artifactId, binary.getArtifactId());
assertEquals(version, binary.getVersion());
assertEquals(Paths.get(m2Folder.getPath(), artifactPath).toString(), binary.getPath().toString());
} finally {
if (oldSettingsXmlPath == null) {
System.clearProperty(CUSTOM_SETTINGS_PROPERTY);
} else {
System.setProperty(CUSTOM_SETTINGS_PROPERTY, oldSettingsXmlPath);
}
MavenSettings.reinitSettings();
}
}
Aggregations