Search in sources :

Example 16 with Country

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());
}
Also used : Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country) Test(org.junit.Test)

Example 17 with Country

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()));
}
Also used : Serializable(java.io.Serializable) Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with Country

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());
}
Also used : Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country) IntegerWrapper(com.liferay.portal.kernel.util.IntegerWrapper) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 19 with Country

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());
}
Also used : DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country) Test(org.junit.Test)

Example 20 with Country

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;
    }
}
Also used : Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country)

Aggregations

Country (com.liferay.blade.samples.jdbcservicebuilder.model.Country)23 Test (org.junit.Test)13 Serializable (java.io.Serializable)5 NoSuchCountryException (com.liferay.blade.samples.jdbcservicebuilder.exception.NoSuchCountryException)4 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)4 Session (com.liferay.portal.kernel.dao.orm.Session)4 CountryImpl (com.liferay.blade.samples.jdbcservicebuilder.model.impl.CountryImpl)3 StringBundler (com.liferay.petra.string.StringBundler)3 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Query (com.liferay.portal.kernel.dao.orm.Query)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Function (java.util.function.Function)2 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)1 IntegerWrapper (com.liferay.portal.kernel.util.IntegerWrapper)1 StringBundler (com.liferay.portal.kernel.util.StringBundler)1 List (java.util.List)1