Search in sources :

Example 36 with Bar

use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.

the class BarPersistenceTest method testRemove.

@Test
public void testRemove() throws Exception {
    Bar newBar = addBar();
    _persistence.remove(newBar);
    Bar existingBar = _persistence.fetchByPrimaryKey(newBar.getPrimaryKey());
    Assert.assertNull(existingBar);
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) Test(org.junit.Test)

Example 37 with Bar

use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.

the class BarPersistenceTest method testFetchByPrimaryKeyMissing.

@Test
public void testFetchByPrimaryKeyMissing() throws Exception {
    long pk = RandomTestUtil.nextLong();
    Bar missingBar = _persistence.fetchByPrimaryKey(pk);
    Assert.assertNull(missingBar);
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) Test(org.junit.Test)

Example 38 with Bar

use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.

the class BarPersistenceTest method testActionableDynamicQuery.

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

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

Example 39 with Bar

use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.

the class BarPersistenceTest method addBar.

protected Bar addBar() throws Exception {
    long pk = RandomTestUtil.nextLong();
    Bar bar = _persistence.create(pk);
    bar.setUuid(RandomTestUtil.randomString());
    bar.setGroupId(RandomTestUtil.nextLong());
    bar.setCompanyId(RandomTestUtil.nextLong());
    bar.setUserId(RandomTestUtil.nextLong());
    bar.setUserName(RandomTestUtil.randomString());
    bar.setCreateDate(RandomTestUtil.nextDate());
    bar.setModifiedDate(RandomTestUtil.nextDate());
    bar.setField1(RandomTestUtil.randomString());
    bar.setField2(RandomTestUtil.randomBoolean());
    bar.setField3(RandomTestUtil.nextInt());
    bar.setField4(RandomTestUtil.nextDate());
    bar.setField5(RandomTestUtil.randomString());
    _bars.add(_persistence.update(bar));
    return bar;
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar)

Example 40 with Bar

use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.

the class BarPersistenceTest method testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist.

@Test
public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception {
    Bar newBar = addBar();
    long pk = RandomTestUtil.nextLong();
    Set<Serializable> primaryKeys = new HashSet<Serializable>();
    primaryKeys.add(newBar.getPrimaryKey());
    primaryKeys.add(pk);
    Map<Serializable, Bar> bars = _persistence.fetchByPrimaryKeys(primaryKeys);
    Assert.assertEquals(1, bars.size());
    Assert.assertEquals(newBar, bars.get(newBar.getPrimaryKey()));
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) Serializable(java.io.Serializable) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Bar (com.liferay.blade.samples.servicebuilder.adq.model.Bar)44 StringBundler (com.liferay.petra.string.StringBundler)17 NoSuchBarException (com.liferay.blade.samples.servicebuilder.adq.exception.NoSuchBarException)16 Test (org.junit.Test)15 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 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)6 BarImpl (com.liferay.blade.samples.servicebuilder.adq.model.impl.BarImpl)5 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)5 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 Serializable (java.io.Serializable)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 DefaultActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery)1