Search in sources :

Example 1 with RepositoryManagerResult

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;
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)

Example 2 with RepositoryManagerResult

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);
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)

Example 3 with RepositoryManagerResult

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));
}
Also used : BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult) BuildExecutionStatus(org.jboss.pnc.enums.BuildExecutionStatus) Artifact(org.jboss.pnc.model.Artifact) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildResult(org.jboss.pnc.spi.BuildResult) ObjectWrapper(org.jboss.pnc.common.util.ObjectWrapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with RepositoryManagerResult

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);
}
Also used : BuildResultRest(org.jboss.pnc.bpm.model.BuildResultRest) ProcessException(org.jboss.pnc.spi.coordinator.ProcessException) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) RepositoryManagerResultRest(org.jboss.pnc.bpm.model.RepositoryManagerResultRest) EnvironmentDriverResult(org.jboss.pnc.spi.environment.EnvironmentDriverResult) CompletionStatus(org.jboss.pnc.spi.coordinator.CompletionStatus) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult) BuildExecutionConfigurationRest(org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest) RepourResult(org.jboss.pnc.spi.repour.RepourResult) BuildDriverResultRest(org.jboss.pnc.bpm.model.BuildDriverResultRest)

Example 5 with RepositoryManagerResult

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);
}
Also used : Inject(javax.inject.Inject) GenericRepositoryManagerResult(org.jboss.pnc.bpm.model.RepositoryManagerResultRest.GenericRepositoryManagerResult) List(java.util.List) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult) RepositoryManagerResultRest(org.jboss.pnc.bpm.model.RepositoryManagerResultRest) CompletionStatus(org.jboss.pnc.spi.coordinator.CompletionStatus) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Artifact(org.jboss.pnc.dto.Artifact) ArtifactMapper(org.jboss.pnc.mapper.api.ArtifactMapper) Collectors(java.util.stream.Collectors) CompletionStatus(org.jboss.pnc.spi.coordinator.CompletionStatus) GenericRepositoryManagerResult(org.jboss.pnc.bpm.model.RepositoryManagerResultRest.GenericRepositoryManagerResult) Artifact(org.jboss.pnc.dto.Artifact)

Aggregations

RepositoryManagerResult (org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)27 Artifact (org.jboss.pnc.model.Artifact)14 RepositorySession (org.jboss.pnc.spi.repositorymanager.model.RepositorySession)14 Test (org.junit.Test)14 TestBuildExecution (org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution)12 BuildExecution (org.jboss.pnc.spi.repositorymanager.BuildExecution)11 ContainerTest (org.jboss.pnc.test.category.ContainerTest)11 StoreKey (org.commonjava.indy.model.core.StoreKey)9 BuildDriverResult (org.jboss.pnc.spi.builddriver.BuildDriverResult)7 File (java.io.File)6 CompletionStatus (org.jboss.pnc.spi.coordinator.CompletionStatus)6 SimpleArtifactRef (org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef)5 BuildResult (org.jboss.pnc.spi.BuildResult)5 BuildExecutionConfiguration (org.jboss.pnc.spi.executor.BuildExecutionConfiguration)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 HashSet (java.util.HashSet)4 ProjectVersionRef (org.commonjava.atlas.maven.ident.ref.ProjectVersionRef)4 SimpleProjectVersionRef (org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef)4 Indy (org.commonjava.indy.client.core.Indy)4 IndyFoloContentClientModule (org.commonjava.indy.folo.client.IndyFoloContentClientModule)4