@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());
  }
  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;
  }
  @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;
  }