@Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testOverridingDifferentClassDefinedForMapping() { BeanPropertyRowMapper mapper = new BeanPropertyRowMapper(Person.class); thrown.expect(InvalidDataAccessApiUsageException.class); mapper.setMappedClass(Long.class); }
/** * Static factory method to create a new BeanPropertyRowMapper (with the mapped class specified * only once). * * @param mappedClass the class that each row should be mapped to */ public static <T> BeanPropertyRowMapper<T> newInstance(Class<T> mappedClass) { BeanPropertyRowMapper<T> newInstance = new BeanPropertyRowMapper<T>(); newInstance.setMappedClass(mappedClass); return newInstance; }
@Test public void testOverridingSameClassDefinedForMapping() { BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<>(Person.class); mapper.setMappedClass(Person.class); }