#1479 - DelegatingEntityLinks now overrides linkForItemResource(Class<?>, Object).
This commit is contained in:
@@ -78,7 +78,16 @@ public class DelegatingEntityLinks extends AbstractEntityLinks {
|
||||
return getPluginFor(type).linkToItemResource(type, id);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.hateoas.server.core.AbstractEntityLinks#linkForItemResource(java.lang.Class, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public LinkBuilder linkForItemResource(Class<?> type, Object id) {
|
||||
return getPluginFor(type).linkForItemResource(type, id);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)
|
||||
*/
|
||||
|
||||
@@ -72,6 +72,17 @@ class DelegatingEntityLinksUnitTest extends TestUtils {
|
||||
verify(target, times(1)).linkFor(String.class);
|
||||
}
|
||||
|
||||
@Test // #1479
|
||||
void delegatesCallToLinkForItemResource() {
|
||||
|
||||
EntityLinks target = mock(EntityLinks.class);
|
||||
when(target.supports(String.class)).thenReturn(true);
|
||||
|
||||
createDelegatingEntityLinks(target).linkForItemResource(String.class, 0);
|
||||
|
||||
verify(target, times(1)).linkForItemResource(String.class, 0);
|
||||
}
|
||||
|
||||
private EntityLinks createDelegatingEntityLinks(EntityLinks target) {
|
||||
return new DelegatingEntityLinks(SimplePluginRegistry.of(target));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user