Search in sources :

Example 26 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method testGetSpecific.

@Test
@InSequence(10)
public void testGetSpecific() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    BuildConfiguration dto = client.getSpecific(configurationId);
    // from DatabaseDataInitializer
    assertThat(dto.getScmRevision()).isEqualTo("*/v0.2");
    // from
    assertThat(dto.getDescription()).isEqualTo("Test build config for project newcastle");
// DatabaseDataInitializer
}
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)

Example 27 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method testGetSupportedParameters.

@Test
public void testGetSupportedParameters() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    Set<Parameter> all = client.getSupportedParameters();
    assertThat(all).haveExactly(1, new Condition<>(p -> p.getName().equals(BuildConfigurationParameterKeys.ALIGNMENT_PARAMETERS.name()) && p.getDescription().startsWith("Additional parameters, which will be "), "has PME parameter")).size().isGreaterThanOrEqualTo(4);
}
Also used : PatchBuilderException(org.jboss.pnc.client.patch.PatchBuilderException) Arquillian(org.jboss.arquillian.junit.Arquillian) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) ClientErrorException(javax.ws.rs.ClientErrorException) ProjectClient(org.jboss.pnc.client.ProjectClient) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) BadRequestException(javax.ws.rs.BadRequestException) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) Deployments(org.jboss.pnc.integration.setup.Deployments) BuildConfigurationParameterKeys(org.jboss.pnc.api.constants.BuildConfigurationParameterKeys) BuildConfigurationPatchBuilder(org.jboss.pnc.client.patch.BuildConfigurationPatchBuilder) AlignmentParameters(org.jboss.pnc.dto.response.AlignmentParameters) EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) Parameter(org.jboss.pnc.dto.response.Parameter) Set(java.util.Set) UUID(java.util.UUID) Category(org.junit.experimental.categories.Category) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) BuildConfigCreationResponse(org.jboss.pnc.dto.response.BuildConfigCreationResponse) List(java.util.List) BeforeClass(org.junit.BeforeClass) BuildConfigWithSCMRequest(org.jboss.pnc.dto.requests.BuildConfigWithSCMRequest) RunWith(org.junit.runner.RunWith) ProductClient(org.jboss.pnc.client.ProductClient) DTOEntity(org.jboss.pnc.dto.DTOEntity) HashMap(java.util.HashMap) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Environment(org.jboss.pnc.dto.Environment) RemoteCollection(org.jboss.pnc.client.RemoteCollection) ArrayList(java.util.ArrayList) BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) ContainerTest(org.jboss.pnc.test.category.ContainerTest) ClientException(org.jboss.pnc.client.ClientException) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ProjectRef(org.jboss.pnc.dto.ProjectRef) BuildType(org.jboss.pnc.enums.BuildType) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence) RestClientConfiguration(org.jboss.pnc.integration.setup.RestClientConfiguration) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) SCMRepositoryClient(org.jboss.pnc.client.SCMRepositoryClient) Build(org.jboss.pnc.dto.Build) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationWithLatestBuild(org.jboss.pnc.dto.BuildConfigurationWithLatestBuild) SCMRepository(org.jboss.pnc.dto.SCMRepository) Ignore(org.junit.Ignore) Deployment(org.jboss.arquillian.container.test.api.Deployment) Condition(org.assertj.core.api.Condition) RemoteResourceException(org.jboss.pnc.client.RemoteResourceException) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Parameter(org.jboss.pnc.dto.response.Parameter) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 28 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldNotCreateBuildConfigRevision.

@Test
public void shouldNotCreateBuildConfigRevision() throws ClientException {
    final String description = "Updated description again.";
    final String updatedName = "yetanotherupdatedname";
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configuration2Id);
    BuildConfiguration newBC1 = bc.toBuilder().name(updatedName).description(description).build();
    BuildConfiguration newBC2 = newBC1.toBuilder().description(description + " and again").build();
    BuildConfigurationRevision newRevision1 = client.createRevision(configuration2Id, newBC1);
    BuildConfigurationRevision newRevision2 = client.createRevision(configuration2Id, newBC2);
    assertEquals(newRevision1.getRev(), newRevision2.getRev());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 29 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldPatchBuildConfiguration.

@Test
@InSequence(20)
public void shouldPatchBuildConfiguration() throws ClientException, PatchBuilderException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration buildConfiguration = client.getAll().iterator().next();
    String newDescription = "Testing patch support.";
    Instant modTime = buildConfiguration.getModificationTime();
    String id = buildConfiguration.getId();
    Map<String, String> addElements = Collections.singletonMap("newKey", "newValue");
    BuildConfigurationPatchBuilder builder = new BuildConfigurationPatchBuilder().replaceDescription(newDescription).addParameters(addElements);
    BuildConfiguration updated = client.patch(id, builder);
    Assert.assertEquals(newDescription, updated.getDescription());
    Assert.assertNotEquals(modTime, updated.getModificationTime());
    Assertions.assertThat(updated.getParameters()).contains(addElements.entrySet().toArray(new Map.Entry[1]));
    String newDescription2 = "Testing patch support 2.";
    BuildConfigurationPatchBuilder builder2 = new BuildConfigurationPatchBuilder().replaceDescription(newDescription2);
    BuildConfiguration updated2 = client.patch(id, builder2.getJsonPatch(), BuildConfiguration.class);
    Assert.assertEquals(newDescription2, updated2.getDescription());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationPatchBuilder(org.jboss.pnc.client.patch.BuildConfigurationPatchBuilder) Instant(java.time.Instant) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 30 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldUpdateBuildConfiguration.

/**
 * Reproducer NCL-2615 - big generic parameters cannot be ubdated in the BuildConfiguration
 *
 * @throws ClientException
 */
@Test
@InSequence(30)
public void shouldUpdateBuildConfiguration() throws ClientException {
    // given
    final String updatedBuildScript = "mvn clean deploy -Dmaven.test.skip=true";
    final String updatedName = UUID.randomUUID().toString();
    final String updatedProjectId = String.valueOf(projectId);
    final String updatedGenParamValue = PME_PARAMS_LONG;
    final Instant modificationTime = Instant.ofEpochMilli(155382545038L);
    BuildConfiguration buildConfiguration = BuildConfiguration.builder().id(configurationId).name(updatedName).buildScript(updatedBuildScript).creationTime(Instant.ofEpochMilli(1518382545038L)).modificationTime(modificationTime).project(ProjectRef.refBuilder().id(updatedProjectId).build()).environment(Environment.builder().id(environmentId).build()).parameters(Collections.singletonMap(PARAMETER_KEY, updatedGenParamValue)).scmRepository(SCMRepository.builder().id(repositoryConfigurationId).build()).buildType(BuildType.MVN).brewPullActive(true).build();
    // when
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    client.update(configurationId, buildConfiguration);
    BuildConfiguration updatedBC = client.getSpecific(configurationId);
    // then
    assertThat(updatedBC.getId()).isEqualTo(configurationId);
    assertThat(updatedBC.getName()).isEqualTo(updatedName);
    assertThat(updatedBC.getBuildScript()).isEqualTo(updatedBuildScript);
    assertThat(updatedBC.getScmRepository().getId()).isEqualTo(repositoryConfigurationId);
    assertThat(updatedBC.getProject().getId()).isEqualTo(updatedProjectId);
    assertThat(updatedBC.getParameters().get(PARAMETER_KEY)).isEqualTo(updatedGenParamValue);
    assertThat(updatedBC.getEnvironment().getId()).isEqualTo(environmentId);
    assertThat(modificationTime).isNotEqualTo(updatedBC.getModificationTime());
    assertThat(updatedBC.getBrewPullActive()).isTrue();
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Instant(java.time.Instant) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)41 ContainerTest (org.jboss.pnc.test.category.ContainerTest)37 Test (org.junit.Test)37 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)32 InSequence (org.jboss.arquillian.junit.InSequence)16 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)6 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)6 Instant (java.time.Instant)5 Build (org.jboss.pnc.dto.Build)5 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)5 SCMRepositoryClient (org.jboss.pnc.client.SCMRepositoryClient)4 HashMap (java.util.HashMap)3 ClientErrorException (javax.ws.rs.ClientErrorException)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Deployment (org.jboss.arquillian.container.test.api.Deployment)3 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)3 Arquillian (org.jboss.arquillian.junit.Arquillian)3 ClientException (org.jboss.pnc.client.ClientException)3 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)3 BuildConfigurationPatchBuilder (org.jboss.pnc.client.patch.BuildConfigurationPatchBuilder)3