コード例 #1
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());
  }
コード例 #2
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);
  }
コード例 #3
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);
  }