use of com.liferay.blade.basic.model.Foo in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testDynamicQueryByPrimaryKeyMissing.
@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());
}
use of com.liferay.blade.basic.model.Foo in project liferay-blade-samples by liferay.
the class FooPersistenceTest method addFoo.
protected Foo addFoo() throws Exception {
long pk = RandomTestUtil.nextLong();
Foo foo = _persistence.create(pk);
foo.setUuid(RandomTestUtil.randomString());
foo.setGroupId(RandomTestUtil.nextLong());
foo.setCompanyId(RandomTestUtil.nextLong());
foo.setUserId(RandomTestUtil.nextLong());
foo.setUserName(RandomTestUtil.randomString());
foo.setCreateDate(RandomTestUtil.nextDate());
foo.setModifiedDate(RandomTestUtil.nextDate());
foo.setField1(RandomTestUtil.randomString());
foo.setField2(RandomTestUtil.randomBoolean());
foo.setField3(RandomTestUtil.nextInt());
foo.setField4(RandomTestUtil.nextDate());
foo.setField5(RandomTestUtil.randomString());
_foos.add(_persistence.update(foo));
return foo;
}
use of com.liferay.blade.basic.model.Foo in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testDynamicQueryByPrimaryKeyExisting.
@Test
public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
Foo newFoo = addFoo();
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Foo.class, _dynamicQueryClassLoader);
dynamicQuery.add(RestrictionsFactoryUtil.eq("fooId", newFoo.getFooId()));
List<Foo> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(1, result.size());
Foo existingFoo = result.get(0);
Assert.assertEquals(existingFoo, newFoo);
}
use of com.liferay.blade.basic.model.Foo in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testResetOriginalValues.
@Test
public void testResetOriginalValues() throws Exception {
Foo newFoo = addFoo();
_persistence.clearCache();
Foo existingFoo = _persistence.findByPrimaryKey(newFoo.getPrimaryKey());
Assert.assertTrue(Objects.equals(existingFoo.getUuid(), ReflectionTestUtil.invoke(existingFoo, "getOriginalUuid", new Class<?>[0])));
Assert.assertEquals(Long.valueOf(existingFoo.getGroupId()), ReflectionTestUtil.<Long>invoke(existingFoo, "getOriginalGroupId", new Class<?>[0]));
}
use of com.liferay.blade.basic.model.Foo in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testRemove.
@Test
public void testRemove() throws Exception {
Foo newFoo = addFoo();
_persistence.remove(newFoo);
Foo existingFoo = _persistence.fetchByPrimaryKey(newFoo.getPrimaryKey());
Assert.assertNull(existingFoo);
}
Aggregations