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