use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method testRemoveBuildConfigFromGroupConfig.
@Test
public void testRemoveBuildConfigFromGroupConfig() throws ClientException {
// with
GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
String gcId = "100";
BuildConfiguration configuration = client.getBuildConfigs(gcId).iterator().next();
// when
client.removeBuildConfig(gcId, configuration.getId());
// then
GroupConfiguration refreshed = client.getSpecific(gcId);
assertThat(refreshed).isNotNull();
assertThat(refreshed.getBuildConfigs()).doesNotContainKey(configuration.getId());
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class ProductVersionEndpointTest method testGetBuildConfigurations.
@Test
public void testGetBuildConfigurations() throws ClientException {
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
RemoteCollection<BuildConfiguration> all = client.getBuildConfigs(productVersionsId);
assertThat(all).hasSize(2).allMatch(v -> v.getProductVersion().getId().equals(productVersionsId));
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class ProductVersionEndpointTest method shouldDeleteBuildConfigWithPatch.
@Test
public void shouldDeleteBuildConfigWithPatch() throws Exception {
// given
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
ProductVersion productVersion = client.getSpecific(productVersionsId2);
assertThat(productVersion.getBuildConfigs()).isNotEmpty();
BuildConfiguration toRemove = bcClient.getSpecific(productVersion.getBuildConfigs().keySet().iterator().next());
ProductVersionPatchBuilder builder = new ProductVersionPatchBuilder();
builder.removeBuildConfigs(Collections.singletonList(toRemove.getId()));
// when
client.patch(productVersion.getId(), builder);
// then
ProductVersion refresh = client.getSpecific(productVersionsId2);
assertThat(refresh.getBuildConfigs().keySet()).doesNotContain(toRemove.getId());
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class RSQLPredicateProducerTest method testComparatorUnknownQuery.
@Test
public void testComparatorUnknownQuery() {
Comparator<BuildConfiguration> comparator = producer.getComparator("=desc=fieldThatDoesNotExists");
BuildConfiguration foo = BuildConfiguration.builder().id("3").name("FooBC").build();
BuildConfiguration bar = BuildConfiguration.builder().id("5").name("BarBC").build();
BuildConfiguration baz = BuildConfiguration.builder().id("7").name("BazBC").build();
try {
List<BuildConfiguration> sorted = Arrays.asList(foo, bar, baz).stream().sorted(comparator).collect(Collectors.toList());
fail("Exception expected");
} catch (RuntimeException ex) {
// ok
}
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationProviderImpl method createBuildConfigurationWithRepository.
public void createBuildConfigurationWithRepository(String taskId, int scmRepositoryId, BuildConfiguration configuration) {
RepositoryConfiguration repositoryConfiguration = repositoryConfigurationRepository.queryById(scmRepositoryId);
final boolean sendMessage = taskId != null;
if (repositoryConfiguration == null) {
String errorMessage = "Repository Configuration was not found in database.";
logger.error(errorMessage);
if (sendMessage) {
sendErrorMessage(SCMRepository.builder().id(Integer.toString(scmRepositoryId)).build(), null, errorMessage, taskId);
return;
}
throw new RepositoryViolationException("Repository Configuration was not found in database.");
}
org.jboss.pnc.model.BuildConfiguration buildConfiguration = mapper.toEntity(configuration);
buildConfiguration.setRepositoryConfiguration(repositoryConfiguration);
org.jboss.pnc.model.BuildConfiguration buildConfigurationSaved = repository.save(buildConfiguration);
Set<Integer> bcSetIds;
if (configuration.getGroupConfigs() == null) {
bcSetIds = Collections.emptySet();
} else {
bcSetIds = configuration.getGroupConfigs().keySet().stream().map(Integer::valueOf).collect(Collectors.toSet());
}
SCMRepository scmRepository = scmRepositoryMapper.toDTO(repositoryConfiguration);
BuildConfiguration buildConfig = mapper.toDTO(buildConfigurationSaved);
try {
addBuildConfigurationToSet(buildConfigurationSaved, bcSetIds);
} catch (Exception e) {
logger.error(e.getMessage());
if (sendMessage) {
sendErrorMessage(scmRepository, buildConfig, e.getMessage(), taskId);
return;
}
throw new RepositoryViolationException("Failed to add BuildConfig to BuildConfigSets.");
}
logger.info("Created Build Configuration with Repository: {}.", buildConfig);
if (sendMessage) {
BuildConfigurationCreation successMessage = BuildConfigurationCreation.success(scmRepository, buildConfig, taskId);
notifier.sendMessage(successMessage);
}
}
Aggregations