use of org.jboss.pnc.bpm.model.RepositoryManagerResultRest 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.bpm.model.RepositoryManagerResultRest 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);
}
use of org.jboss.pnc.bpm.model.RepositoryManagerResultRest in project pnc by project-ncl.
the class RepositoryManagerResultSerializationTest method serializeAndDeserializeRepositoryManagerResult.
@Test
public void serializeAndDeserializeRepositoryManagerResult() throws IOException {
RepositoryManagerResult repoMngrResult = RepositoryManagerResultMock.mockResult();
RepositoryManagerResultRest repoMngrResultRest = repositoryManagerResultMapper.toDTO(repoMngrResult);
String repoMngrResultJson = JsonOutputConverterMapper.apply(repoMngrResultRest);
log.debug("RepoManagerResultJson : {}", repoMngrResultJson);
RepositoryManagerResultRest deserializedRepoManResultRest = JsonOutputConverterMapper.readValue(repoMngrResultJson, RepositoryManagerResultRest.class);
RepositoryManagerResult deserializedRepoMngrResult = repositoryManagerResultMapper.toEntity(deserializedRepoManResultRest);
String message = "Deserialized object does not match the original.";
Assert.assertEquals(message, repoMngrResult.getBuildContentId(), deserializedRepoMngrResult.getBuildContentId());
Assert.assertEquals(message, repoMngrResult.getBuiltArtifacts().get(0), deserializedRepoMngrResult.getBuiltArtifacts().get(0));
Assert.assertEquals(message, repoMngrResult.getBuiltArtifacts().get(0).getSha256(), deserializedRepoMngrResult.getBuiltArtifacts().get(0).getSha256());
Assert.assertEquals(message, repoMngrResult.getBuiltArtifacts().get(0).isBuilt(), deserializedRepoMngrResult.getBuiltArtifacts().get(0).isBuilt());
Assert.assertEquals(message, repoMngrResult.getDependencies().get(0), deserializedRepoMngrResult.getDependencies().get(0));
Assert.assertEquals(message, repoMngrResult.getDependencies().get(0).getDeployPath(), deserializedRepoMngrResult.getDependencies().get(0).getDeployPath());
Assert.assertEquals(message, repoMngrResult.getDependencies().get(0).isImported(), deserializedRepoMngrResult.getDependencies().get(0).isImported());
}
use of org.jboss.pnc.bpm.model.RepositoryManagerResultRest in project pnc by project-ncl.
the class RepositoryManagerResultMapper method toDTO.
public RepositoryManagerResultRest toDTO(RepositoryManagerResult entity) {
List<Artifact> builtArtifacts = entity.getBuiltArtifacts().stream().map(artifact -> artifactMapper.toDTO(artifact)).collect(Collectors.toList());
List<Artifact> dependencies = entity.getDependencies().stream().map(artifact -> artifactMapper.toDTO(artifact)).collect(Collectors.toList());
String buildContentId = entity.getBuildContentId();
String log = entity.getLog();
CompletionStatus completionStatus = entity.getCompletionStatus();
return new RepositoryManagerResultRest(builtArtifacts, dependencies, buildContentId, log, completionStatus);
}
Aggregations