Search in sources :

Example 31 with Foo

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

the class FooPersistenceTest method testActionableDynamicQuery.

@Test
public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();
    ActionableDynamicQuery actionableDynamicQuery = FooLocalServiceUtil.getActionableDynamicQuery();
    actionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Foo>() {

        @Override
        public void performAction(Foo foo) {
            Assert.assertNotNull(foo);
            count.increment();
        }
    });
    actionableDynamicQuery.performActions();
    Assert.assertEquals(count.getValue(), _persistence.countAll());
}
Also used : Foo(com.liferay.blade.basic.model.Foo) IntegerWrapper(com.liferay.portal.kernel.util.IntegerWrapper) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 32 with Foo

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

the class FooPersistenceTest method testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist.

@Test
public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist() throws Exception {
    Foo newFoo1 = addFoo();
    Foo newFoo2 = addFoo();
    Set<Serializable> primaryKeys = new HashSet<Serializable>();
    primaryKeys.add(newFoo1.getPrimaryKey());
    primaryKeys.add(newFoo2.getPrimaryKey());
    Map<Serializable, Foo> foos = _persistence.fetchByPrimaryKeys(primaryKeys);
    Assert.assertEquals(2, foos.size());
    Assert.assertEquals(newFoo1, foos.get(newFoo1.getPrimaryKey()));
    Assert.assertEquals(newFoo2, foos.get(newFoo2.getPrimaryKey()));
}
Also used : Serializable(java.io.Serializable) Foo(com.liferay.blade.basic.model.Foo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 33 with Foo

use of com.liferay.blade.basic.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.basic.model.Foo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 34 with Foo

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

Example 35 with Foo

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

the class FooModelImpl method equals.

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof Foo)) {
        return false;
    }
    Foo foo = (Foo) obj;
    long primaryKey = foo.getPrimaryKey();
    if (getPrimaryKey() == primaryKey) {
        return true;
    } else {
        return false;
    }
}
Also used : Foo(com.liferay.blade.basic.model.Foo)

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