#1974 - Improve default LinkRelationProvider setup to also consider @Relation.
RepositoryRestConfiguration now defaults the LinkRelationProvider instance to a delegating one considering both AnnotationLinkRelationProvider and EvoLinkRelationProvider so that @Relation annotations on entity types.
This commit is contained in:
@@ -29,6 +29,8 @@ import org.springframework.data.rest.core.config.RepositoryCorsRegistry;
|
||||
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
|
||||
import org.springframework.data.rest.core.domain.Profile;
|
||||
import org.springframework.data.rest.core.domain.ProfileRepository;
|
||||
import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.hateoas.server.core.Relation;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
|
||||
@@ -136,4 +138,15 @@ public class RepositoryRestConfigurationUnitTests {
|
||||
public void rejectsNullRelProvider() {
|
||||
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> configuration.setRelProvider(null));
|
||||
}
|
||||
|
||||
@Test // #1974
|
||||
public void considersAtRelationOnTypesByDefault() {
|
||||
assertThat(configuration.getRelProvider().getItemResourceRelFor(Sample.class))
|
||||
.isEqualTo(LinkRelation.of("something"));
|
||||
}
|
||||
|
||||
@Relation("something")
|
||||
static class Sample {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user