Search in sources :

Example 1 with Foo

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

Example 2 with Foo

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

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

Example 4 with Foo

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

Example 5 with Foo

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

Aggregations

Foo (com.liferay.blade.basic.model.Foo)44 StringBundler (com.liferay.petra.string.StringBundler)17 NoSuchFooException (com.liferay.blade.basic.exception.NoSuchFooException)16 Test (org.junit.Test)14 Session (com.liferay.portal.kernel.dao.orm.Session)9 Query (com.liferay.portal.kernel.dao.orm.Query)8 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)7 FooImpl (com.liferay.blade.basic.model.impl.FooImpl)5 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)5 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)4 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 Serializable (java.io.Serializable)3 Date (java.util.Date)3 HashSet (java.util.HashSet)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Function (java.util.function.Function)2 ManifestSummary (com.liferay.exportimport.kernel.lar.ManifestSummary)1 StagedModelType (com.liferay.exportimport.kernel.lar.StagedModelType)1