package org.sfm.jdbc;

import org.junit.Test;
import org.sfm.beans.DbObject;
import org.sfm.map.FieldMapperErrorHandler;
import org.sfm.map.RethrowMapperBuilderErrorHandler;
import org.sfm.reflect.Setter;
import org.sfm.reflect.SetterFactory;

public class ResultSetFieldMapperFactoryTest {
	
	SetterFactory setterFactory = new SetterFactory(null);
	ResultSetFieldMapperFactory factory = new ResultSetFieldMapperFactory(setterFactory, new ResultSetGetterFactory());
	private FieldMapperErrorHandler<ColumnKey> errorHandler;

	@Test
	public void testPrimitiveFieldMapperWrontType() {
		Setter<DbObject, String> setter = setterFactory.getFieldSetter(DbObject.class, "name");
		
		factory.newFieldMapper(setter, new ColumnKey("id", 1), errorHandler, new RethrowMapperBuilderErrorHandler());
		factory.newFieldMapper(setter, new ColumnKey("col1"), errorHandler, new RethrowMapperBuilderErrorHandler());
	}


}

@@ -14,16 +14,78 @@
 fm.jdbc;
+%0Aimport static org.junit.Assert.*;%0A%0Aimport java.sql.ResultSet;
 %0A%0Aimport
@@ -132,16 +132,48 @@
 Object;%0A
+import org.sfm.map.FieldMapper;%0A
 import o
@@ -253,32 +253,78 @@
 erErrorHandler;%0A
+import org.sfm.map.primitive.LongFieldMapper;%0A
 import org.sfm.r
@@ -700,23 +700,8 @@
 ield
-MapperWrontType
 () %7B
@@ -724,14 +724,15 @@
 ct, 
-String
+Integer
 %3E se
@@ -788,12 +788,10 @@
 s, %22
-name
+id
 %22);%0A
@@ -795,16 +795,66 @@
 );%0A%09%09%0A%09%09
+%0A%09%09FieldMapper%3CResultSet, DbObject%3E fieldMapper = 
 factory.
@@ -957,16 +957,88 @@
 r());%0A%09%09
+%0A%09%09assertTrue(fieldMapper instanceof LongFieldMapper);%0A%0A%09%09fieldMapper = 
 factory.
@@ -1079,12 +1079,10 @@
 ey(%22
-col1
+id
 %22), 
@@ -1136,15 +1136,70 @@
 ler());%0A
+%09%09assertTrue(fieldMapper instanceof LongFieldMapper);%0A%0A
 %09%7D%0A%0A%0A%7D%0A

test return primitive mapper: