Search in sources :

Example 6 with Product

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

the class ProductTest method shouldUpdateProduct.

@Test
@Order(3)
void shouldUpdateProduct() throws JsonProcessingException {
    Assumptions.assumeTrue(productId != null);
    Product response = Product.builder().id(productId).name(PRODUCT_NAME_PREFIX + "suffix").build();
    Product updatedResponse = Product.builder().id(productId).name(PRODUCT_NAME_PREFIX + "suffix updated").build();
    wmock.update(PRODUCT, response, updatedResponse);
    Product originalProduct = executeAndDeserialize(Product.class, "pnc", "product", "get", productId);
    String originalName = originalProduct.getName();
    String newName = originalName + " updated";
    execute("pnc", "product", "update", productId, "--name", newName);
    Product refreshedProduct = executeAndDeserialize(Product.class, "pnc", "product", "get", productId);
    assertThat(refreshedProduct.getName()).isEqualTo(newName);
}
Also used : Product(org.jboss.pnc.dto.Product) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) AbstractTest(org.jboss.pnc.bacon.test.AbstractTest) Test(org.junit.jupiter.api.Test)

Example 7 with Product

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

the class ProductTest method shouldCreateProduct.

@Test
@Order(1)
void shouldCreateProduct() throws JsonProcessingException {
    final String suffix = getRandomString();
    final String productName = PRODUCT_NAME_PREFIX + suffix;
    final String abbreviation = "BT-NPN-" + suffix;
    final String description = "BT New Product Description";
    Product response = Product.builder().id("666").name(productName).abbreviation(abbreviation).description(description).build();
    wmock.creation(PRODUCT, response);
    Product product = executeAndDeserialize(Product.class, "-v", "pnc", "product", "create", productName, "--abbreviation", abbreviation, "--description", description);
    assertThat(product.getName()).isEqualTo(productName);
    assertThat(product.getAbbreviation()).isEqualTo(abbreviation);
    assertThat(product.getId()).isNotBlank();
    productId = product.getId();
}
Also used : Product(org.jboss.pnc.dto.Product) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) AbstractTest(org.jboss.pnc.bacon.test.AbstractTest) Test(org.junit.jupiter.api.Test)

Example 8 with Product

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

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

the class ProductTest method shouldGetProduct.

@Test
@Order(2)
void shouldGetProduct() throws JsonProcessingException {
    Assumptions.assumeTrue(productId != null);
    Product response = Product.builder().id(productId).name(PRODUCT_NAME_PREFIX + " suffix").build();
    wmock.get(PRODUCT, response);
    Product product = executeAndDeserialize(Product.class, "pnc", "product", "get", productId);
    assertThat(product.getId()).isEqualTo(productId);
    assertThat(product.getName()).startsWith(PRODUCT_NAME_PREFIX);
}
Also used : Product(org.jboss.pnc.dto.Product) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) AbstractTest(org.jboss.pnc.bacon.test.AbstractTest) Test(org.junit.jupiter.api.Test)

Example 10 with Product

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

the class ProductTest method shouldListProducts.

@Test
@Order(2)
void shouldListProducts() throws JsonProcessingException {
    Assumptions.assumeTrue(productId != null);
    Product response = Product.builder().id(productId).name(PRODUCT_NAME_PREFIX + "suffix").build();
    Page<Product> responsePage = new Page<>(0, 50, 1, Collections.singleton(response));
    wmock.list(PRODUCT, responsePage);
    Product[] products = executeAndDeserialize(Product[].class, "pnc", "product", "list");
    assertThat(products).extracting(Product::getId).contains(productId);
}
Also used : Product(org.jboss.pnc.dto.Product) Page(org.jboss.pnc.dto.response.Page) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) AbstractTest(org.jboss.pnc.bacon.test.AbstractTest) Test(org.junit.jupiter.api.Test)

Aggregations

Product (org.jboss.pnc.dto.Product)17 ProductClient (org.jboss.pnc.client.ProductClient)10 ContainerTest (org.jboss.pnc.test.category.ContainerTest)9 Test (org.junit.Test)9 AbstractTest (org.jboss.pnc.bacon.test.AbstractTest)5 Order (org.junit.jupiter.api.Order)5 Test (org.junit.jupiter.api.Test)5 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)5 InSequence (org.jboss.arquillian.junit.InSequence)4 ClientException (org.jboss.pnc.client.ClientException)4 ProductVersion (org.jboss.pnc.dto.ProductVersion)3 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)2 ProductMilestone (org.jboss.pnc.dto.ProductMilestone)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Instant (java.time.Instant)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Optional (java.util.Optional)1 BadRequestException (javax.ws.rs.BadRequestException)1