Search in sources :

Example 1 with Project

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

the class RSQLPredicateProducerTest method testStreamPredicateEmbeded.

@Test
public void testStreamPredicateEmbeded() {
    Predicate<BuildConfiguration> streamPredicate = producer.getStreamPredicate("project.name==\"Bar Project\"");
    Project projBar = Project.builder().name("Bar Project").build();
    Project projBaz = Project.builder().name("Baz Project").build();
    BuildConfiguration fooBar = BuildConfiguration.builder().project(projBar).build();
    BuildConfiguration fooBaz = BuildConfiguration.builder().project(projBaz).build();
    List<BuildConfiguration> filtered = Arrays.asList(fooBar, fooBaz).stream().filter(streamPredicate).collect(Collectors.toList());
    assertEquals(1, filtered.size());
    assertEquals("Bar Project", filtered.get(0).getProject().getName());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Project(org.jboss.pnc.dto.Project) Test(org.junit.Test)

Example 2 with Project

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

the class ProjectEndpointTest method shouldPatchProject.

@Test
public void shouldPatchProject() throws ClientException, PatchBuilderException {
    Project project = client.getAll().iterator().next();
    String newDescription = "Testing patch support";
    String newUrl = "http://example.com";
    String id = project.getId();
    ProjectPatchBuilder builder = new ProjectPatchBuilder().replaceDescription(newDescription).replaceProjectUrl(newUrl);
    Project updated = client.patch(id, builder);
    assertThat(updated.getDescription()).isEqualTo(newDescription);
    assertThat(updated.getProjectUrl()).isEqualTo(newUrl);
    String newDescription2 = "Testing patch support 2";
    ProjectPatchBuilder builder2 = new ProjectPatchBuilder().replaceDescription(newDescription2);
    Project updated2 = client.patch(id, builder2.getJsonPatch(), Project.class);
    assertThat(updated2.getDescription()).isEqualTo(newDescription2);
}
Also used : Project(org.jboss.pnc.dto.Project) ProjectPatchBuilder(org.jboss.pnc.client.patch.ProjectPatchBuilder) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 3 with Project

use of org.jboss.pnc.dto.Project 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 4 with Project

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

the class SecondLevelCacheStoreTest method prepareData.

/**
 * At first we need to create testing data and commit it.
 */
@Test
@InSequence(-2)
public void prepareData() throws Exception {
    EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asAnonymous());
    environmentId = client.getAll().iterator().next().getId();
    SCMRepositoryClient scmrc = new SCMRepositoryClient(RestClientConfiguration.asAnonymous());
    final Iterator<SCMRepository> scmrIt = scmrc.getAll(null, null).iterator();
    repositoryConfigurationBCId = scmrIt.next().getId();
    repositoryConfigurationDepBCId = scmrIt.next().getId();
    Project projectBC = createProjectAndValidateResults("https://github.com/project-ncl/dependency-analysis", null, "Dependency Analysis New", "Dependency Analysis - Analise project dependencies.");
    Project projectDepBC = createProjectAndValidateResults("https://github.com/project-ncl/pnc", null, "Project Newcastle Demo Project 1 New", "Example Project for Newcastle Demo");
    projectBCId = projectBC.getId();
    projectDepBCId = projectDepBC.getId();
    BuildConfiguration dependencyBC = createBuildConfigurationAndValidateResults(projectDepBCId, environmentId, repositoryConfigurationDepBCId, "pnc-1.0.0.DR1-new", UUID.randomUUID().toString());
    BuildConfiguration buildConfiguration = createBuildConfigurationAndValidateResults(projectBCId, environmentId, repositoryConfigurationBCId, "dependency-analysis-master-new", UUID.randomUUID().toString());
    dependencyBCId = dependencyBC.getId();
    buildConfigurationId = buildConfiguration.getId();
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) SCMRepositoryClient(org.jboss.pnc.client.SCMRepositoryClient) Project(org.jboss.pnc.dto.Project) EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) SCMRepository(org.jboss.pnc.dto.SCMRepository) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 5 with Project

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

the class SecondLevelCacheStoreTest method createProjectAndValidateResults.

private Project createProjectAndValidateResults(String projectUrl, String issueTrackerUrl, String name, String description) throws ClientException {
    Project project = Project.builder().projectUrl(projectUrl).issueTrackerUrl(issueTrackerUrl).name(name).description(description).build();
    // when
    Project created = projectClient.createNew(project);
    // then
    assertThat(created.getId()).isNotNull().isNotEmpty();
    assertThat(created.getName()).isEqualTo(project.getName());
    assertThat(created.getProjectUrl()).isEqualTo(project.getProjectUrl());
    assertThat(created.getIssueTrackerUrl()).isEqualTo(project.getIssueTrackerUrl());
    return created;
}
Also used : Project(org.jboss.pnc.dto.Project)

Aggregations

Project (org.jboss.pnc.dto.Project)11 Test (org.junit.Test)9 ContainerTest (org.jboss.pnc.test.category.ContainerTest)8 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)3 InSequence (org.jboss.arquillian.junit.InSequence)2 SCMRepository (org.jboss.pnc.dto.SCMRepository)2 Path (java.nio.file.Path)1 AbstractTest (org.jboss.pnc.bacon.test.AbstractTest)1 ExecutionResult (org.jboss.pnc.bacon.test.ExecutionResult)1 EnvironmentClient (org.jboss.pnc.client.EnvironmentClient)1 SCMRepositoryClient (org.jboss.pnc.client.SCMRepositoryClient)1 ProjectPatchBuilder (org.jboss.pnc.client.patch.ProjectPatchBuilder)1 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)1 Environment (org.jboss.pnc.dto.Environment)1 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)1 Product (org.jboss.pnc.dto.Product)1 ProductMilestone (org.jboss.pnc.dto.ProductMilestone)1 ProductVersion (org.jboss.pnc.dto.ProductVersion)1 Order (org.junit.jupiter.api.Order)1 Test (org.junit.jupiter.api.Test)1