use of com.liferay.blade.samples.servicebuilder.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());
}
use of com.liferay.blade.samples.servicebuilder.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()));
}
use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.
the class FooPersistenceTest method testFetchByPrimaryKeyMissing.
@Test
public void testFetchByPrimaryKeyMissing() throws Exception {
long pk = RandomTestUtil.nextLong();
Foo missingFoo = _persistence.fetchByPrimaryKey(pk);
Assert.assertNull(missingFoo);
}
use of com.liferay.blade.samples.servicebuilder.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());
}
use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.
the class BladeServiceBuilderIntegrationTest method testUpdateFoo.
@Test
public void testUpdateFoo() throws PortalException {
long id = CounterLocalServiceUtil.increment();
Foo foo = FooLocalServiceUtil.createFoo(id);
foo.setField1("updateFooEntryField1");
foo.setField2(true);
foo.setField3(3);
Date createDate = new Date();
foo.setField4(createDate);
foo.setField5("updateFooEntryField5");
foo.isNew();
Foo fooEntry = FooLocalServiceUtil.addFoo(foo);
fooEntry.setField1("updatedFooEntryField1");
fooEntry.setField2(false);
fooEntry.setField3(4);
Date newDate = new Date();
fooEntry.setField4(newDate);
fooEntry.setField5("updatedFooEntryField5");
FooLocalServiceUtil.updateFoo(foo);
Assert.assertTrue("Expected updatedFooEntryField1, but saw " + fooEntry.getField1(), fooEntry.getField1().contentEquals("updatedFooEntryField1"));
Assert.assertTrue("Expected false, but saw " + fooEntry.getField2(), fooEntry.getField2() == false);
Assert.assertTrue("Expected \"4\", but saw " + fooEntry.getField3(), fooEntry.getField3() == 4);
Assert.assertTrue("Expected " + newDate + "but saw, " + fooEntry.getField4(), fooEntry.getField4().compareTo(newDate) == 0);
Assert.assertTrue("Expected updatedFooEntryField5, but saw " + fooEntry.getField5(), fooEntry.getField5().contentEquals("updatedFooEntryField5"));
}
Aggregations