#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:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user