コード例 #1
0
  @Test
  public void testRemoveProductContent() {
    Product p = createTestProduct();
    Content content =
        new Content(
            this.owner,
            "test-content",
            "test-content",
            "test-content",
            "yum",
            "us",
            "here",
            "here",
            "test-arch");
    p.addContent(content);
    contentCurator.create(content);
    productCurator.create(p);

    p = productCurator.find(p.getUuid());
    assertEquals(1, p.getProductContent().size());

    productCurator.removeProductContent(p, content);
    p = productCurator.find(p.getUuid());
    assertEquals(0, p.getProductContent().size());
  }
コード例 #2
0
  @Before
  public void setUp() {
    owner = new Owner("test-owner", "Test Owner");
    owner = ownerCurator.create(owner);

    e = new Environment("env1", "Env 1", owner);
    envCurator.create(e);

    p = TestUtil.createProduct(owner);
    c =
        new Content(
            this.owner,
            "testcontent",
            "contentId1",
            "testcontent",
            "yum",
            "red hat",
            "http://example.com",
            "http://example.com/gpg.key",
            "test-arch");
    contentCurator.create(c);
    p.addContent(c);
    productCurator.create(p);

    envContent = new EnvironmentContent(e, c, true);
    envContent = envContentCurator.create(envContent);
  }
コード例 #3
0
  @Test
  public void testSaveOrUpdateProductNoDuplicateProdContent() {
    Product p = createTestProduct();
    Content content =
        new Content(
            this.owner,
            "best-content",
            "best-content",
            "best-content",
            "yum",
            "us",
            "here",
            "here",
            "test-arch");

    p.addContent(content);
    contentCurator.create(content);
    productCurator.createOrUpdate(p);

    // Technically the same product:
    Product p2 = createTestProduct();

    // The content isn't quite the same. We just care about matching
    // product ids with content ids
    Content contentUpdate =
        new Content(
            this.owner,
            "best-content",
            "best-content",
            "best-content",
            "yum",
            "us",
            "here",
            "differnet",
            "test-arch");

    contentUpdate.setUuid(content.getUuid());

    p2.addContent(contentUpdate);
    productCurator.createOrUpdate(p2);

    Product result = productCurator.find(p.getUuid());
    assertEquals(1, result.getProductContent().size());
  }
コード例 #4
0
  @Test
  public void testGetProductIdFromContentUuid() {
    Product p = createTestProduct();
    Content content =
        new Content(
            this.owner,
            "best-content",
            "best-content",
            "best-content",
            "yum",
            "us",
            "here",
            "here",
            "test-arch");
    p.addContent(content);
    contentCurator.create(content);
    productCurator.create(p);

    List<String> contentUuids = new LinkedList<String>();
    contentUuids.add(content.getUuid());
    List<Product> products = productCurator.getProductsWithContent(contentUuids);
    assertEquals(1, products.size());
    assertEquals(p, products.get(0));
  }