Finish porting tests

This commit is contained in:
Travis Burtrum 2018-05-09 23:20:40 -04:00
parent c04a9ee842
commit c151f3ba0e
3 changed files with 15 additions and 15 deletions

View File

@ -141,13 +141,14 @@ public interface QmDao extends JdbcMapper {
@SQL(selectLongLong) @SQL(selectLongLong)
Map<Long, Long> getMapLongLong() throws SQLException; Map<Long, Long> getMapLongLong() throws SQLException;
/*
@SQL(selectLongArray) @SQL(selectLongArray)
@SingleRow
Long[] getLongObjectArray() throws SQLException; Long[] getLongObjectArray() throws SQLException;
@SQL(selectLongArray) @SQL(selectLongArray)
@SingleRow
long[] getLongPrimitiveArray() throws SQLException; long[] getLongPrimitiveArray() throws SQLException;
*/
@SQL(bobTomMap) @SQL(bobTomMap)
List<Map<String, String>> getBobTomMap() throws SQLException; List<Map<String, String>> getBobTomMap() throws SQLException;

View File

@ -215,7 +215,6 @@ public class QueryMapperQmDao implements QmDao {
return qm.toMap(selectLongLong, Long.class, Long.class); return qm.toMap(selectLongLong, Long.class, Long.class);
} }
/*
@Override @Override
public Long[] getLongObjectArray() throws SQLException { public Long[] getLongObjectArray() throws SQLException {
return qm.toObject(selectLongArray, Long[].class); return qm.toObject(selectLongArray, Long[].class);
@ -225,7 +224,6 @@ public class QueryMapperQmDao implements QmDao {
public long[] getLongPrimitiveArray() throws SQLException { public long[] getLongPrimitiveArray() throws SQLException {
return qm.toObject(selectLongArray, long[].class); return qm.toObject(selectLongArray, long[].class);
} }
*/
@Override @Override
public List<Map<String, String>> getBobTomMap() throws SQLException { public List<Map<String, String>> getBobTomMap() throws SQLException {
@ -233,8 +231,11 @@ public class QueryMapperQmDao implements QmDao {
} }
@Override @Override
@SuppressWarnings("unchecked")
public List<CaseInsensitiveHashMap<String, String>> getBobTomMapCaseInsensitive() throws SQLException { public List<CaseInsensitiveHashMap<String, String>> getBobTomMapCaseInsensitive() throws SQLException {
return qm.toType(bobTomMap, new TypeReference<List<CaseInsensitiveHashMap<String, String>>>() {}); // todo: ParameterizedTypeImpl cannot be cast to java.lang.Class
// return qm.toType(bobTomMap, new TypeReference<List<CaseInsensitiveHashMap<String, String>>>() {});
return (List<CaseInsensitiveHashMap<String, String>>)(Object)qm.toListMap(bobTomMap, CaseInsensitiveHashMap.class, String.class);
} }
@Override @Override

View File

@ -342,8 +342,7 @@ public class QueryMapperTest {
final Long[] expected = {fieldPerson1.getPersonNo()}; final Long[] expected = {fieldPerson1.getPersonNo()};
assertArrayEquals(expected, qm.getPersonNoObjectArray(expected[0])); assertArrayEquals(expected, qm.getPersonNoObjectArray(expected[0]));
} }
/*
// todo: fix these
@Test @Test
public void testSelectObjectArray() throws Throwable { public void testSelectObjectArray() throws Throwable {
final Long[] arr = {1L, 2L, 3L}; final Long[] arr = {1L, 2L, 3L};
@ -353,9 +352,9 @@ public class QueryMapperTest {
@Test @Test
public void testSelectPrimitiveArray() throws Throwable { public void testSelectPrimitiveArray() throws Throwable {
final long[] arr = {1L, 2L, 3L}; final long[] arr = {1L, 2L, 3L};
assertArrayEquals(arr, qm.toObject("SELECT 1, 2, 3 FROM person WHERE person_no = ?", long[].class, fieldPerson1.getPersonNo())); assertArrayEquals(arr, qm.getLongPrimitiveArray());
} }
*/
@Test(expected = com.moparisthebest.jdbc.MapperException.class) @Test(expected = com.moparisthebest.jdbc.MapperException.class)
public void testNoDefaultConstructorFails() throws Throwable { public void testNoDefaultConstructorFails() throws Throwable {
if(qm instanceof QueryMapperQmDao) if(qm instanceof QueryMapperQmDao)
@ -405,8 +404,6 @@ public class QueryMapperTest {
@Test @Test
public void testCaseInsensitiveMapJdbcMapper() throws Throwable { public void testCaseInsensitiveMapJdbcMapper() throws Throwable {
if(qm instanceof QueryMapperQmDao)
return; // skip todo: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
final Map<String, String> map = qm.getBobTomMapCaseInsensitive().get(0); final Map<String, String> map = qm.getBobTomMapCaseInsensitive().get(0);
assertEquals("bob", map.get("bob")); assertEquals("bob", map.get("bob"));
assertEquals("bob", map.get("Bob")); assertEquals("bob", map.get("Bob"));
@ -431,17 +428,18 @@ public class QueryMapperTest {
final List<FieldPerson> fromDb = qm.getThreePeopleType(people[0].getPersonNo(), people[1].getPersonNo(), people[2].getPersonNo()); final List<FieldPerson> fromDb = qm.getThreePeopleType(people[0].getPersonNo(), people[1].getPersonNo(), people[2].getPersonNo());
assertArrayEquals(people, fromDb.toArray()); assertArrayEquals(people, fromDb.toArray());
} }
/*
// todo: port this one
@Test @Test
public void testListQueryMapperList() throws SQLException { public void testListQueryMapperList() throws SQLException {
final ListQueryMapper lqm = new ListQueryMapper(qm); if(!(qm instanceof QueryMapperQmDao))
return; // todo: port this when JdbcMapper supports in-lists on generic SQL backends
final ListQueryMapper lqm = new ListQueryMapper(((QueryMapperQmDao)qm).getQm());
final List<FieldPerson> fromDb = lqm.toList("SELECT * from person WHERE " + ListQueryMapper.inListReplace + " ORDER BY person_no", final List<FieldPerson> fromDb = lqm.toList("SELECT * from person WHERE " + ListQueryMapper.inListReplace + " ORDER BY person_no",
FieldPerson.class, lqm.inList("person_no", Arrays.asList(people[0].getPersonNo(), people[1].getPersonNo(), people[2].getPersonNo()))); FieldPerson.class, lqm.inList("person_no", Arrays.asList(people[0].getPersonNo(), people[1].getPersonNo(), people[2].getPersonNo())));
assertArrayEquals(people, fromDb.toArray()); assertArrayEquals(people, fromDb.toArray());
lqm.close(); lqm.close();
} }
*/
@Test @Test
public void testResultSetIterable() throws SQLException { public void testResultSetIterable() throws SQLException {
final ResultSetIterable<FieldPerson> rsi = qm.getThreePeopleResultSetIterable(people[0].getPersonNo(), people[1].getPersonNo(), people[2].getPersonNo()); final ResultSetIterable<FieldPerson> rsi = qm.getThreePeopleResultSetIterable(people[0].getPersonNo(), people[1].getPersonNo(), people[2].getPersonNo());