Search in sources :

Example 6 with Country

use of com.liferay.blade.samples.jdbcservicebuilder.model.Country in project liferay-blade-samples by liferay.

the class CountryPersistenceTest method testFindByPrimaryKeyExisting.

@Test
public void testFindByPrimaryKeyExisting() throws Exception {
    Country newCountry = addCountry();
    Country existingCountry = _persistence.findByPrimaryKey(newCountry.getPrimaryKey());
    Assert.assertEquals(existingCountry, newCountry);
}
Also used : Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country) Test(org.junit.Test)

Example 7 with Country

use of com.liferay.blade.samples.jdbcservicebuilder.model.Country in project liferay-blade-samples by liferay.

the class CountryPersistenceTest method addCountry.

protected Country addCountry() throws Exception {
    long pk = RandomTestUtil.nextLong();
    Country country = _persistence.create(pk);
    country.setCountryName(RandomTestUtil.randomString());
    _countries.add(_persistence.update(country));
    return country;
}
Also used : Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country)

Example 8 with Country

use of com.liferay.blade.samples.jdbcservicebuilder.model.Country in project liferay-blade-samples by liferay.

the class CountryPersistenceTest method testRemove.

@Test
public void testRemove() throws Exception {
    Country newCountry = addCountry();
    _persistence.remove(newCountry);
    Country existingCountry = _persistence.fetchByPrimaryKey(newCountry.getPrimaryKey());
    Assert.assertNull(existingCountry);
}
Also used : Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country) Test(org.junit.Test)

Example 9 with Country

use of com.liferay.blade.samples.jdbcservicebuilder.model.Country in project liferay-blade-samples by liferay.

the class CountryModelImpl method toXmlString.

@Override
public String toXmlString() {
    Map<String, Function<Country, Object>> attributeGetterFunctions = getAttributeGetterFunctions();
    StringBundler sb = new StringBundler(5 * attributeGetterFunctions.size() + 4);
    sb.append("<model><model-name>");
    sb.append(getModelClassName());
    sb.append("</model-name>");
    for (Map.Entry<String, Function<Country, Object>> entry : attributeGetterFunctions.entrySet()) {
        String attributeName = entry.getKey();
        Function<Country, Object> attributeGetterFunction = entry.getValue();
        sb.append("<column><column-name>");
        sb.append(attributeName);
        sb.append("</column-name><column-value><![CDATA[");
        sb.append(attributeGetterFunction.apply((Country) this));
        sb.append("]]></column-value></column>");
    }
    sb.append("</model>");
    return sb.toString();
}
Also used : Function(java.util.function.Function) Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringBundler(com.liferay.petra.string.StringBundler)

Example 10 with Country

use of com.liferay.blade.samples.jdbcservicebuilder.model.Country in project liferay-blade-samples by liferay.

the class CountryModelImpl method toString.

@Override
public String toString() {
    Map<String, Function<Country, Object>> attributeGetterFunctions = getAttributeGetterFunctions();
    StringBundler sb = new StringBundler(4 * attributeGetterFunctions.size() + 2);
    sb.append("{");
    for (Map.Entry<String, Function<Country, Object>> entry : attributeGetterFunctions.entrySet()) {
        String attributeName = entry.getKey();
        Function<Country, Object> attributeGetterFunction = entry.getValue();
        sb.append(attributeName);
        sb.append("=");
        sb.append(attributeGetterFunction.apply((Country) this));
        sb.append(", ");
    }
    if (sb.index() > 1) {
        sb.setIndex(sb.index() - 1);
    }
    sb.append("}");
    return sb.toString();
}
Also used : Function(java.util.function.Function) Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringBundler(com.liferay.petra.string.StringBundler)

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