Permalink
Browse files

Fixing test on linkTo with generic controller

  • Loading branch information...
1 parent 6c6fe9a commit ecd55f5b1da155e90fb19b1f9eda9364230d55a8 Nykolas Lima committed Nov 6, 2012
@@ -0,0 +1,12 @@
+package br.com.caelum.vraptor.view;
+
+/**
+ * Controller used to test Generic Controllers on LinkToHandler
+ * @author Nykolas Lima
+ *
+ */
+public class GenericController<T> {
+ public void method(T entity) {
+ System.out.println("Do Something");
+ }
+}
@@ -56,11 +56,11 @@ public void shouldReturnWantedUrlWithParamArgs() {
}
@Test
- public void shouldReturnWantedUrlForOverrideMethodWithParamArgs() {
+ public void shouldReturnWantedUrlForOverrideMethodWithParamArgs() throws NoSuchMethodException, SecurityException {
String a = "test";
- when(router.urlFor(TestSubGenericController.class, TestSubGenericController.class.getDeclaredMethods()[0], new Object[]{a})).thenReturn("/expectedURL");
+ when(router.urlFor(SubGenericController.class, SubGenericController.class.getDeclaredMethod("method", new Class[]{String.class}), new Object[]{a})).thenReturn("/expectedURL");
//${linkTo[TestSubGenericController].method['test']}]
- String uri = handler.get(TestSubGenericController.class).get("method").get(a).toString();
+ String uri = handler.get(SubGenericController.class).get("method").get(a).toString();
assertThat(uri, is("/path/expectedURL"));
}
@@ -69,16 +69,4 @@ void method(String a, int b) {
}
}
-
- static class TestGenericController<T> {
- void method(T a) {
-
- }
- }
-
- static class TestSubGenericController extends TestGenericController<String> {
- void method(String a) {
-
- }
- }
}
@@ -0,0 +1,16 @@
+package br.com.caelum.vraptor.view;
+
+/**
+ * Controller used to test Generic Controllers on LinkToHandler
+ * @author Nykolas Lima
+ *
+ */
+public class SubGenericController extends GenericController<String> {
+ public void method(String string) {
+ System.out.println("Do another thing by Sub Generic Controller");
+ }
+
+ public void okMethod(String string) {
+ System.out.println("OKOK");
+ }
+}

0 comments on commit ecd55f5

Please sign in to comment.