use of org.jboss.pnc.spi.executor.BuildExecutionConfiguration in project pnc by project-ncl.
the class BuildExecutionConfigurationTest method serializeAndDeserializeBuildResult.
@Test
public void serializeAndDeserializeBuildResult() throws IOException, BuildDriverException {
BuildExecutionConfiguration buildExecutionConfiguration = BuildExecutionConfiguration.build("1", "condent-id", "1", "mvn clean install", "configuration name", "12", "https://pathToRepo.git", "f18de64523d5054395d82e24d4e28473a05a3880", "1.0.0.Final-redhat-00001", "https://pathToOriginRepo.git", false, "abcd1234", "image.repo.url/repo", SystemImageType.DOCKER_IMAGE, BuildType.MVN, false, null, new HashMap<>(), false, null, false, "-DdependencySource=REST -DrepoRemovalBackup=repositories-backup.xml -DversionSuffixStrip= -DreportNonAligned=true", AlignmentPreference.PREFER_PERSISTENT);
BuildExecutionConfigurationRest buildExecutionConfigurationREST = new BuildExecutionConfigurationRest(buildExecutionConfiguration);
String buildExecutionConfigurationJson = buildExecutionConfigurationREST.toString();
log.debug("Json : {}", buildExecutionConfigurationJson);
BuildExecutionConfigurationRest buildExecutionConfigurationRestFromJson = JsonOutputConverterMapper.readValue(buildExecutionConfigurationJson, BuildExecutionConfigurationRest.class);
BuildExecutionConfiguration buildExecutionConfigurationFromJson = buildExecutionConfigurationRestFromJson.toBuildExecutionConfiguration();
String message = "Deserialized object does not match the original.";
Assert.assertEquals(message, buildExecutionConfiguration.getId(), buildExecutionConfigurationFromJson.getId());
Assert.assertEquals(message, buildExecutionConfiguration.getBuildScript(), buildExecutionConfigurationFromJson.getBuildScript());
Assert.assertEquals(message, buildExecutionConfiguration.getName(), buildExecutionConfigurationFromJson.getName());
Assert.assertEquals(message, buildExecutionConfiguration.getScmRepoURL(), buildExecutionConfigurationFromJson.getScmRepoURL());
Assert.assertEquals(message, buildExecutionConfiguration.getScmRevision(), buildExecutionConfigurationFromJson.getScmRevision());
Assert.assertEquals(message, buildExecutionConfiguration.getScmTag(), buildExecutionConfigurationFromJson.getScmTag());
Assert.assertEquals(message, buildExecutionConfiguration.getOriginRepoURL(), buildExecutionConfigurationFromJson.getOriginRepoURL());
Assert.assertEquals(message, buildExecutionConfiguration.isPreBuildSyncEnabled(), buildExecutionConfigurationFromJson.isPreBuildSyncEnabled());
Assert.assertEquals(message, buildExecutionConfiguration.getUserId(), buildExecutionConfigurationFromJson.getUserId());
}
use of org.jboss.pnc.spi.executor.BuildExecutionConfiguration in project pnc by project-ncl.
the class ComponentBuildParametersSerialization method shouldSerializeParameters.
@Test
public void shouldSerializeParameters() throws JsonProcessingException {
BuildExecutionConfiguration buildExecutionConfiguration = BuildExecutionConfigurationMock.mock();
BuildExecutionConfigurationRest buildExecutionConfigurationRest = new BuildExecutionConfigurationRest(buildExecutionConfiguration);
ComponentBuildParameters processParameters = new ComponentBuildParameters("http://pncBaseUrl", "http://aproxBaseUrl", "http://repourBaseUrl", "http://daBaseUrl", false, true, buildExecutionConfigurationRest);
String string = MAPPER.writeValueAsString(processParameters);
log.debug("Serialized: {}", string);
Assert.assertTrue(string.contains(BuildExecutionConfigurationMock.DEFAULT_SYSTEM_IMAGE_ID));
}
use of org.jboss.pnc.spi.executor.BuildExecutionConfiguration in project pnc by project-ncl.
the class BuildResultMapper method toEntity.
public BuildResult toEntity(BuildResultRest buildResultRest) {
RepositoryManagerResult repositoryManagerResult = null;
if (buildResultRest.getRepositoryManagerResult() != null) {
repositoryManagerResult = repositoryManagerResultMapper.toEntity(buildResultRest.getRepositoryManagerResult());
}
BuildExecutionConfiguration bec = null;
if (buildResultRest.getBuildExecutionConfiguration() != null) {
bec = buildResultRest.getBuildExecutionConfiguration().toBuildExecutionConfiguration();
}
return new BuildResult(buildResultRest.getCompletionStatus(), ofNullable(buildResultRest.getProcessException()), buildResultRest.getProcessLog(), ofNullable(bec), ofNullable(buildResultRest.getBuildDriverResult()), ofNullable(repositoryManagerResult), ofNullable(buildResultRest.getEnvironmentDriverResult()), ofNullable(buildResultRest.getRepourResult()));
}
use of org.jboss.pnc.spi.executor.BuildExecutionConfiguration in project pnc by project-ncl.
the class BuildExecutorTriggerer method executeBuild.
public BuildExecutionSession executeBuild(BuildExecutionConfiguration buildExecutionConfig, String callbackUrl, String accessToken) throws CoreException, ExecutorException {
Consumer<BuildExecutionStatusChangedEvent> onExecutionStatusChange = (statusChangedEvent) -> {
log.debug("Received BuildExecutionStatusChangedEvent: " + statusChangedEvent);
if (statusChangedEvent.isFinal() && callbackUrl != null && !callbackUrl.isEmpty()) {
statusChangedEvent.getBuildResult().ifPresent((buildResult) -> bpmNotifier.sendBuildExecutionCompleted(callbackUrl, buildResult, accessToken));
}
};
BuildExecutionSession buildExecutionSession = buildExecutor.startBuilding(buildExecutionConfig, onExecutionStatusChange, accessToken);
return buildExecutionSession;
}
Aggregations