Search in sources :

Example 26 with Foo

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

the class FooPersistenceImpl method findByField2_First.

/**
 * Returns the first foo in the ordered set where field2 = ?.
 *
 * @param field2 the field2
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the first matching foo
 * @throws NoSuchFooException if a matching foo could not be found
 */
@Override
public Foo findByField2_First(boolean field2, OrderByComparator<Foo> orderByComparator) throws NoSuchFooException {
    Foo foo = fetchByField2_First(field2, orderByComparator);
    if (foo != null) {
        return foo;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("field2=");
    msg.append(field2);
    msg.append("}");
    throw new NoSuchFooException(msg.toString());
}
Also used : NoSuchFooException(com.liferay.blade.basic.exception.NoSuchFooException) Foo(com.liferay.blade.basic.model.Foo) StringBundler(com.liferay.petra.string.StringBundler)

Example 27 with Foo

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

the class AddTestData method addTestData.

@Activate
public void addTestData() {
    Foo foo = FooLocalServiceUtil.createFoo(0);
    foo.setField1("createFooEntryField1");
    foo.setField2(true);
    foo.setField3(1);
    foo.setField4(new Date());
    foo.setField5("createFooEntryField5");
    foo.isNew();
    Foo fooEntry = FooLocalServiceUtil.addFoo(foo);
    if (!fooEntry.getField2()) {
        _log.error("Test Failed");
    }
    FooLocalServiceUtil.deleteFoo(fooEntry);
}
Also used : Foo(com.liferay.blade.basic.model.Foo) Date(java.util.Date) Activate(org.osgi.service.component.annotations.Activate)

Example 28 with Foo

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

Example 29 with Foo

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

Example 30 with Foo

use of com.liferay.blade.basic.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.isField2(), newFoo.isField2());
    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.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