List of usage examples for com.liferay.portal.kernel.test.util RandomTestUtil nextLong
public static long nextLong()
From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java
License:Open Source License
@Test public void testCreate() throws Exception { long pk = RandomTestUtil.nextLong(); Foo foo = _persistence.create(pk);//from ww w.j av a 2s . co m Assert.assertNotNull(foo); Assert.assertEquals(foo.getPrimaryKey(), pk); }
From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java
License:Open Source License
@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); Foo newFoo = _persistence.create(pk); newFoo.setUuid(RandomTestUtil.randomString()); newFoo.setGroupId(RandomTestUtil.nextLong()); newFoo.setCompanyId(RandomTestUtil.nextLong()); newFoo.setUserId(RandomTestUtil.nextLong()); newFoo.setUserName(RandomTestUtil.randomString()); newFoo.setCreateDate(RandomTestUtil.nextDate()); newFoo.setModifiedDate(RandomTestUtil.nextDate()); newFoo.setField1(RandomTestUtil.randomString()); newFoo.setField2(RandomTestUtil.randomBoolean()); newFoo.setField3(RandomTestUtil.nextInt()); newFoo.setField4(RandomTestUtil.nextDate()); newFoo.setField5(RandomTestUtil.randomString()); _foos.add(_persistence.update(newFoo)); Foo existingFoo = _persistence.findByPrimaryKey(newFoo.getPrimaryKey()); Assert.assertEquals(existingFoo.getUuid(), newFoo.getUuid()); Assert.assertEquals(existingFoo.getFooId(), newFoo.getFooId()); Assert.assertEquals(existingFoo.getGroupId(), newFoo.getGroupId()); Assert.assertEquals(existingFoo.getCompanyId(), newFoo.getCompanyId()); Assert.assertEquals(existingFoo.getUserId(), newFoo.getUserId()); Assert.assertEquals(existingFoo.getUserName(), newFoo.getUserName()); Assert.assertEquals(Time.getShortTimestamp(existingFoo.getCreateDate()), Time.getShortTimestamp(newFoo.getCreateDate())); Assert.assertEquals(Time.getShortTimestamp(existingFoo.getModifiedDate()), Time.getShortTimestamp(newFoo.getModifiedDate())); Assert.assertEquals(existingFoo.getField1(), newFoo.getField1()); Assert.assertEquals(existingFoo.getField2(), newFoo.getField2()); Assert.assertEquals(existingFoo.getField3(), newFoo.getField3()); Assert.assertEquals(Time.getShortTimestamp(existingFoo.getField4()), Time.getShortTimestamp(newFoo.getField4())); Assert.assertEquals(existingFoo.getField5(), newFoo.getField5()); }
From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java
License:Open Source License
@Test public void testCountByUUID_G() throws Exception { _persistence.countByUUID_G(StringPool.BLANK, RandomTestUtil.nextLong()); _persistence.countByUUID_G(StringPool.NULL, 0L); _persistence.countByUUID_G((String) null, 0L); }
From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java
License:Open Source License
@Test public void testCountByUuid_C() throws Exception { _persistence.countByUuid_C(StringPool.BLANK, RandomTestUtil.nextLong()); _persistence.countByUuid_C(StringPool.NULL, 0L); _persistence.countByUuid_C((String) null, 0L); }
From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java
License:Open Source License
@Test(expected = NoSuchFooException.class) public void testFindByPrimaryKeyMissing() throws Exception { long pk = RandomTestUtil.nextLong(); _persistence.findByPrimaryKey(pk);//from w w w .j ava2 s. c o m }
From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java
License:Open Source License
@Test public void testFetchByPrimaryKeyMissing() throws Exception { long pk = RandomTestUtil.nextLong(); Foo missingFoo = _persistence.fetchByPrimaryKey(pk); Assert.assertNull(missingFoo);/*from w w w . j a v a2 s. co m*/ }
From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java
License:Open Source License
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereNoPrimaryKeysExist() throws Exception { long pk1 = RandomTestUtil.nextLong(); long pk2 = RandomTestUtil.nextLong(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(pk1);//from w w w . java2 s .c o m primaryKeys.add(pk2); Map<Serializable, Foo> foos = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertTrue(foos.isEmpty()); }
From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java
License:Open Source License
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception { Foo newFoo = addFoo();/*ww w .java 2 s. co m*/ long pk = RandomTestUtil.nextLong(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newFoo.getPrimaryKey()); primaryKeys.add(pk); Map<Serializable, Foo> foos = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, foos.size()); Assert.assertEquals(newFoo, foos.get(newFoo.getPrimaryKey())); }
From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java
License:Open Source License
@Test public void testDynamicQueryByPrimaryKeyMissing() throws Exception { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Foo.class, _dynamicQueryClassLoader); dynamicQuery.add(RestrictionsFactoryUtil.eq("fooId", RandomTestUtil.nextLong())); List<Foo> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(0, result.size()); }
From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java
License:Open Source License
@Test public void testDynamicQueryByProjectionMissing() throws Exception { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Foo.class, _dynamicQueryClassLoader); dynamicQuery.setProjection(ProjectionFactoryUtil.property("fooId")); dynamicQuery.add(RestrictionsFactoryUtil.in("fooId", new Object[] { RandomTestUtil.nextLong() })); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(0, result.size()); }