mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-12-22 07:18:51 -05:00
Finish porting tests
This commit is contained in:
parent
c04a9ee842
commit
c151f3ba0e
@ -141,13 +141,14 @@ public interface QmDao extends JdbcMapper {
|
||||
@SQL(selectLongLong)
|
||||
Map<Long, Long> getMapLongLong() throws SQLException;
|
||||
|
||||
/*
|
||||
|
||||
@SQL(selectLongArray)
|
||||
@SingleRow
|
||||
Long[] getLongObjectArray() throws SQLException;
|
||||
|
||||
@SQL(selectLongArray)
|
||||
@SingleRow
|
||||
long[] getLongPrimitiveArray() throws SQLException;
|
||||
*/
|
||||
|
||||
@SQL(bobTomMap)
|
||||
List<Map<String, String>> getBobTomMap() throws SQLException;
|
||||
|
@ -215,7 +215,6 @@ public class QueryMapperQmDao implements QmDao {
|
||||
return qm.toMap(selectLongLong, Long.class, Long.class);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public Long[] getLongObjectArray() throws SQLException {
|
||||
return qm.toObject(selectLongArray, Long[].class);
|
||||
@ -225,7 +224,6 @@ public class QueryMapperQmDao implements QmDao {
|
||||
public long[] getLongPrimitiveArray() throws SQLException {
|
||||
return qm.toObject(selectLongArray, long[].class);
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> getBobTomMap() throws SQLException {
|
||||
@ -233,8 +231,11 @@ public class QueryMapperQmDao implements QmDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
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
|
||||
|
@ -342,8 +342,7 @@ public class QueryMapperTest {
|
||||
final Long[] expected = {fieldPerson1.getPersonNo()};
|
||||
assertArrayEquals(expected, qm.getPersonNoObjectArray(expected[0]));
|
||||
}
|
||||
/*
|
||||
// todo: fix these
|
||||
|
||||
@Test
|
||||
public void testSelectObjectArray() throws Throwable {
|
||||
final Long[] arr = {1L, 2L, 3L};
|
||||
@ -353,9 +352,9 @@ public class QueryMapperTest {
|
||||
@Test
|
||||
public void testSelectPrimitiveArray() throws Throwable {
|
||||
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)
|
||||
public void testNoDefaultConstructorFails() throws Throwable {
|
||||
if(qm instanceof QueryMapperQmDao)
|
||||
@ -405,8 +404,6 @@ public class QueryMapperTest {
|
||||
|
||||
@Test
|
||||
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);
|
||||
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());
|
||||
assertArrayEquals(people, fromDb.toArray());
|
||||
}
|
||||
/*
|
||||
// todo: port this one
|
||||
|
||||
@Test
|
||||
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",
|
||||
FieldPerson.class, lqm.inList("person_no", Arrays.asList(people[0].getPersonNo(), people[1].getPersonNo(), people[2].getPersonNo())));
|
||||
assertArrayEquals(people, fromDb.toArray());
|
||||
lqm.close();
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testResultSetIterable() throws SQLException {
|
||||
final ResultSetIterable<FieldPerson> rsi = qm.getThreePeopleResultSetIterable(people[0].getPersonNo(), people[1].getPersonNo(), people[2].getPersonNo());
|
||||
|
Loading…
Reference in New Issue
Block a user