Search in sources :

Example 1 with Foo

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);
}
Also used : DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Test(org.junit.Test)

Example 2 with Foo

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);
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Test(org.junit.Test)

Example 3 with Foo

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);
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Test(org.junit.Test)

Example 4 with Foo

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;
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo)

Example 5 with 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());
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Test(org.junit.Test)

Aggregations

Foo (com.liferay.blade.samples.servicebuilder.model.Foo)48 NoSuchFooException (com.liferay.blade.samples.servicebuilder.exception.NoSuchFooException)18 Test (org.junit.Test)17 StringBundler (com.liferay.portal.kernel.util.StringBundler)16 Session (com.liferay.portal.kernel.dao.orm.Session)11 Query (com.liferay.portal.kernel.dao.orm.Query)9 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)7 Date (java.util.Date)7 FooImpl (com.liferay.blade.samples.servicebuilder.model.impl.FooImpl)6 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)5 Serializable (java.io.Serializable)5 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)4 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 HashSet (java.util.HashSet)3 List (java.util.List)2 ManifestSummary (com.liferay.exportimport.kernel.lar.ManifestSummary)1 StagedModelType (com.liferay.exportimport.kernel.lar.StagedModelType)1 DefaultActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery)1 ExportActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery)1 IndexableActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery)1