Search in sources :

Example 31 with Foo

use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.

the class FooPersistenceTest method testCreate.

@Test
public void testCreate() throws Exception {
    long pk = RandomTestUtil.nextLong();
    Foo foo = _persistence.create(pk);
    Assert.assertNotNull(foo);
    Assert.assertEquals(foo.getPrimaryKey(), pk);
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Test(org.junit.Test)

Example 32 with Foo

use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.

the class FooPersistenceTest method testFindByPrimaryKeyExisting.

@Test
public void testFindByPrimaryKeyExisting() throws Exception {
    Foo newFoo = addFoo();
    Foo existingFoo = _persistence.findByPrimaryKey(newFoo.getPrimaryKey());
    Assert.assertEquals(existingFoo, newFoo);
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Test(org.junit.Test)

Example 33 with Foo

use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.

the class FooPersistenceTest method testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist.

@Test
public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception {
    Foo newFoo = addFoo();
    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()));
}
Also used : Serializable(java.io.Serializable) Foo(com.liferay.blade.samples.servicebuilder.model.Foo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 34 with Foo

use of com.liferay.blade.samples.servicebuilder.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.samples.servicebuilder.model.Foo) Test(org.junit.Test)

Example 35 with Foo

use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.

the class FooPersistenceTest method testFetchByPrimaryKeysWithOnePrimaryKey.

@Test
public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    Foo newFoo = addFoo();
    Set<Serializable> primaryKeys = new HashSet<Serializable>();
    primaryKeys.add(newFoo.getPrimaryKey());
    Map<Serializable, Foo> foos = _persistence.fetchByPrimaryKeys(primaryKeys);
    Assert.assertEquals(1, foos.size());
    Assert.assertEquals(newFoo, foos.get(newFoo.getPrimaryKey()));
}
Also used : Serializable(java.io.Serializable) Foo(com.liferay.blade.samples.servicebuilder.model.Foo) HashSet(java.util.HashSet) 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