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