From: erik Date: Sun, 15 Nov 2009 11:06:31 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.2@603~49 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=791ec557d572d44febe9fc8e152eb08643cd9c06;p=utils --- diff --git a/trunk/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java b/trunk/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java index 15c101dc..57323a54 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java @@ -171,7 +171,7 @@ public class SetterConfiguration { * @throws IllegalArgumentException * In case no setter is found or multiple setters are found. */ - public SetterConfiguration add(final Class aType) { + public SetterConfiguration addSetter(final Class aType) { List result = new ArrayList(); CollectionFilter.filter(getAllSetters(_class, _publicOnly), result, new Condition() { @@ -223,11 +223,14 @@ public class SetterConfiguration { return result; } - private static ParameterValues createParameterValues(Method method) { - // TODO generalize to multiple parameters. - return new ParameterValues( - new String[] { method.getName() }, new Class[] { method - .getParameterTypes()[0] }); + private static ParameterValues createParameterValues(Method aMethod) { + + Class[] paramTypes = aMethod.getParameterTypes(); + String[] paramNames = new String[paramTypes.length]; + for (int i = 0; i < paramTypes.length; i++) { + paramNames[i] = aMethod.getName() + "." + i; + } + return new ParameterValues(paramNames, paramTypes); } private static final List getAllMethods(Class aClass) { diff --git a/trunk/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java b/trunk/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java index 34f06a38..aebdc3df 100644 --- a/trunk/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java +++ b/trunk/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java @@ -36,7 +36,7 @@ public class SetterConfigurationTest extends AdapterTestCase { config.initAllSetters(); List required = config.getRequiredInterfaces(); assertEquals(1, required.size()); - assertEquals("setValue", required.get(0).getName()); + assertEquals("setValue.0", required.get(0).getName()); ProvidedInterface provided = new DefaultProvidedInterface("janse", String.class); @@ -62,8 +62,8 @@ public class SetterConfigurationTest extends AdapterTestCase { } }); assertEquals(2, required.size()); - assertEquals("setValue", required.get(0).getName()); - assertEquals("setXyz", required.get(1).getName()); + assertEquals("setValue.0", required.get(0).getName()); + assertEquals("setXyz.0", required.get(1).getName()); ProvidedInterface providedString = new DefaultProvidedInterface( "janse", String.class); @@ -98,9 +98,9 @@ public class SetterConfigurationTest extends AdapterTestCase { } }); assertEquals(3, required.size()); - assertEquals("setFlag", required.get(0).getName()); - assertEquals("setValue", required.get(1).getName()); - assertEquals("setXyz", required.get(2).getName()); + assertEquals("setFlag.0", required.get(0).getName()); + assertEquals("setValue.0", required.get(1).getName()); + assertEquals("setXyz.0", required.get(2).getName()); ProvidedInterface providedBoolean = new DefaultProvidedInterface( "janse", Boolean.class); @@ -135,8 +135,8 @@ public class SetterConfigurationTest extends AdapterTestCase { List required = config.getRequiredInterfaces(); Collections.sort(required, new RequiredInterfaceComparator()); assertEquals(2, required.size()); - assertEquals("setHost", required.get(0).getName()); - assertEquals("setPort", required.get(1).getName()); + assertEquals("setHost.0", required.get(0).getName()); + assertEquals("setPort.0", required.get(1).getName()); ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); @@ -161,7 +161,7 @@ public class SetterConfigurationTest extends AdapterTestCase { final SetterConfiguration config = new SetterConfiguration(X5.class).initAllSetters(); List required = config.getRequiredInterfaces(); assertEquals(1, required.size()); - assertEquals("setValue", required.get(0).getName()); + assertEquals("setValue.0", required.get(0).getName()); ProvidedInterface provided = new DefaultProvidedInterface("janse", String.class); @@ -213,7 +213,7 @@ public class SetterConfigurationTest extends AdapterTestCase { List required = config.getRequiredInterfaces(); Collections.sort(required, new RequiredInterfaceComparator()); assertEquals(1, required.size()); - assertEquals("setHost", required.get(0).getName()); + assertEquals("setHost.0", required.get(0).getName()); ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); @@ -231,11 +231,11 @@ public class SetterConfigurationTest extends AdapterTestCase { public void testAddByType() { SetterConfiguration config = new SetterConfiguration(X6.class); - config.clear().add(String.class); + config.clear().addSetter(String.class); List required = config.getRequiredInterfaces(); Collections.sort(required, new RequiredInterfaceComparator()); assertEquals(1, required.size()); - assertEquals("setHost", required.get(0).getName()); + assertEquals("setHost.0", required.get(0).getName()); ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); @@ -280,7 +280,7 @@ public class SetterConfigurationTest extends AdapterTestCase { AssertionUtils.assertException(new AssertionUtils.ErroneousCode() { @Override public void run() throws Exception { - config.add(DataSource.class); + config.addSetter(DataSource.class); } }, IllegalArgumentException.class); } @@ -291,7 +291,7 @@ public class SetterConfigurationTest extends AdapterTestCase { AssertionUtils.assertException(new AssertionUtils.ErroneousCode() { @Override public void run() throws Exception { - config.add(String.class); + config.addSetter(String.class); } }, IllegalArgumentException.class); } @@ -302,7 +302,7 @@ public class SetterConfigurationTest extends AdapterTestCase { List required = config.getRequiredInterfaces(); Collections.sort(required, new RequiredInterfaceComparator()); assertEquals(1, required.size()); - assertEquals("setHost", required.get(0).getName()); + assertEquals("setHost.0", required.get(0).getName()); ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); @@ -324,7 +324,7 @@ public class SetterConfigurationTest extends AdapterTestCase { List required = config.getRequiredInterfaces(); Collections.sort(required, new RequiredInterfaceComparator()); assertEquals(1, required.size()); - assertEquals("setHost", required.get(0).getName()); + assertEquals("setHost.0", required.get(0).getName()); ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class);