use of org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method mockBuildResult.
private BuildResult mockBuildResult(boolean withSshCredentials) {
BuildResult result = mock(BuildResult.class);
BuildDriverResult driverResult = mock(BuildDriverResult.class);
when(driverResult.getBuildStatus()).thenReturn(BuildStatus.FAILED);
when(result.getBuildDriverResult()).thenReturn(Optional.of(driverResult));
RepositoryManagerResult repoManagerResult = mock(RepositoryManagerResult.class);
when(repoManagerResult.getCompletionStatus()).thenReturn(CompletionStatus.SUCCESS);
when(result.getRepositoryManagerResult()).thenReturn(Optional.of(repoManagerResult));
when(result.getBuildExecutionConfiguration()).thenReturn(Optional.of(mock(BuildExecutionConfiguration.class)));
return result;
}
use of org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult in project pnc by project-ncl.
the class DatastoreAdapterTest method storeResult.
private void storeResult(DatastoreAdapter datastoreAdapter, BuildStatus buildStatus, CompletionStatus completionStatus) throws DatastoreException {
BuildDriverResult buildDriverResult = mock(BuildDriverResult.class);
when(buildDriverResult.getBuildStatus()).thenReturn(buildStatus);
when(buildDriverResult.getBuildLog()).thenReturn(BUILD_LOG);
RepositoryManagerResult repositoryManagerResult = mock(RepositoryManagerResult.class);
when(repositoryManagerResult.getCompletionStatus()).thenReturn(completionStatus);
when(repositoryManagerResult.getLog()).thenReturn(REPOSITORY_MANAGER_LOG);
BuildExecutionConfiguration buildExecutionConfiguration = mock(BuildExecutionConfiguration.class);
BuildResult buildResult = new BuildResult(CompletionStatus.SUCCESS, Optional.empty(), "", Optional.of(buildExecutionConfiguration), Optional.of(buildDriverResult), Optional.of(repositoryManagerResult), Optional.of(EnvironmentDriverResultMock.mock()), Optional.of(RepourResultMock.mock()));
BuildTask buildTask = mockBuildTask();
datastoreAdapter.storeResult(buildTask, buildResult);
}
use of org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult in project pnc by project-ncl.
the class BuildExecutionTest method testBuild.
@Test
public void testBuild() throws ExecutorException, TimeoutException, InterruptedException, BuildDriverException {
BuildConfiguration buildConfiguration = configurationBuilder.build(1, "c1-java");
Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper);
List<BuildExecutionStatus> expectedStatuses = getBuildExecutionStatusesSuccess();
// check build statuses
checkBuildStatuses(statusChangedEvents, expectedStatuses);
// check results
BuildResult buildResult = buildExecutionResultWrapper.get();
// check results: logs
BuildDriverResult buildDriverResult = buildResult.getBuildDriverResult().get();
String buildLog = buildDriverResult.getBuildLog();
Assert.assertTrue("Invalid build log.", buildLog.contains("Finished: SUCCESS"));
// check results: artifacts
RepositoryManagerResult repositoryManagerResult = buildResult.getRepositoryManagerResult().get();
Assert.assertTrue("Missing build artifacts.", repositoryManagerResult.getBuiltArtifacts().size() > 0);
Assert.assertTrue("Missing build dependencies.", repositoryManagerResult.getDependencies().size() > 0);
Artifact artifact = repositoryManagerResult.getBuiltArtifacts().iterator().next();
Assert.assertTrue("Invalid built artifact in the result.", artifact.getIdentifier().startsWith(ArtifactBuilder.IDENTIFIER_PREFIX));
}
use of org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult in project pnc by project-ncl.
the class BuildResultMapper method toDTO.
public BuildResultRest toDTO(BuildResult buildResult) {
CompletionStatus completionStatus = buildResult.getCompletionStatus();
ProcessException processException = buildResult.getProcessException().orElse(null);
String processLog = buildResult.getProcessLog();
BuildExecutionConfigurationRest buildExecutionConfiguration;
if (buildResult.getBuildExecutionConfiguration().isPresent()) {
BuildExecutionConfiguration bec = buildResult.getBuildExecutionConfiguration().get();
buildExecutionConfiguration = new BuildExecutionConfigurationRest(bec);
} else {
buildExecutionConfiguration = null;
}
BuildDriverResultRest buildDriverResult;
if (buildResult.getBuildDriverResult().isPresent()) {
BuildDriverResult result = buildResult.getBuildDriverResult().get();
buildDriverResult = new BuildDriverResultRest(result);
} else {
buildDriverResult = null;
}
RepositoryManagerResultRest repositoryManagerResult;
if (buildResult.getRepositoryManagerResult().isPresent()) {
RepositoryManagerResult result = buildResult.getRepositoryManagerResult().get();
repositoryManagerResult = repositoryManagerResultMapper.toDTO(result);
} else {
repositoryManagerResult = null;
}
EnvironmentDriverResult environmentDriverResult;
if (buildResult.getEnvironmentDriverResult().isPresent()) {
environmentDriverResult = buildResult.getEnvironmentDriverResult().get();
} else {
environmentDriverResult = null;
}
RepourResult repourResult = buildResult.getRepourResult().orElse(null);
return new BuildResultRest(completionStatus, processException, processLog, buildExecutionConfiguration, buildDriverResult, repositoryManagerResult, environmentDriverResult, repourResult);
}
use of org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult in project pnc by project-ncl.
the class RepositoryManagerResultMapper method toEntity.
public RepositoryManagerResult toEntity(RepositoryManagerResultRest dto) {
List<org.jboss.pnc.model.Artifact> builtArtifacts = dto.getBuiltArtifacts().stream().map(artifactRest -> artifactMapper.toEntityWithTransientTargetRepository(artifactRest)).collect(Collectors.toList());
List<org.jboss.pnc.model.Artifact> dependencies = dto.getDependencies().stream().map(artifactRest -> artifactMapper.toEntityWithTransientTargetRepository(artifactRest)).collect(Collectors.toList());
String buildContentId = dto.getBuildContentId();
String log = dto.getLog();
CompletionStatus completionStatus = dto.getCompletionStatus();
return new GenericRepositoryManagerResult(builtArtifacts, dependencies, buildContentId, log, completionStatus);
}
Aggregations