use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method shouldGetBuildConfigurationRevision.
@Test
public void shouldGetBuildConfigurationRevision() throws Exception {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
BuildConfigurationRevision revision = client.getRevision(configurationId, 1);
assertThat(revision.getId()).isEqualTo(configurationId);
}
use of org.jboss.pnc.client.BuildConfigurationClient 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);
}
use of org.jboss.pnc.client.BuildConfigurationClient 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.client.BuildConfigurationClient 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.client.BuildConfigurationClient 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());
}
Aggregations