@Test public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception { RosterMember newRosterMember = addRosterMember(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newRosterMember.getPrimaryKey()); Map<Serializable, RosterMember> rosterMembers = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, rosterMembers.size()); Assert.assertEquals(newRosterMember, rosterMembers.get(newRosterMember.getPrimaryKey())); }
@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); RosterMember newRosterMember = _persistence.create(pk); newRosterMember.setUuid(RandomTestUtil.randomString()); newRosterMember.setCreateDate(RandomTestUtil.nextDate()); newRosterMember.setModifiedDate(RandomTestUtil.nextDate()); newRosterMember.setRosterId(RandomTestUtil.nextLong()); newRosterMember.setContactId(RandomTestUtil.nextLong()); _rosterMembers.add(_persistence.update(newRosterMember)); RosterMember existingRosterMember = _persistence.findByPrimaryKey(newRosterMember.getPrimaryKey()); Assert.assertEquals(existingRosterMember.getUuid(), newRosterMember.getUuid()); Assert.assertEquals( existingRosterMember.getRosterMemberId(), newRosterMember.getRosterMemberId()); Assert.assertEquals( Time.getShortTimestamp(existingRosterMember.getCreateDate()), Time.getShortTimestamp(newRosterMember.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingRosterMember.getModifiedDate()), Time.getShortTimestamp(newRosterMember.getModifiedDate())); Assert.assertEquals(existingRosterMember.getRosterId(), newRosterMember.getRosterId()); Assert.assertEquals(existingRosterMember.getContactId(), newRosterMember.getContactId()); }
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception { RosterMember newRosterMember = addRosterMember(); long pk = RandomTestUtil.nextLong(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newRosterMember.getPrimaryKey()); primaryKeys.add(pk); Map<Serializable, RosterMember> rosterMembers = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, rosterMembers.size()); Assert.assertEquals(newRosterMember, rosterMembers.get(newRosterMember.getPrimaryKey())); }
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist() throws Exception { RosterMember newRosterMember1 = addRosterMember(); RosterMember newRosterMember2 = addRosterMember(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newRosterMember1.getPrimaryKey()); primaryKeys.add(newRosterMember2.getPrimaryKey()); Map<Serializable, RosterMember> rosterMembers = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(2, rosterMembers.size()); Assert.assertEquals(newRosterMember1, rosterMembers.get(newRosterMember1.getPrimaryKey())); Assert.assertEquals(newRosterMember2, rosterMembers.get(newRosterMember2.getPrimaryKey())); }
@Test public void testFetchByPrimaryKeyExisting() throws Exception { RosterMember newRosterMember = addRosterMember(); RosterMember existingRosterMember = _persistence.fetchByPrimaryKey(newRosterMember.getPrimaryKey()); Assert.assertEquals(existingRosterMember, newRosterMember); }
@Test public void testCreate() throws Exception { long pk = RandomTestUtil.nextLong(); RosterMember rosterMember = _persistence.create(pk); Assert.assertNotNull(rosterMember); Assert.assertEquals(rosterMember.getPrimaryKey(), pk); }
@Test public void testRemove() throws Exception { RosterMember newRosterMember = addRosterMember(); _persistence.remove(newRosterMember); RosterMember existingRosterMember = _persistence.fetchByPrimaryKey(newRosterMember.getPrimaryKey()); Assert.assertNull(existingRosterMember); }