Search in sources :

Example 21 with BuildResult

use of org.jboss.pnc.spi.BuildResult in project pnc by project-ncl.

the class DefaultBuildCoordinatorTest method shouldStoreSshCredentialsOnSshEnabled.

@Test
public void shouldStoreSshCredentialsOnSshEnabled() throws DatastoreException {
    BuildTask buildTask = mockBuildTask();
    BuildResult buildResult = mockBuildResult(true);
    SshCredentials sshCredentials = new SshCredentials();
    sshCredentials.setCommand(RandomStringUtils.randomAlphabetic(30));
    sshCredentials.setPassword(RandomStringUtils.randomAlphabetic(30));
    when(buildResult.getEnvironmentDriverResult()).thenReturn(Optional.of(new EnvironmentDriverResult(CompletionStatus.FAILED, "", Optional.of(sshCredentials))));
    when(buildResult.getRepourResult()).thenReturn(Optional.of(RepourResultMock.mock()));
    ArgumentGrabbingAnswer<BuildRecord.Builder> answer = new ArgumentGrabbingAnswer<>(BuildRecord.Builder.class);
    when(datastore.storeCompletedBuild(any(BuildRecord.Builder.class), any(), any())).thenAnswer(answer);
    coordinator.completeBuild(buildTask, buildResult);
    assertThat(answer.arguments).hasSize(1);
    BuildRecord.Builder builder = answer.arguments.iterator().next();
    BuildRecord record = builder.build();
    assertThat(record.getSshCommand()).isEqualTo(sshCredentials.getCommand());
    assertThat(record.getSshPassword()).isEqualTo(sshCredentials.getPassword());
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) SshCredentials(org.jboss.pnc.spi.SshCredentials) EnvironmentDriverResult(org.jboss.pnc.spi.environment.EnvironmentDriverResult) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Example 22 with BuildResult

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

Aggregations

BuildResult (org.jboss.pnc.spi.BuildResult)22 BuildExecutionStatusChangedEvent (org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)11 ExecutorException (org.jboss.pnc.spi.executor.exceptions.ExecutorException)10 Test (org.junit.Test)10 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)9 ObjectWrapper (org.jboss.pnc.common.util.ObjectWrapper)8 HashSet (java.util.HashSet)7 BuildExecutionConfiguration (org.jboss.pnc.spi.executor.BuildExecutionConfiguration)7 BuildExecutionStatus (org.jboss.pnc.enums.BuildExecutionStatus)6 BuildDriverResult (org.jboss.pnc.spi.builddriver.BuildDriverResult)6 Consumer (java.util.function.Consumer)5 Inject (javax.inject.Inject)5 RepositoryManagerResult (org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 Set (java.util.Set)4 Configuration (org.jboss.pnc.common.Configuration)4 BuildDriverFactory (org.jboss.pnc.executor.servicefactories.BuildDriverFactory)4 EnvironmentDriverFactory (org.jboss.pnc.executor.servicefactories.EnvironmentDriverFactory)4 RepositoryManagerFactory (org.jboss.pnc.executor.servicefactories.RepositoryManagerFactory)4