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());
}
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);
}
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()));
}
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);
}
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());
}
Aggregations