Search in sources :

Example 6 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method shouldCreateWithInternalUrlMatchingPattern.

@Test
@InSequence(62)
public void shouldCreateWithInternalUrlMatchingPattern() throws ClientException {
    // given
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    BuildConfiguration newBC = BuildConfiguration.builder().name("othernameforbc").buildScript(bc.getBuildScript()).project(bc.getProject()).environment(bc.getEnvironment()).parameters(bc.getParameters()).buildType(bc.getBuildType()).build();
    BuildConfigWithSCMRequest request = BuildConfigWithSCMRequest.builder().buildConfig(newBC).scmUrl("ssh://git@github.com:22/newUser/newRepo.git").build();
    BuildConfigCreationResponse received = client.createWithSCM(request);
    assertThat(received).isNotNull();
    assertThat(received.getBuildConfig().getId()).isNotNull();
    assertThat(client.getSpecific(received.getBuildConfig().getId())).hasFieldOrPropertyWithValue("name", "othernameforbc");
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigCreationResponse(org.jboss.pnc.dto.response.BuildConfigCreationResponse) BuildConfigWithSCMRequest(org.jboss.pnc.dto.requests.BuildConfigWithSCMRequest) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 7 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method shouldCreateNewBuildConfiguration.

@Test
@InSequence(20)
public void shouldCreateNewBuildConfiguration() throws ClientException {
    BuildConfiguration bc = createBuildConfigurationAndValidateResults(projectId, environmentId, repositoryConfigurationId, UUID.randomUUID().toString(), UUID.randomUUID().toString());
    assertThat(bc.getCreationTime()).isNotNull();
    assertThat(bc.getModificationTime()).isNotNull();
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 8 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method testRemoveDependency.

@Test
@InSequence(40)
public void testRemoveDependency() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    // given
    BuildConfiguration parent = client.getSpecific(configuration3Id);
    Map<String, BuildConfigurationRef> oldDependencies = parent.getDependencies();
    assertThat(oldDependencies).isNotEmpty();
    BuildConfigurationRef toDelete = oldDependencies.values().iterator().next();
    // when
    client.removeDependency(parent.getId(), toDelete.getId());
    // then
    RemoteCollection<BuildConfiguration> all = client.getDependencies(parent.getId());
    oldDependencies.remove(toDelete.getId());
    assertThat(all).extracting(DTOEntity::getId).doesNotContain(toDelete.getId()).containsAll(oldDependencies.keySet().stream().collect(Collectors.toList()));
}
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 9 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method shouldGetConflictWhenCreatingNewBuildConfigurationWithTheSameNameAndProjectId.

@Test
public void shouldGetConflictWhenCreatingNewBuildConfigurationWithTheSameNameAndProjectId() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    BuildConfiguration duplicate = BuildConfiguration.builder().name(bc.getName()).buildScript(bc.getBuildScript()).project(bc.getProject()).environment(bc.getEnvironment()).parameters(bc.getParameters()).scmRepository(bc.getScmRepository()).buildType(bc.getBuildType()).build();
    assertThatThrownBy(() -> client.createNew(duplicate)).hasCauseInstanceOf(ClientErrorException.class).has(new Condition<Throwable>((e -> ((ClientErrorException) e.getCause()).getResponse().getStatus() == 409), "HTTP 409 Conflict"));
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) ClientErrorException(javax.ws.rs.ClientErrorException) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 10 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration 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)

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