use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testDynamicQueryByProjectionExisting.
@Test
public void testDynamicQueryByProjectionExisting() throws Exception {
Foo newFoo = addFoo();
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Foo.class, _dynamicQueryClassLoader);
dynamicQuery.setProjection(ProjectionFactoryUtil.property("fooId"));
Object newFooId = newFoo.getFooId();
dynamicQuery.add(RestrictionsFactoryUtil.in("fooId", new Object[] { newFooId }));
List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(1, result.size());
Object existingFooId = result.get(0);
Assert.assertEquals(existingFooId, newFooId);
}
use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testFetchByPrimaryKeyExisting.
@Test
public void testFetchByPrimaryKeyExisting() throws Exception {
Foo newFoo = addFoo();
Foo existingFoo = _persistence.fetchByPrimaryKey(newFoo.getPrimaryKey());
Assert.assertEquals(existingFoo, newFoo);
}
use of com.liferay.blade.samples.servicebuilder.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);
}
use of com.liferay.blade.samples.servicebuilder.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.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testUpdateExisting.
@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());
}
Aggregations