Search in sources :

Example 1 with RepositoryManagerResultRest

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);
}
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 2 with RepositoryManagerResultRest

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

Example 3 with RepositoryManagerResultRest

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());
}
Also used : RepositoryManagerResultRest(org.jboss.pnc.bpm.model.RepositoryManagerResultRest) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult) Test(org.junit.Test)

Example 4 with RepositoryManagerResultRest

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);
}
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) RepositoryManagerResultRest(org.jboss.pnc.bpm.model.RepositoryManagerResultRest) CompletionStatus(org.jboss.pnc.spi.coordinator.CompletionStatus) Artifact(org.jboss.pnc.dto.Artifact)

Aggregations

RepositoryManagerResultRest (org.jboss.pnc.bpm.model.RepositoryManagerResultRest)4 RepositoryManagerResult (org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)4 CompletionStatus (org.jboss.pnc.spi.coordinator.CompletionStatus)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 Inject (javax.inject.Inject)2 GenericRepositoryManagerResult (org.jboss.pnc.bpm.model.RepositoryManagerResultRest.GenericRepositoryManagerResult)2 Artifact (org.jboss.pnc.dto.Artifact)2 ArtifactMapper (org.jboss.pnc.mapper.api.ArtifactMapper)2 BuildDriverResultRest (org.jboss.pnc.bpm.model.BuildDriverResultRest)1 BuildExecutionConfigurationRest (org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest)1 BuildResultRest (org.jboss.pnc.bpm.model.BuildResultRest)1 BuildDriverResult (org.jboss.pnc.spi.builddriver.BuildDriverResult)1 ProcessException (org.jboss.pnc.spi.coordinator.ProcessException)1 EnvironmentDriverResult (org.jboss.pnc.spi.environment.EnvironmentDriverResult)1 BuildExecutionConfiguration (org.jboss.pnc.spi.executor.BuildExecutionConfiguration)1 RepourResult (org.jboss.pnc.spi.repour.RepourResult)1 Test (org.junit.Test)1