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