Search in sources :

Example 11 with GroupConfiguration

use of org.jboss.pnc.dto.GroupConfiguration in project bacon by project-ncl.

the class PigTest method shouldCreateProduct.

@Test
@Order(1)
void shouldCreateProduct() throws IOException {
    final Path configFile = CONFIG_LOCATION;
    replaceSuffixInConfigFile(configFile.resolve("build-config.yaml"));
    final Product product = Product.builder().id(UNIVERSAL_ID).name(PRODUCT_NAME).abbreviation(PRODUCT_ABBREVIATION).build();
    final ProductVersion productVersion = ProductVersion.builder().id(UNIVERSAL_ID).version(VERSION).product(product).build();
    final ProductMilestone productMilestone = ProductMilestone.builder().id(UNIVERSAL_ID).productVersion(productVersion).version(MILESTONE).build();
    final ProductVersion productVersionWithCurrentMilestone = productVersion.toBuilder().currentProductMilestone(productMilestone).build();
    final GroupConfiguration groupConfig = GroupConfiguration.builder().id(UNIVERSAL_ID).name(GROUP_NAME).productVersion(productVersionWithCurrentMilestone).build();
    final Project project = Project.builder().id(UNIVERSAL_ID).name(PROJECT_NAME).build();
    final SCMRepository scmRepository = SCMRepository.builder().id(UNIVERSAL_ID).internalUrl(SCM_URL).preBuildSyncEnabled(true).build();
    final Environment environment = Environment.builder().id(UNIVERSAL_ID).deprecated(false).build();
    final BuildConfiguration buildConfig = BuildConfiguration.builder().id(UNIVERSAL_ID).name(BC_NAME).buildScript(BUILD_SCRIPT).scmRevision(SCM_REVISION).creationTime(Instant.now()).modificationTime(Instant.now()).scmRepository(scmRepository).environment(environment).project(project).productVersion(productVersionWithCurrentMilestone).build();
    final GroupConfiguration groupConfigWithBuildConfig = groupConfig.toBuilder().buildConfigs(Collections.singletonMap(UNIVERSAL_ID, buildConfig)).build();
    wmock.list(PRODUCT, new Page<Product>());
    wmock.creation(PRODUCT, product);
    wmock.list(PRODUCT_VERSIONS.apply(UNIVERSAL_ID), new Page<ProductVersion>());
    wmock.creation(PRODUCT_VERSION, productVersion);
    wmock.list(PRODUCT_VERSION_MILESTONES.apply(UNIVERSAL_ID), new Page<ProductMilestone>());
    wmock.creation(PRODUCT_MILESTONE, productMilestone);
    wmock.update(PRODUCT_VERSION, productVersion, productVersionWithCurrentMilestone);
    wmock.list(GROUP_CONFIG, new Page<GroupConfiguration>());
    wmock.creation(GROUP_CONFIG, groupConfig);
    wmock.list(GROUP_CONFIG_BUILD_CONFIGS.apply(UNIVERSAL_ID), new Page<BuildConfiguration>());
    wmock.list(BUILD_CONFIG, new Page<BuildConfiguration>());
    wmock.list(PROJECT, new Page<Project>());
    wmock.creation(PROJECT, project);
    wmock.list(SCM_REPOSITORY, new Page<SCMRepository>());
    wmock.creation(SCM_REPOSITORY_CREATE, RepositoryCreationResponse.builder().repository(scmRepository).build());
    wmock.get(ENVIRONMENT, environment);
    wmock.creation(BUILD_CONFIG, buildConfig);
    wmock.list(BUILD_CONFIG_DEPENDENCIES.apply(UNIVERSAL_ID), new Page<BuildConfiguration>());
    wmock.get(BUILD_CONFIG, buildConfig);
    wmock.creation(BUILD_CONFIG, buildConfig);
    wmock.scenario("add BC to GC").getEntity(GROUP_CONFIG, groupConfig).when().post(GROUP_CONFIG_BUILD_CONFIGS.apply(UNIVERSAL_ID)).then().getEntity(GROUP_CONFIG, groupConfigWithBuildConfig);
    ExecutionResult output = executeAndGetResult("pig", "configure", configFile.toString());
    assertThat(output.getOutput()).contains("name: \"Product Foobar " + SUFFIX + "\"");
}
Also used : Path(java.nio.file.Path) ProductMilestone(org.jboss.pnc.dto.ProductMilestone) Product(org.jboss.pnc.dto.Product) ExecutionResult(org.jboss.pnc.bacon.test.ExecutionResult) ProductVersion(org.jboss.pnc.dto.ProductVersion) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Project(org.jboss.pnc.dto.Project) Environment(org.jboss.pnc.dto.Environment) SCMRepository(org.jboss.pnc.dto.SCMRepository) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) AbstractTest(org.jboss.pnc.bacon.test.AbstractTest) Test(org.junit.jupiter.api.Test)

Example 12 with GroupConfiguration

use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method testGetGroupConfig.

@Test
public void testGetGroupConfig() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<GroupConfiguration> all = client.getGroupConfigs(configurationId);
    assertThat(all).hasSize(1).allMatch(gc -> gc.getBuildConfigs().containsKey(configurationId));
}
Also used : GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 13 with GroupConfiguration

use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.

the class BuildTest method shouldTriggerGroupBuildWithBCInRevisionAndFinishWithoutProblems.

@Test
public void shouldTriggerGroupBuildWithBCInRevisionAndFinishWithoutProblems() throws ClientException {
    // given
    GroupConfiguration groupConfiguration = groupConfigurationClient.getAll().iterator().next();
    assertThat(groupConfiguration.getBuildConfigs()).isNotEmpty();
    List<BuildConfigurationRevisionRef> buildConfigurationRevisions = new ArrayList<>();
    BuildConfigurationRevision buildConfigurationRevision = BuildConfigurationRevision.builder().id(groupConfiguration.getBuildConfigs().keySet().iterator().next()).rev(1).name(groupConfiguration.getName()).build();
    buildConfigurationRevisions.add(buildConfigurationRevision);
    GroupBuildRequest groupConfigWithAuditedBCsRest = GroupBuildRequest.builder().buildConfigurationRevisions(buildConfigurationRevisions).build();
    GroupBuildParameters groupBuildParameters = new GroupBuildParameters();
    groupBuildParameters.setRebuildMode(RebuildMode.FORCE);
    // when
    GroupBuild groupBuild = groupConfigurationClient.trigger(groupConfiguration.getId(), groupBuildParameters, groupConfigWithAuditedBCsRest);
    // then
    assertThat(groupBuild).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
    EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
    EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.REJECTED);
    ResponseUtils.waitSynchronouslyFor(() -> groupBuildToFinish(groupBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
}
Also used : GroupBuildRequest(org.jboss.pnc.dto.requests.GroupBuildRequest) GroupBuild(org.jboss.pnc.dto.GroupBuild) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef) ArrayList(java.util.ArrayList) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildStatus(org.jboss.pnc.enums.BuildStatus) GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 14 with GroupConfiguration

use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.

the class ProductVersionEndpointTest method shouldAdd2GroupConfigsWithPatch.

@Test
public void shouldAdd2GroupConfigsWithPatch() throws Exception {
    // given #1
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    GroupConfigurationClient gcClient = new GroupConfigurationClient(RestClientConfiguration.asUser());
    ProductVersion productVersion = client.getSpecific(productVersionsId2);
    GroupConfiguration toAdd = gcClient.createNew(GroupConfiguration.builder().name("New GC1").build());
    ProductVersionPatchBuilder builder = new ProductVersionPatchBuilder();
    Map<String, GroupConfigurationRef> toAddMap = new HashMap<>();
    toAddMap.put(toAdd.getId(), toAdd);
    builder.addGroupConfigs(toAddMap);
    // when #1
    client.patch(productVersion.getId(), builder);
    // then #1
    ProductVersion refresh = client.getSpecific(productVersionsId2);
    assertThat(refresh.getGroupConfigs()).containsKey(toAdd.getId());
    // given #2 add second GC
    GroupConfiguration toAdd2 = gcClient.createNew(GroupConfiguration.builder().name("New GC2").build());
    builder = new ProductVersionPatchBuilder();
    toAddMap.clear();
    toAddMap.put(toAdd2.getId(), toAdd2);
    builder.addGroupConfigs(toAddMap);
    // when #2
    client.patch(productVersion.getId(), builder);
    // then #2
    refresh = client.getSpecific(productVersionsId2);
    assertThat(refresh.getGroupConfigs()).containsKey(toAdd2.getId()).containsKey(toAdd.getId());
}
Also used : GroupConfigurationRef(org.jboss.pnc.dto.GroupConfigurationRef) HashMap(java.util.HashMap) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) ProductVersion(org.jboss.pnc.dto.ProductVersion) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ProductVersionPatchBuilder(org.jboss.pnc.client.patch.ProductVersionPatchBuilder) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 15 with GroupConfiguration

use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.

the class ProductVersionEndpointTest method shouldUpdateGroupConfigs.

@Test
public void shouldUpdateGroupConfigs() throws ClientException {
    // given
    GroupConfiguration gc = GroupConfiguration.builder().name("New GC").build();
    GroupConfigurationClient gcc = new GroupConfigurationClient(RestClientConfiguration.asUser());
    GroupConfiguration gcToAdd = gcc.createNew(gc);
    Map<String, GroupConfigurationRef> groupConfis = new HashMap<>();
    // when
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    ProductVersion productVersion = client.getSpecific(productVersionsId2);
    groupConfis.putAll(productVersion.getGroupConfigs());
    groupConfis.put(gcToAdd.getId(), gcToAdd);
    ProductVersion toUpdate = productVersion.toBuilder().groupConfigs(groupConfis).build();
    client.update(productVersion.getId(), toUpdate);
    ProductVersion retrieved = client.getSpecific(productVersion.getId());
    // then
    assertThat(retrieved.getGroupConfigs()).hasSameSizeAs(groupConfis).containsKey(gcToAdd.getId());
}
Also used : GroupConfigurationRef(org.jboss.pnc.dto.GroupConfigurationRef) HashMap(java.util.HashMap) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)23 Test (org.junit.Test)21 ContainerTest (org.jboss.pnc.test.category.ContainerTest)18 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)12 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)6 HashMap (java.util.HashMap)5 GroupBuild (org.jboss.pnc.dto.GroupBuild)5 ProductVersion (org.jboss.pnc.dto.ProductVersion)5 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)4 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)4 GroupBuildParameters (org.jboss.pnc.rest.api.parameters.GroupBuildParameters)4 GroupConfigurationRef (org.jboss.pnc.dto.GroupConfigurationRef)3 BuildStatus (org.jboss.pnc.enums.BuildStatus)3 GroupConfigurationPatchBuilder (org.jboss.pnc.client.patch.GroupConfigurationPatchBuilder)2 ProductVersionPatchBuilder (org.jboss.pnc.client.patch.ProductVersionPatchBuilder)2 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)2 Test (org.junit.jupiter.api.Test)2 Undertow (io.undertow.Undertow)1 Method (java.lang.reflect.Method)1 Path (java.nio.file.Path)1