protected VirtualHost addVirtualHost() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    VirtualHost virtualHost = _persistence.create(pk);

    virtualHost.setMvccVersion(ServiceTestUtil.nextLong());

    virtualHost.setCompanyId(ServiceTestUtil.nextLong());

    virtualHost.setLayoutSetId(ServiceTestUtil.nextLong());

    virtualHost.setHostname(ServiceTestUtil.randomString());

    _persistence.update(virtualHost);

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