Search in sources :

Example 1 with PropertyAccessStrategyMapImpl

use of org.hibernate.property.access.internal.PropertyAccessStrategyMapImpl in project hibernate-orm by hibernate.

the class PropertyAccessStrategyMapTest method testBasic.

private void testBasic(final Class<?> clazz) {
    final String key = "testKey";
    final String value = "testValue";
    final PropertyAccessStrategyMapImpl accessStrategy = PropertyAccessStrategyMapImpl.INSTANCE;
    final PropertyAccess access = accessStrategy.buildPropertyAccess(clazz, key);
    final HashMap<String, String> map = new HashMap<>();
    access.getSetter().set(map, value, null);
    assertEquals(value, map.get(key));
    assertEquals(value, access.getGetter().get(map));
}
Also used : HashMap(java.util.HashMap) PropertyAccessStrategyMapImpl(org.hibernate.property.access.internal.PropertyAccessStrategyMapImpl) PropertyAccess(org.hibernate.property.access.spi.PropertyAccess)

Example 2 with PropertyAccessStrategyMapImpl

use of org.hibernate.property.access.internal.PropertyAccessStrategyMapImpl in project hibernate-orm by hibernate.

the class PropertyAccessStrategyMapTest method testNonMap.

@Test
public void testNonMap() {
    final PropertyAccessStrategyMapImpl accessStrategy = PropertyAccessStrategyMapImpl.INSTANCE;
    try {
        accessStrategy.buildPropertyAccess(Date.class, "time");
        fail("Should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        assertEquals("Expecting class: [org.hibernate.mapping.Map], but containerJavaType is of type: [java.util.Date] for propertyName: [time]", e.getMessage());
    }
}
Also used : PropertyAccessStrategyMapImpl(org.hibernate.property.access.internal.PropertyAccessStrategyMapImpl) Test(org.junit.Test)

Aggregations

PropertyAccessStrategyMapImpl (org.hibernate.property.access.internal.PropertyAccessStrategyMapImpl)2 HashMap (java.util.HashMap)1 PropertyAccess (org.hibernate.property.access.spi.PropertyAccess)1 Test (org.junit.Test)1