Search in sources :

Example 41 with Bar

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

the class BarPersistenceTest method testResetOriginalValues.

@Test
public void testResetOriginalValues() throws Exception {
    Bar newBar = addBar();
    _persistence.clearCache();
    Bar existingBar = _persistence.findByPrimaryKey(newBar.getPrimaryKey());
    Assert.assertTrue(Objects.equals(existingBar.getUuid(), ReflectionTestUtil.invoke(existingBar, "getOriginalUuid", new Class<?>[0])));
    Assert.assertEquals(Long.valueOf(existingBar.getGroupId()), ReflectionTestUtil.<Long>invoke(existingBar, "getOriginalGroupId", new Class<?>[0]));
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) Test(org.junit.Test)

Example 42 with Bar

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

the class BarPersistenceTest method testDynamicQueryByPrimaryKeyExisting.

@Test
public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    Bar newBar = addBar();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Bar.class, _dynamicQueryClassLoader);
    dynamicQuery.add(RestrictionsFactoryUtil.eq("barId", newBar.getBarId()));
    List<Bar> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(1, result.size());
    Bar existingBar = result.get(0);
    Assert.assertEquals(existingBar, newBar);
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 43 with Bar

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

the class BarPersistenceTest method testFetchByPrimaryKeyExisting.

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

Example 44 with Bar

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

the class BarPersistenceTest method testDynamicQueryByPrimaryKeyMissing.

@Test
public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Bar.class, _dynamicQueryClassLoader);
    dynamicQuery.add(RestrictionsFactoryUtil.eq("barId", RandomTestUtil.nextLong()));
    List<Bar> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(0, result.size());
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) 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