#73 - ControllerLinkBuilder does not reject unmapped types anymore.

ControllerLinkBuilder now simply assumes an empty mapping if no type-level mapping can be found.
This commit is contained in:
Oliver Gierke
2013-05-27 13:57:15 +02:00
parent a46e662632
commit 85e3a2462f
2 changed files with 5 additions and 8 deletions

View File

@@ -79,13 +79,8 @@ public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuil
ControllerLinkBuilder builder = new ControllerLinkBuilder(getBuilder());
String mapping = DISCOVERER.getMapping(controller);
UriTemplate template = new UriTemplate(mapping == null ? "/" : mapping);
if (mapping == null) {
throw new IllegalArgumentException(
String.format("No mapping found on controller class %s!", controller.getName()));
}
UriTemplate template = new UriTemplate(mapping);
return builder.slash(template.expand(parameters));
}

View File

@@ -81,9 +81,11 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
linkTo(InvalidController.class);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void createsLinkToUnmappedController() {
linkTo(UnmappedController.class);
Link link = linkTo(UnmappedController.class).withSelfRel();
assertThat(link.getHref(), is("http://localhost"));
}
@Test