Search in sources :

Example 16 with Bar

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

the class BarPersistenceTest method testUpdateExisting.

@Test
public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();
    Bar newBar = _persistence.create(pk);
    newBar.setUuid(RandomTestUtil.randomString());
    newBar.setGroupId(RandomTestUtil.nextLong());
    newBar.setCompanyId(RandomTestUtil.nextLong());
    newBar.setUserId(RandomTestUtil.nextLong());
    newBar.setUserName(RandomTestUtil.randomString());
    newBar.setCreateDate(RandomTestUtil.nextDate());
    newBar.setModifiedDate(RandomTestUtil.nextDate());
    newBar.setField1(RandomTestUtil.randomString());
    newBar.setField2(RandomTestUtil.randomBoolean());
    newBar.setField3(RandomTestUtil.nextInt());
    newBar.setField4(RandomTestUtil.nextDate());
    newBar.setField5(RandomTestUtil.randomString());
    _bars.add(_persistence.update(newBar));
    Bar existingBar = _persistence.findByPrimaryKey(newBar.getPrimaryKey());
    Assert.assertEquals(existingBar.getUuid(), newBar.getUuid());
    Assert.assertEquals(existingBar.getBarId(), newBar.getBarId());
    Assert.assertEquals(existingBar.getGroupId(), newBar.getGroupId());
    Assert.assertEquals(existingBar.getCompanyId(), newBar.getCompanyId());
    Assert.assertEquals(existingBar.getUserId(), newBar.getUserId());
    Assert.assertEquals(existingBar.getUserName(), newBar.getUserName());
    Assert.assertEquals(Time.getShortTimestamp(existingBar.getCreateDate()), Time.getShortTimestamp(newBar.getCreateDate()));
    Assert.assertEquals(Time.getShortTimestamp(existingBar.getModifiedDate()), Time.getShortTimestamp(newBar.getModifiedDate()));
    Assert.assertEquals(existingBar.getField1(), newBar.getField1());
    Assert.assertEquals(existingBar.isField2(), newBar.isField2());
    Assert.assertEquals(existingBar.getField3(), newBar.getField3());
    Assert.assertEquals(Time.getShortTimestamp(existingBar.getField4()), Time.getShortTimestamp(newBar.getField4()));
    Assert.assertEquals(existingBar.getField5(), newBar.getField5());
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) Test(org.junit.Test)

Example 17 with Bar

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

the class BarPersistenceTest method testCreate.

@Test
public void testCreate() throws Exception {
    long pk = RandomTestUtil.nextLong();
    Bar bar = _persistence.create(pk);
    Assert.assertNotNull(bar);
    Assert.assertEquals(bar.getPrimaryKey(), pk);
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) Test(org.junit.Test)

Example 18 with Bar

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

the class BarPersistenceTest method testFindByPrimaryKeyExisting.

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

Example 19 with Bar

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

the class BarPersistenceTest method testDynamicQueryByProjectionExisting.

@Test
public void testDynamicQueryByProjectionExisting() throws Exception {
    Bar newBar = addBar();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Bar.class, _dynamicQueryClassLoader);
    dynamicQuery.setProjection(ProjectionFactoryUtil.property("barId"));
    Object newBarId = newBar.getBarId();
    dynamicQuery.add(RestrictionsFactoryUtil.in("barId", new Object[] { newBarId }));
    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(1, result.size());
    Object existingBarId = result.get(0);
    Assert.assertEquals(existingBarId, newBarId);
}
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 20 with Bar

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

the class BarPersistenceTest method testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist.

@Test
public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist() throws Exception {
    Bar newBar1 = addBar();
    Bar newBar2 = addBar();
    Set<Serializable> primaryKeys = new HashSet<Serializable>();
    primaryKeys.add(newBar1.getPrimaryKey());
    primaryKeys.add(newBar2.getPrimaryKey());
    Map<Serializable, Bar> bars = _persistence.fetchByPrimaryKeys(primaryKeys);
    Assert.assertEquals(2, bars.size());
    Assert.assertEquals(newBar1, bars.get(newBar1.getPrimaryKey()));
    Assert.assertEquals(newBar2, bars.get(newBar2.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