コード例 #1
0
  public void testFindByPrimaryKeyExisting() throws Exception {
    DDMStructureLink newDDMStructureLink = addDDMStructureLink();

    DDMStructureLink existingDDMStructureLink =
        _persistence.findByPrimaryKey(newDDMStructureLink.getPrimaryKey());

    assertEquals(existingDDMStructureLink, newDDMStructureLink);
  }
コード例 #2
0
  public void testCreate() throws Exception {
    long pk = nextLong();

    DDMStructureLink ddmStructureLink = _persistence.create(pk);

    assertNotNull(ddmStructureLink);

    assertEquals(ddmStructureLink.getPrimaryKey(), pk);
  }
コード例 #3
0
  public void testRemove() throws Exception {
    DDMStructureLink newDDMStructureLink = addDDMStructureLink();

    _persistence.remove(newDDMStructureLink);

    DDMStructureLink existingDDMStructureLink =
        _persistence.fetchByPrimaryKey(newDDMStructureLink.getPrimaryKey());

    assertNull(existingDDMStructureLink);
  }
コード例 #4
0
  protected DDMStructureLink addDDMStructureLink() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    DDMStructureLink ddmStructureLink = _persistence.create(pk);

    ddmStructureLink.setClassNameId(ServiceTestUtil.nextLong());

    ddmStructureLink.setClassPK(ServiceTestUtil.nextLong());

    ddmStructureLink.setStructureId(ServiceTestUtil.nextLong());

    _persistence.update(ddmStructureLink);

    return ddmStructureLink;
  }
  protected Set<Long> getExistingDDMStructureLinkStructureIds(long fileEntryTypeId) {

    long classNameId = classNameLocalService.getClassNameId(DLFileEntryType.class);

    Set<Long> existingDDMStructureLinkStructureIds = new HashSet<>();

    List<DDMStructureLink> structureLinks =
        ddmStructureLinkLocalService.getStructureLinks(classNameId, fileEntryTypeId);

    for (DDMStructureLink structureLink : structureLinks) {
      existingDDMStructureLinkStructureIds.add(structureLink.getStructureId());
    }

    return existingDDMStructureLinkStructureIds;
  }
コード例 #6
0
  protected DDMStructureLink addDDMStructureLink() throws Exception {
    long pk = nextLong();

    DDMStructureLink ddmStructureLink = _persistence.create(pk);

    ddmStructureLink.setClassNameId(nextLong());

    ddmStructureLink.setClassPK(nextLong());

    ddmStructureLink.setStructureId(nextLong());

    _persistence.update(ddmStructureLink, false);

    return ddmStructureLink;
  }
コード例 #7
0
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    DDMStructureLink newDDMStructureLink = addDDMStructureLink();

    _persistence.clearCache();

    DDMStructureLinkModelImpl existingDDMStructureLinkModelImpl =
        (DDMStructureLinkModelImpl)
            _persistence.findByPrimaryKey(newDDMStructureLink.getPrimaryKey());

    assertEquals(
        existingDDMStructureLinkModelImpl.getClassPK(),
        existingDDMStructureLinkModelImpl.getOriginalClassPK());
  }
コード例 #8
0
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    DDMStructureLink newDDMStructureLink = addDDMStructureLink();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(
            DDMStructureLink.class, DDMStructureLink.class.getClassLoader());

    dynamicQuery.add(
        RestrictionsFactoryUtil.eq("structureLinkId", newDDMStructureLink.getStructureLinkId()));

    List<DDMStructureLink> result = _persistence.findWithDynamicQuery(dynamicQuery);

    assertEquals(1, result.size());

    DDMStructureLink existingDDMStructureLink = result.get(0);

    assertEquals(existingDDMStructureLink, newDDMStructureLink);
  }
コード例 #9
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (!(obj instanceof DDMStructureLink)) {
      return false;
    }

    DDMStructureLink ddmStructureLink = (DDMStructureLink) obj;

    long primaryKey = ddmStructureLink.getPrimaryKey();

    if (getPrimaryKey() == primaryKey) {
      return true;
    } else {
      return false;
    }
  }
コード例 #10
0
  @Override
  public int compareTo(DDMStructureLink ddmStructureLink) {
    long primaryKey = ddmStructureLink.getPrimaryKey();

    if (getPrimaryKey() < primaryKey) {
      return -1;
    } else if (getPrimaryKey() > primaryKey) {
      return 1;
    } else {
      return 0;
    }
  }
  @Override
  public List<DLFileEntryType> getFileEntryTypes(long ddmStructureId) throws PortalException {

    List<DLFileEntryType> fileEntryTypes = new ArrayList<>();

    long classNameId = classNameLocalService.getClassNameId(DLFileEntryType.class);

    List<DDMStructureLink> ddmStructureLinks =
        ddmStructureLinkLocalService.getClassNameStructureLinks(classNameId);

    for (DDMStructureLink ddmStructureLink : ddmStructureLinks) {
      if (ddmStructureId != ddmStructureLink.getStructureId()) {
        continue;
      }

      DLFileEntryType fileEntryType = getFileEntryType(ddmStructureLink.getClassPK());

      fileEntryTypes.add(fileEntryType);
    }

    return fileEntryTypes;
  }
コード例 #12
0
  public void testDynamicQueryByProjectionExisting() throws Exception {
    DDMStructureLink newDDMStructureLink = addDDMStructureLink();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(
            DDMStructureLink.class, DDMStructureLink.class.getClassLoader());

    dynamicQuery.setProjection(ProjectionFactoryUtil.property("structureLinkId"));

    Object newStructureLinkId = newDDMStructureLink.getStructureLinkId();

    dynamicQuery.add(
        RestrictionsFactoryUtil.in("structureLinkId", new Object[] {newStructureLinkId}));

    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);

    assertEquals(1, result.size());

    Object existingStructureLinkId = result.get(0);

    assertEquals(existingStructureLinkId, newStructureLinkId);
  }
コード例 #13
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    DDMStructureLink newDDMStructureLink = _persistence.create(pk);

    newDDMStructureLink.setClassNameId(ServiceTestUtil.nextLong());

    newDDMStructureLink.setClassPK(ServiceTestUtil.nextLong());

    newDDMStructureLink.setStructureId(ServiceTestUtil.nextLong());

    _persistence.update(newDDMStructureLink);

    DDMStructureLink existingDDMStructureLink =
        _persistence.findByPrimaryKey(newDDMStructureLink.getPrimaryKey());

    Assert.assertEquals(
        existingDDMStructureLink.getStructureLinkId(), newDDMStructureLink.getStructureLinkId());
    Assert.assertEquals(
        existingDDMStructureLink.getClassNameId(), newDDMStructureLink.getClassNameId());
    Assert.assertEquals(existingDDMStructureLink.getClassPK(), newDDMStructureLink.getClassPK());
    Assert.assertEquals(
        existingDDMStructureLink.getStructureId(), newDDMStructureLink.getStructureId());
  }