package org.flatmap.reflect;

import static org.junit.Assert.*;

import org.flatmap.beans.Bar;
import org.flatmap.beans.Foo;
import org.flatmap.reflect.FieldSetter;
import org.flatmap.reflect.MethodSetter;
import org.flatmap.reflect.ReflectionSetterFactory;
import org.flatmap.reflect.Setter;
import org.junit.Test;

public class ReflectionSetterFactoryTest {
	ReflectionSetterFactory factory = new ReflectionSetterFactory();
	@Test
	public void testDefaultToMethod() throws Exception {
		Setter<Foo, String> setter = factory.getSetter(Foo.class, "foo");
		assertTrue(setter instanceof MethodSetter);
		SetterTestHelper.validateFooSetter(setter);
	}
	@Test
	public void testFallBackToField() throws Exception {
		Setter<Bar, String> setter = factory.getSetter(Foo.class, "bar");
		assertTrue(setter instanceof FieldSetter);
		SetterTestHelper.validateBarSetter(setter);
	}
	
	@Test
	public void testReturnNullIfNotFound() throws Exception {
		Setter<Foo, String> setter = factory.getSetter(Foo.class, "xxbar");
		assertNull(setter);
	}
}

@@ -643,16 +643,249 @@
 er);%0A%09%7D%0A
+%09%0A%09@Test%0A%09public void testMatchFullMethodName() throws Exception %7B%0A%09%09Setter%3CFoo, String%3E setter = factory.getSetter(Foo.class, %22setFoo%22);%0A%09%09assertTrue(setter instanceof MethodSetter);%0A%09%09SetterTestHelper.validateFooSetter(setter);%0A%09%7D%0A
 %09@Test%0A%09

add test for method name matching