@Test public void testFetchByPrimaryKeyExisting() throws Exception { MeetupsRegistration newMeetupsRegistration = addMeetupsRegistration(); MeetupsRegistration existingMeetupsRegistration = _persistence.fetchByPrimaryKey(newMeetupsRegistration.getPrimaryKey()); Assert.assertEquals(existingMeetupsRegistration, newMeetupsRegistration); }
@Test public void testCreate() throws Exception { long pk = RandomTestUtil.nextLong(); MeetupsRegistration meetupsRegistration = _persistence.create(pk); Assert.assertNotNull(meetupsRegistration); Assert.assertEquals(meetupsRegistration.getPrimaryKey(), pk); }
protected MeetupsRegistration addMeetupsRegistration() throws Exception { long pk = RandomTestUtil.nextLong(); MeetupsRegistration meetupsRegistration = _persistence.create(pk); meetupsRegistration.setCompanyId(RandomTestUtil.nextLong()); meetupsRegistration.setUserId(RandomTestUtil.nextLong()); meetupsRegistration.setUserName(RandomTestUtil.randomString()); meetupsRegistration.setCreateDate(RandomTestUtil.nextDate()); meetupsRegistration.setModifiedDate(RandomTestUtil.nextDate()); meetupsRegistration.setMeetupsEntryId(RandomTestUtil.nextLong()); meetupsRegistration.setStatus(RandomTestUtil.nextInt()); meetupsRegistration.setComments(RandomTestUtil.randomString()); _meetupsRegistrations.add(_persistence.update(meetupsRegistration)); return meetupsRegistration; }
@Test public void testRemove() throws Exception { MeetupsRegistration newMeetupsRegistration = addMeetupsRegistration(); _persistence.remove(newMeetupsRegistration); MeetupsRegistration existingMeetupsRegistration = _persistence.fetchByPrimaryKey(newMeetupsRegistration.getPrimaryKey()); Assert.assertNull(existingMeetupsRegistration); }
@Test public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception { MeetupsRegistration newMeetupsRegistration = addMeetupsRegistration(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newMeetupsRegistration.getPrimaryKey()); Map<Serializable, MeetupsRegistration> meetupsRegistrations = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, meetupsRegistrations.size()); Assert.assertEquals( newMeetupsRegistration, meetupsRegistrations.get(newMeetupsRegistration.getPrimaryKey())); }
@Test public void testResetOriginalValues() throws Exception { MeetupsRegistration newMeetupsRegistration = addMeetupsRegistration(); _persistence.clearCache(); MeetupsRegistration existingMeetupsRegistration = _persistence.findByPrimaryKey(newMeetupsRegistration.getPrimaryKey()); Assert.assertEquals( Long.valueOf(existingMeetupsRegistration.getUserId()), ReflectionTestUtil.<Long>invoke( existingMeetupsRegistration, "getOriginalUserId", new Class<?>[0])); Assert.assertEquals( Long.valueOf(existingMeetupsRegistration.getMeetupsEntryId()), ReflectionTestUtil.<Long>invoke( existingMeetupsRegistration, "getOriginalMeetupsEntryId", new Class<?>[0])); }
@Test public void testDynamicQueryByPrimaryKeyExisting() throws Exception { MeetupsRegistration newMeetupsRegistration = addMeetupsRegistration(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(MeetupsRegistration.class, _dynamicQueryClassLoader); dynamicQuery.add( RestrictionsFactoryUtil.eq( "meetupsRegistrationId", newMeetupsRegistration.getMeetupsRegistrationId())); List<MeetupsRegistration> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); MeetupsRegistration existingMeetupsRegistration = result.get(0); Assert.assertEquals(existingMeetupsRegistration, newMeetupsRegistration); }
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception { MeetupsRegistration newMeetupsRegistration = addMeetupsRegistration(); long pk = RandomTestUtil.nextLong(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newMeetupsRegistration.getPrimaryKey()); primaryKeys.add(pk); Map<Serializable, MeetupsRegistration> meetupsRegistrations = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, meetupsRegistrations.size()); Assert.assertEquals( newMeetupsRegistration, meetupsRegistrations.get(newMeetupsRegistration.getPrimaryKey())); }
@Test public void testDynamicQueryByProjectionExisting() throws Exception { MeetupsRegistration newMeetupsRegistration = addMeetupsRegistration(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(MeetupsRegistration.class, _dynamicQueryClassLoader); dynamicQuery.setProjection(ProjectionFactoryUtil.property("meetupsRegistrationId")); Object newMeetupsRegistrationId = newMeetupsRegistration.getMeetupsRegistrationId(); dynamicQuery.add( RestrictionsFactoryUtil.in( "meetupsRegistrationId", new Object[] {newMeetupsRegistrationId})); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Object existingMeetupsRegistrationId = result.get(0); Assert.assertEquals(existingMeetupsRegistrationId, newMeetupsRegistrationId); }
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist() throws Exception { MeetupsRegistration newMeetupsRegistration1 = addMeetupsRegistration(); MeetupsRegistration newMeetupsRegistration2 = addMeetupsRegistration(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newMeetupsRegistration1.getPrimaryKey()); primaryKeys.add(newMeetupsRegistration2.getPrimaryKey()); Map<Serializable, MeetupsRegistration> meetupsRegistrations = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(2, meetupsRegistrations.size()); Assert.assertEquals( newMeetupsRegistration1, meetupsRegistrations.get(newMeetupsRegistration1.getPrimaryKey())); Assert.assertEquals( newMeetupsRegistration2, meetupsRegistrations.get(newMeetupsRegistration2.getPrimaryKey())); }
@Override public Long get(MeetupsRegistration meetupsRegistration) { return meetupsRegistration.getMeetupsRegistrationId(); }
@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); MeetupsRegistration newMeetupsRegistration = _persistence.create(pk); newMeetupsRegistration.setCompanyId(RandomTestUtil.nextLong()); newMeetupsRegistration.setUserId(RandomTestUtil.nextLong()); newMeetupsRegistration.setUserName(RandomTestUtil.randomString()); newMeetupsRegistration.setCreateDate(RandomTestUtil.nextDate()); newMeetupsRegistration.setModifiedDate(RandomTestUtil.nextDate()); newMeetupsRegistration.setMeetupsEntryId(RandomTestUtil.nextLong()); newMeetupsRegistration.setStatus(RandomTestUtil.nextInt()); newMeetupsRegistration.setComments(RandomTestUtil.randomString()); _meetupsRegistrations.add(_persistence.update(newMeetupsRegistration)); MeetupsRegistration existingMeetupsRegistration = _persistence.findByPrimaryKey(newMeetupsRegistration.getPrimaryKey()); Assert.assertEquals( existingMeetupsRegistration.getMeetupsRegistrationId(), newMeetupsRegistration.getMeetupsRegistrationId()); Assert.assertEquals( existingMeetupsRegistration.getCompanyId(), newMeetupsRegistration.getCompanyId()); Assert.assertEquals( existingMeetupsRegistration.getUserId(), newMeetupsRegistration.getUserId()); Assert.assertEquals( existingMeetupsRegistration.getUserName(), newMeetupsRegistration.getUserName()); Assert.assertEquals( Time.getShortTimestamp(existingMeetupsRegistration.getCreateDate()), Time.getShortTimestamp(newMeetupsRegistration.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingMeetupsRegistration.getModifiedDate()), Time.getShortTimestamp(newMeetupsRegistration.getModifiedDate())); Assert.assertEquals( existingMeetupsRegistration.getMeetupsEntryId(), newMeetupsRegistration.getMeetupsEntryId()); Assert.assertEquals( existingMeetupsRegistration.getStatus(), newMeetupsRegistration.getStatus()); Assert.assertEquals( existingMeetupsRegistration.getComments(), newMeetupsRegistration.getComments()); }