Search in sources :

Example 11 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method createBuildConfigurationAndValidateResults.

private BuildConfiguration createBuildConfigurationAndValidateResults(String projectId, String environmentId, String repositoryConfigurationId, String name, String genericParameterValue1) throws ClientException {
    BuildConfiguration buildConfiguration = BuildConfiguration.builder().project(ProjectRef.refBuilder().id(projectId).build()).environment(Environment.builder().id(environmentId).build()).scmRepository(SCMRepository.builder().id(repositoryConfigurationId).build()).name(name).parameters(Collections.singletonMap(PARAMETER_KEY, genericParameterValue1)).buildType(BuildType.MVN).build();
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration newBC = client.createNew(buildConfiguration);
    return newBC;
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient)

Example 12 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method shouldFailToCreateNewBuildConfigurationBecauseIdIsNotNull.

@Test
public void shouldFailToCreateNewBuildConfigurationBecauseIdIsNotNull() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    BuildConfiguration bcNew = BuildConfiguration.builder().id(configurationId).name("newbcname").buildScript(bc.getBuildScript()).project(bc.getProject()).environment(bc.getEnvironment()).parameters(bc.getParameters()).scmRepository(bc.getScmRepository()).buildType(bc.getBuildType()).build();
    assertThatThrownBy(() -> client.createNew(bcNew)).hasCauseInstanceOf(BadRequestException.class);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 13 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method testAddDependency.

@Test
@InSequence(20)
public void testAddDependency() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    // given
    BuildConfiguration newDependency = createBuildConfigurationAndValidateResults(projectId, environmentId, repositoryConfigurationId, "dep-" + UUID.randomUUID(), PARAMETER_KEY);
    BuildConfiguration parent = client.getSpecific(configuration3Id);
    Map<String, BuildConfigurationRef> oldDependencies = parent.getDependencies();
    assertThat(oldDependencies).doesNotContainKey(newDependency.getId());
    // when
    client.addDependency(parent.getId(), newDependency);
    // then
    RemoteCollection<BuildConfiguration> all = client.getDependencies(parent.getId());
    assertThat(all).extracting(DTOEntity::getId).containsAll(oldDependencies.keySet().stream().collect(Collectors.toList())).contains(newDependency.getId());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) DTOEntity(org.jboss.pnc.dto.DTOEntity) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 14 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method shouldCreateBuildConfigRevision.

@Test
public void shouldCreateBuildConfigRevision() throws ClientException {
    final String description = "Updated description.";
    final String updatedName = "thisisanupdatedname";
    final String buildScript = "mvn deploy # Updated script";
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    Instant modTime = bc.getModificationTime();
    BuildConfiguration newBC1 = bc.toBuilder().name(updatedName).description(description).build();
    BuildConfiguration newBC2 = bc.toBuilder().buildScript(buildScript).build();
    BuildConfigurationRevision newRevision1 = client.createRevision(configurationId, newBC1);
    BuildConfigurationRevision newRevision2 = client.createRevision(configurationId, newBC2);
    assertNotEquals(modTime, newRevision1.getModificationTime());
    assertNotEquals(modTime, newRevision2.getModificationTime());
    assertEquals(updatedName, newRevision1.getName());
    assertEquals(bc.getBuildScript(), newRevision1.getBuildScript());
    assertEquals(bc.getEnvironment(), newRevision2.getEnvironment());
    assertEquals(buildScript, newRevision2.getBuildScript());
    assertThat(newRevision1.getRev()).isLessThan(newRevision2.getRev());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Instant(java.time.Instant) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 15 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method testGetAll.

@Test
@InSequence(10)
public void testGetAll() throws RemoteResourceException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<BuildConfiguration> all = client.getAll();
    // from DatabaseDataInitializer
    assertThat(all).hasSize(5);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)90 Test (org.junit.Test)65 ContainerTest (org.jboss.pnc.test.category.ContainerTest)45 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)31 HashMap (java.util.HashMap)17 InSequence (org.jboss.arquillian.junit.InSequence)17 Build (org.jboss.pnc.dto.Build)13 GroupBuild (org.jboss.pnc.dto.GroupBuild)12 SCMRepository (org.jboss.pnc.dto.SCMRepository)10 Test (org.junit.jupiter.api.Test)10 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)9 Instant (java.time.Instant)8 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)7 BuildStatus (org.jboss.pnc.enums.BuildStatus)7 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 ArrayList (java.util.ArrayList)4 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)4 HashSet (java.util.HashSet)3