コード例 #1
0
  public void testFindByC_R_P() throws Exception {
    Content content1 = addContent();

    long contentId2 = content1.getContentId() + 1;

    String version2 = content1.getVersion().concat("-2");

    int size = (int) content1.getSize();

    Blob data = new OutputBlob(new ByteArrayInputStream(new byte[size]), size);

    Content content2 =
        new Content(
            contentId2,
            content1.getCompanyId(),
            content1.getPortletId(),
            content1.getGroupId(),
            content1.getRepositoryId(),
            content1.getPath(),
            version2,
            data,
            size);

    _persistence.update(content2);

    Content existingContent2 =
        _persistence.findByC_R_P(
            content1.getCompanyId(), content1.getRepositoryId(), content1.getPath());

    assertTrue(existingContent2.equals(content2));

    _persistence.remove(existingContent2.getContentId());

    Content existingContent1 =
        _persistence.findByC_R_P(
            content1.getCompanyId(), content1.getRepositoryId(), content1.getPath());

    assertTrue(existingContent1.equals(content1));

    _persistence.remove(existingContent1.getContentId());

    try {
      _persistence.findByC_R_P(
          content1.getCompanyId(), content1.getRepositoryId(), content1.getPath());

      fail("Missing entity did not throw NoSuchContentException");
    } catch (NoSuchContentException nsce) {
    }
  }
コード例 #2
0
  public void testFetchByC_R_P() throws Exception {
    Content content1 = addContent();

    long contentId2 = content1.getContentId() + 1;

    String version2 = content1.getVersion().concat("-2");

    int size = (int) content1.getSize();

    Blob data = new OutputBlob(new ByteArrayInputStream(new byte[size]), size);

    Content content2 =
        new Content(
            contentId2,
            content1.getCompanyId(),
            content1.getPortletId(),
            content1.getGroupId(),
            content1.getRepositoryId(),
            content1.getPath(),
            version2,
            data,
            size);

    _persistence.update(content2);

    Content existingContent2 =
        _persistence.fetchByC_R_P(
            content1.getCompanyId(), content1.getRepositoryId(), content1.getPath());

    assertTrue(existingContent2.equals(content2));

    _persistence.remove(existingContent2.getContentId());

    Content existingContent1 =
        _persistence.fetchByC_R_P(
            content1.getCompanyId(), content1.getRepositoryId(), content1.getPath());

    assertTrue(existingContent1.equals(content1));

    _persistence.remove(existingContent1.getContentId());

    Content missingContent =
        _persistence.fetchByC_R_P(
            content1.getCompanyId(), content1.getRepositoryId(), content1.getPath());

    assertNull(missingContent);
  }