Search in sources :

Example 1 with Environment

use of org.jboss.pnc.dto.Environment in project pnc by project-ncl.

the class RemoteBuildTest method getOrCreateBuildConfiguration.

private BuildConfiguration getOrCreateBuildConfiguration(String buildConfigurationName, String buildScript, String scmRevision, Map<String, String> genericParameters, String projectId, String repositoryConfigurationId, String buildEnvironmentId) throws RemoteResourceException {
    RemoteCollection<BuildConfiguration> existing = buildConfigurationRestClient.getAll(Optional.empty(), Optional.of("name==" + buildConfigurationName));
    Iterator<BuildConfiguration> it = existing.iterator();
    if (!it.hasNext()) {
        ProjectRef project = ProjectRef.refBuilder().id(projectId).build();
        SCMRepository repository = SCMRepository.builder().id(repositoryConfigurationId).build();
        Environment environment = Environment.builder().id(buildEnvironmentId).build();
        BuildConfiguration buildConfiguration = BuildConfiguration.builder().name(buildConfigurationName).project(project).scmRepository(repository).scmRevision(scmRevision).environment(environment).buildScript(buildScript).parameters(genericParameters).build();
        BuildConfiguration created = buildConfigurationRestClient.createNew(buildConfiguration);
        return created;
    } else {
        return it.next();
    }
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Environment(org.jboss.pnc.dto.Environment) ProjectRef(org.jboss.pnc.dto.ProjectRef) SCMRepository(org.jboss.pnc.dto.SCMRepository)

Example 2 with Environment

use of org.jboss.pnc.dto.Environment in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldNotCreateWhenEnvironmentDoesNotExist.

@Test
public void shouldNotCreateWhenEnvironmentDoesNotExist() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    Environment origEnv = bc.getEnvironment();
    Environment env = Environment.builder().attributes(origEnv.getAttributes()).deprecated(origEnv.isDeprecated()).description(origEnv.getDescription()).name(origEnv.getName()).systemImageId(origEnv.getSystemImageId()).systemImageRepositoryUrl(origEnv.getSystemImageRepositoryUrl()).systemImageType(origEnv.getSystemImageType()).id("10000").build();
    BuildConfiguration newBC = BuildConfiguration.builder().name("othernameforbc2").buildScript(bc.getBuildScript()).project(bc.getProject()).environment(env).parameters(bc.getParameters()).buildType(bc.getBuildType()).scmRepository(bc.getScmRepository()).scmRevision(bc.getScmRevision()).build();
    assertThatThrownBy(() -> client.createNew(newBC)).hasCauseInstanceOf(NotFoundException.class);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Environment(org.jboss.pnc.dto.Environment) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 3 with Environment

use of org.jboss.pnc.dto.Environment in project pnc by project-ncl.

the class EnvironmentEndpointTest method testQueryForEnvironment.

@Test
@InSequence(20)
public void testQueryForEnvironment() throws RemoteResourceException {
    EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<Environment> allNonDeprecated = client.getAll(Optional.empty(), Optional.of("deprecated==false"));
    RemoteCollection<Environment> allDeprecated = client.getAll(Optional.empty(), Optional.of("deprecated==true"));
    assertThat(allNonDeprecated.getAll().stream().map(Environment::isDeprecated)).containsOnly(false);
    assertThat(allDeprecated.getAll().stream().map(Environment::isDeprecated)).containsOnly(true);
}
Also used : EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) Environment(org.jboss.pnc.dto.Environment) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest) InSequence(org.jboss.arquillian.junit.InSequence)

Example 4 with Environment

use of org.jboss.pnc.dto.Environment in project pnc by project-ncl.

the class BuildBCRevisionFetcher method mapFromAuditedBuildConfig.

@BeforeMapping
public void mapFromAuditedBuildConfig(BuildRecord build, @MappingTarget Build.Builder dtoBuilder) {
    Integer id = build.getBuildConfigurationId();
    Integer revision = build.getBuildConfigurationRev();
    // If somebody before us already set the BCA we don't need to query it from DB again
    BuildConfigurationAudited bca = build.getBuildConfigurationAudited();
    if (bca == null) {
        bca = bcAuditedRepository.queryById(new IdRev(id, revision));
    }
    BuildConfigurationRevisionRef bcRevision = bcRevisionMapper.toRef(bca);
    ProjectRef project = projectMapper.toRef(bca.getProject());
    Environment environment = environmentMapper.toRef(bca.getBuildEnvironment());
    SCMRepository scmRepository = scmRepositoryMapper.toRef(bca.getRepositoryConfiguration());
    dtoBuilder.buildConfigRevision(bcRevision);
    dtoBuilder.project(project);
    dtoBuilder.environment(environment);
    dtoBuilder.scmRepository(scmRepository);
}
Also used : BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef) Environment(org.jboss.pnc.dto.Environment) IdRev(org.jboss.pnc.model.IdRev) ProjectRef(org.jboss.pnc.dto.ProjectRef) SCMRepository(org.jboss.pnc.dto.SCMRepository) BeforeMapping(org.mapstruct.BeforeMapping)

Example 5 with Environment

use of org.jboss.pnc.dto.Environment in project bacon by project-ncl.

the class PncEntitiesImporter method generatePncBuildConfig.

/**
 * @param buildConfig PiG buildconfig to generate
 * @param existing if present, we'll use it as the buildconfig to modify if null: we'll use a fresh buildconfig
 *        object
 *
 * @return BuildConfiguration generated
 */
private BuildConfiguration generatePncBuildConfig(BuildConfig buildConfig, BuildConfiguration existing) {
    ProjectRef project = getOrGenerateProject(buildConfig.getProject());
    SCMRepository repository = getOrGenerateRepository(buildConfig);
    Environment environment = Environment.builder().id(buildConfig.getEnvironmentId()).build();
    BuildConfiguration.Builder builder = BuildConfiguration.builder();
    if (existing != null) {
        builder = existing.toBuilder();
    }
    return builder.productVersion(version).parameters(buildConfig.getGenericParameters(null, false)).name(buildConfig.getName()).project(project).environment(environment).scmRepository(repository).scmRevision(buildConfig.getScmRevision()).buildScript(buildConfig.getBuildScript()).buildType(BuildType.valueOf(buildConfig.getBuildType())).brewPullActive(buildConfig.getBrewPullActive()).build();
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Environment(org.jboss.pnc.dto.Environment) ProjectRef(org.jboss.pnc.dto.ProjectRef) SCMRepository(org.jboss.pnc.dto.SCMRepository)

Aggregations

Environment (org.jboss.pnc.dto.Environment)14 Test (org.junit.Test)8 SCMRepository (org.jboss.pnc.dto.SCMRepository)5 ContainerTest (org.jboss.pnc.test.category.ContainerTest)5 InSequence (org.jboss.arquillian.junit.InSequence)4 EnvironmentClient (org.jboss.pnc.client.EnvironmentClient)4 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)4 ProjectRef (org.jboss.pnc.dto.ProjectRef)4 BuildEnvironment (org.jboss.pnc.model.BuildEnvironment)3 BuildConfigurationRevisionRef (org.jboss.pnc.dto.BuildConfigurationRevisionRef)2 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 AbstractTest (org.jboss.pnc.bacon.test.AbstractTest)1 ExecutionResult (org.jboss.pnc.bacon.test.ExecutionResult)1 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)1 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)1 Product (org.jboss.pnc.dto.Product)1 ProductMilestone (org.jboss.pnc.dto.ProductMilestone)1 ProductVersion (org.jboss.pnc.dto.ProductVersion)1 Project (org.jboss.pnc.dto.Project)1