@Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    VirtualHost newVirtualHost = addVirtualHost();

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

    primaryKeys.add(newVirtualHost.getPrimaryKey());

    Map<Serializable, VirtualHost> virtualHosts = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, virtualHosts.size());
    Assert.assertEquals(newVirtualHost, virtualHosts.get(newVirtualHost.getPrimaryKey()));
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    VirtualHost newVirtualHost = addVirtualHost();

    _persistence.clearCache();

    VirtualHostModelImpl existingVirtualHostModelImpl =
        (VirtualHostModelImpl) _persistence.findByPrimaryKey(newVirtualHost.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingVirtualHostModelImpl.getHostname(),
            existingVirtualHostModelImpl.getOriginalHostname()));

    Assert.assertEquals(
        existingVirtualHostModelImpl.getCompanyId(),
        existingVirtualHostModelImpl.getOriginalCompanyId());
    Assert.assertEquals(
        existingVirtualHostModelImpl.getLayoutSetId(),
        existingVirtualHostModelImpl.getOriginalLayoutSetId());
  }
  @Test
  public void testFindByPrimaryKeyExisting() throws Exception {
    VirtualHost newVirtualHost = addVirtualHost();

    VirtualHost existingVirtualHost = _persistence.findByPrimaryKey(newVirtualHost.getPrimaryKey());

    Assert.assertEquals(existingVirtualHost, newVirtualHost);
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    VirtualHost newVirtualHost = addVirtualHost();

    long pk = RandomTestUtil.nextLong();

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

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

    Map<Serializable, VirtualHost> virtualHosts = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, virtualHosts.size());
    Assert.assertEquals(newVirtualHost, virtualHosts.get(newVirtualHost.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    VirtualHost newVirtualHost1 = addVirtualHost();
    VirtualHost newVirtualHost2 = addVirtualHost();

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

    primaryKeys.add(newVirtualHost1.getPrimaryKey());
    primaryKeys.add(newVirtualHost2.getPrimaryKey());

    Map<Serializable, VirtualHost> virtualHosts = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, virtualHosts.size());
    Assert.assertEquals(newVirtualHost1, virtualHosts.get(newVirtualHost1.getPrimaryKey()));
    Assert.assertEquals(newVirtualHost2, virtualHosts.get(newVirtualHost2.getPrimaryKey()));
  }
  @Test
  public void testCreate() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    VirtualHost virtualHost = _persistence.create(pk);

    Assert.assertNotNull(virtualHost);

    Assert.assertEquals(virtualHost.getPrimaryKey(), pk);
  }
  public int compareTo(VirtualHost virtualHost) {
    long primaryKey = virtualHost.getPrimaryKey();

    if (getPrimaryKey() < primaryKey) {
      return -1;
    } else if (getPrimaryKey() > primaryKey) {
      return 1;
    } else {
      return 0;
    }
  }
  @Test
  public void testRemove() throws Exception {
    VirtualHost newVirtualHost = addVirtualHost();

    _persistence.remove(newVirtualHost);

    VirtualHost existingVirtualHost =
        _persistence.fetchByPrimaryKey(newVirtualHost.getPrimaryKey());

    Assert.assertNull(existingVirtualHost);
  }
  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }

    VirtualHost virtualHost = null;

    try {
      virtualHost = (VirtualHost) obj;
    } catch (ClassCastException cce) {
      return false;
    }

    long primaryKey = virtualHost.getPrimaryKey();

    if (getPrimaryKey() == primaryKey) {
      return true;
    } else {
      return false;
    }
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    VirtualHost newVirtualHost = _persistence.create(pk);

    newVirtualHost.setMvccVersion(ServiceTestUtil.nextLong());

    newVirtualHost.setCompanyId(ServiceTestUtil.nextLong());

    newVirtualHost.setLayoutSetId(ServiceTestUtil.nextLong());

    newVirtualHost.setHostname(ServiceTestUtil.randomString());

    _persistence.update(newVirtualHost);

    VirtualHost existingVirtualHost = _persistence.findByPrimaryKey(newVirtualHost.getPrimaryKey());

    Assert.assertEquals(existingVirtualHost.getMvccVersion(), newVirtualHost.getMvccVersion());
    Assert.assertEquals(existingVirtualHost.getVirtualHostId(), newVirtualHost.getVirtualHostId());
    Assert.assertEquals(existingVirtualHost.getCompanyId(), newVirtualHost.getCompanyId());
    Assert.assertEquals(existingVirtualHost.getLayoutSetId(), newVirtualHost.getLayoutSetId());
    Assert.assertEquals(existingVirtualHost.getHostname(), newVirtualHost.getHostname());
  }