@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); }
@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 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 testDynamicQueryByPrimaryKeyExisting() throws Exception { RosterMember newRosterMember = addRosterMember(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(RosterMember.class, _dynamicQueryClassLoader); dynamicQuery.add( RestrictionsFactoryUtil.eq("rosterMemberId", newRosterMember.getRosterMemberId())); List<RosterMember> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); RosterMember existingRosterMember = result.get(0); Assert.assertEquals(existingRosterMember, newRosterMember); }
@Test public void testDynamicQueryByProjectionExisting() throws Exception { RosterMember newRosterMember = addRosterMember(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(RosterMember.class, _dynamicQueryClassLoader); dynamicQuery.setProjection(ProjectionFactoryUtil.property("rosterMemberId")); Object newRosterMemberId = newRosterMember.getRosterMemberId(); dynamicQuery.add( RestrictionsFactoryUtil.in("rosterMemberId", new Object[] {newRosterMemberId})); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Object existingRosterMemberId = result.get(0); Assert.assertEquals(existingRosterMemberId, newRosterMemberId); }
@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())); }
protected RosterMember addRosterMember() throws Exception { long pk = RandomTestUtil.nextLong(); RosterMember rosterMember = _persistence.create(pk); rosterMember.setUuid(RandomTestUtil.randomString()); rosterMember.setCreateDate(RandomTestUtil.nextDate()); rosterMember.setModifiedDate(RandomTestUtil.nextDate()); rosterMember.setRosterId(RandomTestUtil.nextLong()); rosterMember.setContactId(RandomTestUtil.nextLong()); _rosterMembers.add(_persistence.update(rosterMember)); return rosterMember; }
@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()); }