@Test
  public void testFetchByPrimaryKeyExisting() throws Exception {
    Website newWebsite = addWebsite();

    Website existingWebsite = _persistence.fetchByPrimaryKey(newWebsite.getPrimaryKey());

    Assert.assertEquals(existingWebsite, newWebsite);
  }
  @Test
  public void testRemove() throws Exception {
    Website newWebsite = addWebsite();

    _persistence.remove(newWebsite);

    Website existingWebsite = _persistence.fetchByPrimaryKey(newWebsite.getPrimaryKey());

    Assert.assertNull(existingWebsite);
  }
  @Test
  public void testCreate() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Website website = _persistence.create(pk);

    Assert.assertNotNull(website);

    Assert.assertEquals(website.getPrimaryKey(), pk);
  }
  @Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    Website newWebsite = addWebsite();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newWebsite.getPrimaryKey());

    Map<Serializable, Website> websites = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, websites.size());
    Assert.assertEquals(newWebsite, websites.get(newWebsite.getPrimaryKey()));
  }
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    Website newWebsite = addWebsite();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(Website.class, _dynamicQueryClassLoader);

    dynamicQuery.add(RestrictionsFactoryUtil.eq("websiteId", newWebsite.getWebsiteId()));

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

    Assert.assertEquals(1, result.size());

    Website existingWebsite = result.get(0);

    Assert.assertEquals(existingWebsite, newWebsite);
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    Website newWebsite = addWebsite();

    long pk = RandomTestUtil.nextLong();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newWebsite.getPrimaryKey());
    primaryKeys.add(pk);

    Map<Serializable, Website> websites = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, websites.size());
    Assert.assertEquals(newWebsite, websites.get(newWebsite.getPrimaryKey()));
  }
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    Website newWebsite = addWebsite();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(Website.class, _dynamicQueryClassLoader);

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

    Object newWebsiteId = newWebsite.getWebsiteId();

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

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

    Assert.assertEquals(1, result.size());

    Object existingWebsiteId = result.get(0);

    Assert.assertEquals(existingWebsiteId, newWebsiteId);
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    Website newWebsite1 = addWebsite();
    Website newWebsite2 = addWebsite();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newWebsite1.getPrimaryKey());
    primaryKeys.add(newWebsite2.getPrimaryKey());

    Map<Serializable, Website> websites = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, websites.size());
    Assert.assertEquals(newWebsite1, websites.get(newWebsite1.getPrimaryKey()));
    Assert.assertEquals(newWebsite2, websites.get(newWebsite2.getPrimaryKey()));
  }
  protected Website addWebsite() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Website website = _persistence.create(pk);

    website.setMvccVersion(RandomTestUtil.nextLong());

    website.setUuid(RandomTestUtil.randomString());

    website.setCompanyId(RandomTestUtil.nextLong());

    website.setUserId(RandomTestUtil.nextLong());

    website.setUserName(RandomTestUtil.randomString());

    website.setCreateDate(RandomTestUtil.nextDate());

    website.setModifiedDate(RandomTestUtil.nextDate());

    website.setClassNameId(RandomTestUtil.nextLong());

    website.setClassPK(RandomTestUtil.nextLong());

    website.setUrl(RandomTestUtil.randomString());

    website.setTypeId(RandomTestUtil.nextLong());

    website.setPrimary(RandomTestUtil.randomBoolean());

    website.setLastPublishDate(RandomTestUtil.nextDate());

    _websites.add(_persistence.update(website));

    return website;
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Website newWebsite = _persistence.create(pk);

    newWebsite.setMvccVersion(RandomTestUtil.nextLong());

    newWebsite.setUuid(RandomTestUtil.randomString());

    newWebsite.setCompanyId(RandomTestUtil.nextLong());

    newWebsite.setUserId(RandomTestUtil.nextLong());

    newWebsite.setUserName(RandomTestUtil.randomString());

    newWebsite.setCreateDate(RandomTestUtil.nextDate());

    newWebsite.setModifiedDate(RandomTestUtil.nextDate());

    newWebsite.setClassNameId(RandomTestUtil.nextLong());

    newWebsite.setClassPK(RandomTestUtil.nextLong());

    newWebsite.setUrl(RandomTestUtil.randomString());

    newWebsite.setTypeId(RandomTestUtil.nextLong());

    newWebsite.setPrimary(RandomTestUtil.randomBoolean());

    newWebsite.setLastPublishDate(RandomTestUtil.nextDate());

    _websites.add(_persistence.update(newWebsite));

    Website existingWebsite = _persistence.findByPrimaryKey(newWebsite.getPrimaryKey());

    Assert.assertEquals(existingWebsite.getMvccVersion(), newWebsite.getMvccVersion());
    Assert.assertEquals(existingWebsite.getUuid(), newWebsite.getUuid());
    Assert.assertEquals(existingWebsite.getWebsiteId(), newWebsite.getWebsiteId());
    Assert.assertEquals(existingWebsite.getCompanyId(), newWebsite.getCompanyId());
    Assert.assertEquals(existingWebsite.getUserId(), newWebsite.getUserId());
    Assert.assertEquals(existingWebsite.getUserName(), newWebsite.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingWebsite.getCreateDate()),
        Time.getShortTimestamp(newWebsite.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingWebsite.getModifiedDate()),
        Time.getShortTimestamp(newWebsite.getModifiedDate()));
    Assert.assertEquals(existingWebsite.getClassNameId(), newWebsite.getClassNameId());
    Assert.assertEquals(existingWebsite.getClassPK(), newWebsite.getClassPK());
    Assert.assertEquals(existingWebsite.getUrl(), newWebsite.getUrl());
    Assert.assertEquals(existingWebsite.getTypeId(), newWebsite.getTypeId());
    Assert.assertEquals(existingWebsite.getPrimary(), newWebsite.getPrimary());
    Assert.assertEquals(
        Time.getShortTimestamp(existingWebsite.getLastPublishDate()),
        Time.getShortTimestamp(newWebsite.getLastPublishDate()));
  }