use of com.liferay.blade.samples.jdbcservicebuilder.model.Country in project liferay-blade-samples by liferay.
the class CountryPersistenceTest method testUpdateExisting.
@Test
public void testUpdateExisting() throws Exception {
long pk = RandomTestUtil.nextLong();
Country newCountry = _persistence.create(pk);
newCountry.setCountryName(RandomTestUtil.randomString());
_countries.add(_persistence.update(newCountry));
Country existingCountry = _persistence.findByPrimaryKey(newCountry.getPrimaryKey());
Assert.assertEquals(existingCountry.getCountryId(), newCountry.getCountryId());
Assert.assertEquals(existingCountry.getCountryName(), newCountry.getCountryName());
}
use of com.liferay.blade.samples.jdbcservicebuilder.model.Country in project liferay-blade-samples by liferay.
the class CountryPersistenceTest method testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist.
@Test
public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception {
Country newCountry = addCountry();
long pk = RandomTestUtil.nextLong();
Set<Serializable> primaryKeys = new HashSet<Serializable>();
primaryKeys.add(newCountry.getPrimaryKey());
primaryKeys.add(pk);
Map<Serializable, Country> countries = _persistence.fetchByPrimaryKeys(primaryKeys);
Assert.assertEquals(1, countries.size());
Assert.assertEquals(newCountry, countries.get(newCountry.getPrimaryKey()));
}
use of com.liferay.blade.samples.jdbcservicebuilder.model.Country in project liferay-blade-samples by liferay.
the class CountryPersistenceTest method testActionableDynamicQuery.
@Test
public void testActionableDynamicQuery() throws Exception {
final IntegerWrapper count = new IntegerWrapper();
ActionableDynamicQuery actionableDynamicQuery = CountryLocalServiceUtil.getActionableDynamicQuery();
actionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Country>() {
@Override
public void performAction(Country country) {
Assert.assertNotNull(country);
count.increment();
}
});
actionableDynamicQuery.performActions();
Assert.assertEquals(count.getValue(), _persistence.countAll());
}
use of com.liferay.blade.samples.jdbcservicebuilder.model.Country in project liferay-blade-samples by liferay.
the class CountryPersistenceTest method testDynamicQueryByPrimaryKeyMissing.
@Test
public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Country.class, _dynamicQueryClassLoader);
dynamicQuery.add(RestrictionsFactoryUtil.eq("countryId", RandomTestUtil.nextLong()));
List<Country> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(0, result.size());
}
use of com.liferay.blade.samples.jdbcservicebuilder.model.Country in project liferay-blade-samples by liferay.
the class CountryModelImpl method equals.
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Country)) {
return false;
}
Country country = (Country) obj;
long primaryKey = country.getPrimaryKey();
if (getPrimaryKey() == primaryKey) {
return true;
} else {
return false;
}
}
Aggregations