#850 - Polishing.

Moved to factory methods on PluginRegistry.
This commit is contained in:
Oliver Drotbohm
2019-03-05 14:20:07 +01:00
parent ae08cd0eee
commit 4b08aa783e
3 changed files with 5 additions and 13 deletions

View File

@@ -40,7 +40,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.plugin.core.OrderAwarePluginRegistry;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.Assert;
import org.springframework.web.client.RestOperations;
import org.springframework.web.client.RestTemplate;
@@ -161,7 +161,7 @@ public class Traverson {
? DEFAULTS.getLinkDiscoverers(mediaTypes) //
: discoverer;
this.discoverers = new LinkDiscoverers(OrderAwarePluginRegistry.of(defaultedDiscoverers));
this.discoverers = new LinkDiscoverers(PluginRegistry.of(defaultedDiscoverers));
return this;
}

View File

@@ -19,11 +19,7 @@ import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.springframework.core.Ordered;
import org.springframework.hateoas.client.JsonPathLinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverers;
import org.springframework.http.MediaType;
import org.springframework.plugin.core.OrderAwarePluginRegistry;
import org.springframework.plugin.core.PluginRegistry;
/**
@@ -45,7 +41,8 @@ public class LinkDiscoverersUnitTest {
LinkDiscoverer low = new LowPriorityLinkDiscoverer();
LinkDiscoverer high = new HighPriorityLinkDiscoverer();
PluginRegistry<LinkDiscoverer, MediaType> registry = OrderAwarePluginRegistry.of(low, high);
PluginRegistry<LinkDiscoverer, MediaType> registry = PluginRegistry.of(low, high);
assertThat(registry.getRequiredPluginFor(MediaType.APPLICATION_JSON)).isEqualTo(high);
}

View File

@@ -20,11 +20,6 @@ import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.server.LinkRelationProvider;
import org.springframework.hateoas.server.core.AnnotationLinkRelationProvider;
import org.springframework.hateoas.server.core.DefaultLinkRelationProvider;
import org.springframework.hateoas.server.core.DelegatingLinkRelationProvider;
import org.springframework.hateoas.server.core.Relation;
import org.springframework.plugin.core.OrderAwarePluginRegistry;
import org.springframework.plugin.core.PluginRegistry;
/**
@@ -37,7 +32,7 @@ public class DelegatingRelProviderUnitTest {
@Test
public void foo() {
PluginRegistry<LinkRelationProvider, Class<?>> registry = OrderAwarePluginRegistry.of(new AnnotationLinkRelationProvider(),
PluginRegistry<LinkRelationProvider, Class<?>> registry = PluginRegistry.of(new AnnotationLinkRelationProvider(),
new DefaultLinkRelationProvider());
LinkRelationProvider delegatingProvider = new DelegatingLinkRelationProvider(registry);