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