Search in sources :

Example 6 with Foo

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

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()));
}
Also used : Serializable(java.io.Serializable) Foo(com.liferay.blade.samples.servicebuilder.model.Foo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with Foo

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);
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Test(org.junit.Test)

Example 9 with Foo

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());
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) IntegerWrapper(com.liferay.portal.kernel.util.IntegerWrapper) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 10 with Foo

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"));
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Date(java.util.Date) 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