@Test public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception { Address newAddress = addAddress(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newAddress.getPrimaryKey()); Map<Serializable, Address> addresses = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, addresses.size()); Assert.assertEquals(newAddress, addresses.get(newAddress.getPrimaryKey())); }
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception { Address newAddress = addAddress(); long pk = RandomTestUtil.nextLong(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newAddress.getPrimaryKey()); primaryKeys.add(pk); Map<Serializable, Address> addresses = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, addresses.size()); Assert.assertEquals(newAddress, addresses.get(newAddress.getPrimaryKey())); }
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist() throws Exception { Address newAddress1 = addAddress(); Address newAddress2 = addAddress(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newAddress1.getPrimaryKey()); primaryKeys.add(newAddress2.getPrimaryKey()); Map<Serializable, Address> addresses = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(2, addresses.size()); Assert.assertEquals(newAddress1, addresses.get(newAddress1.getPrimaryKey())); Assert.assertEquals(newAddress2, addresses.get(newAddress2.getPrimaryKey())); }
@Test public void testFetchByPrimaryKeyExisting() throws Exception { Address newAddress = addAddress(); Address existingAddress = _persistence.fetchByPrimaryKey(newAddress.getPrimaryKey()); Assert.assertEquals(existingAddress, newAddress); }
@Test public void testRemove() throws Exception { Address newAddress = addAddress(); _persistence.remove(newAddress); Address existingAddress = _persistence.fetchByPrimaryKey(newAddress.getPrimaryKey()); Assert.assertNull(existingAddress); }
@Test public void testCreate() throws Exception { long pk = RandomTestUtil.nextLong(); Address address = _persistence.create(pk); Assert.assertNotNull(address); Assert.assertEquals(address.getPrimaryKey(), pk); }
@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); Address newAddress = _persistence.create(pk); newAddress.setMvccVersion(RandomTestUtil.nextLong()); newAddress.setUuid(RandomTestUtil.randomString()); newAddress.setCompanyId(RandomTestUtil.nextLong()); newAddress.setUserId(RandomTestUtil.nextLong()); newAddress.setUserName(RandomTestUtil.randomString()); newAddress.setCreateDate(RandomTestUtil.nextDate()); newAddress.setModifiedDate(RandomTestUtil.nextDate()); newAddress.setClassNameId(RandomTestUtil.nextLong()); newAddress.setClassPK(RandomTestUtil.nextLong()); newAddress.setStreet1(RandomTestUtil.randomString()); newAddress.setStreet2(RandomTestUtil.randomString()); newAddress.setStreet3(RandomTestUtil.randomString()); newAddress.setCity(RandomTestUtil.randomString()); newAddress.setZip(RandomTestUtil.randomString()); newAddress.setRegionId(RandomTestUtil.nextLong()); newAddress.setCountryId(RandomTestUtil.nextLong()); newAddress.setTypeId(RandomTestUtil.nextLong()); newAddress.setMailing(RandomTestUtil.randomBoolean()); newAddress.setPrimary(RandomTestUtil.randomBoolean()); newAddress.setLastPublishDate(RandomTestUtil.nextDate()); _addresses.add(_persistence.update(newAddress)); Address existingAddress = _persistence.findByPrimaryKey(newAddress.getPrimaryKey()); Assert.assertEquals(existingAddress.getMvccVersion(), newAddress.getMvccVersion()); Assert.assertEquals(existingAddress.getUuid(), newAddress.getUuid()); Assert.assertEquals(existingAddress.getAddressId(), newAddress.getAddressId()); Assert.assertEquals(existingAddress.getCompanyId(), newAddress.getCompanyId()); Assert.assertEquals(existingAddress.getUserId(), newAddress.getUserId()); Assert.assertEquals(existingAddress.getUserName(), newAddress.getUserName()); Assert.assertEquals( Time.getShortTimestamp(existingAddress.getCreateDate()), Time.getShortTimestamp(newAddress.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingAddress.getModifiedDate()), Time.getShortTimestamp(newAddress.getModifiedDate())); Assert.assertEquals(existingAddress.getClassNameId(), newAddress.getClassNameId()); Assert.assertEquals(existingAddress.getClassPK(), newAddress.getClassPK()); Assert.assertEquals(existingAddress.getStreet1(), newAddress.getStreet1()); Assert.assertEquals(existingAddress.getStreet2(), newAddress.getStreet2()); Assert.assertEquals(existingAddress.getStreet3(), newAddress.getStreet3()); Assert.assertEquals(existingAddress.getCity(), newAddress.getCity()); Assert.assertEquals(existingAddress.getZip(), newAddress.getZip()); Assert.assertEquals(existingAddress.getRegionId(), newAddress.getRegionId()); Assert.assertEquals(existingAddress.getCountryId(), newAddress.getCountryId()); Assert.assertEquals(existingAddress.getTypeId(), newAddress.getTypeId()); Assert.assertEquals(existingAddress.getMailing(), newAddress.getMailing()); Assert.assertEquals(existingAddress.getPrimary(), newAddress.getPrimary()); Assert.assertEquals( Time.getShortTimestamp(existingAddress.getLastPublishDate()), Time.getShortTimestamp(newAddress.getLastPublishDate())); }