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());
}
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()));
}
Aggregations