From ce5e66b2f846280597341917970f7e634afae6a0 Mon Sep 17 00:00:00 2001 From: Patrick ALLAIN Date: Tue, 2 Jun 2020 07:32:29 +0200 Subject: [PATCH] [#1300] Integrate abstract class for collection model --- .../hateoas/AbstractCollectionModel.java | 116 ++++++++++++++++++ .../hateoas/CollectionModel.java | 68 +--------- .../springframework/hateoas/EntityModel.java | 1 - .../springframework/hateoas/PagedModel.java | 14 ++- .../Jackson2CollectionJsonModule.java | 23 ++-- .../hal/forms/HalFormsSerializers.java | 7 +- .../hateoas/mediatype/uber/UberData.java | 15 ++- .../RepresentationModelProcessorInvoker.java | 17 +-- .../hateoas/CollectionModelUnitTest.java | 3 +- .../hateoas/PagedModelUnitTest.java | 10 ++ ...Jackson2CollectionJsonIntegrationTest.java | 2 +- .../hal/Jackson2HalIntegrationTest.java | 2 +- .../Jackson2HalFormsIntegrationTest.java | 2 +- .../uber/Jackson2UberIntegrationTest.java | 5 +- ...ndlerMethodReturnValueHandlerUnitTest.java | 6 +- 15 files changed, 183 insertions(+), 108 deletions(-) create mode 100644 src/main/java/org/springframework/hateoas/AbstractCollectionModel.java diff --git a/src/main/java/org/springframework/hateoas/AbstractCollectionModel.java b/src/main/java/org/springframework/hateoas/AbstractCollectionModel.java new file mode 100644 index 000000000..557150994 --- /dev/null +++ b/src/main/java/org/springframework/hateoas/AbstractCollectionModel.java @@ -0,0 +1,116 @@ +/* + * Copyright 2012-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.hateoas; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.springframework.lang.Nullable; +import org.springframework.util.Assert; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.Objects; +import java.util.function.Supplier; + +/** + * General helper to easily create a wrapper for a collection of entities. + * + * @author Oliver Gierke + * @author Greg Turnquist + */ +public class AbstractCollectionModel, T> extends RepresentationModel implements Iterable { + + private final Collection content; + + public AbstractCollectionModel() { + this(new ArrayList<>(), Collections.emptyList()); + } + + /** + * Creates a {@link AbstractCollectionModel} instance with the given content and {@link Link}s. + * + * @param content must not be {@literal null}. + * @param links the links to be added to the {@link AbstractCollectionModel}. + */ + protected AbstractCollectionModel(Iterable content, Iterable links) { + + Assert.notNull(content, "Content must not be null!"); + + this.content = new ArrayList<>(); + + for (T element : content) { + this.content.add(element); + } + + this.add(links); + } + + /** + * Returns the underlying elements. + * + * @return the content will never be {@literal null}. + */ + @JsonProperty("content") + public Collection getContent() { + return Collections.unmodifiableCollection(content); + } + + /* + * (non-Javadoc) + * @see java.lang.Iterable#iterator() + */ + @Override + public Iterator iterator() { + return content.iterator(); + } + + /* + * (non-Javadoc) + * @see org.springframework.hateoas.ResourceSupport#equals(java.lang.Object) + */ + @Override + public boolean equals(@Nullable Object obj) { + + if (obj == this) { + return true; + } + + if (obj == null || !obj.getClass().equals(getClass())) { + return false; + } + + if (!super.equals(obj)) { + return false; + } + + AbstractCollectionModel that = (AbstractCollectionModel) obj; + return Objects.equals(this.content, that.content); + } + + /* + * (non-Javadoc) + * @see org.springframework.hateoas.ResourceSupport#hashCode() + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result += 17 * Objects.hashCode(content); + return result; + } + +} diff --git a/src/main/java/org/springframework/hateoas/CollectionModel.java b/src/main/java/org/springframework/hateoas/CollectionModel.java index 21b8cf1e8..ef0daf5cb 100644 --- a/src/main/java/org/springframework/hateoas/CollectionModel.java +++ b/src/main/java/org/springframework/hateoas/CollectionModel.java @@ -32,9 +32,7 @@ * @author Oliver Gierke * @author Greg Turnquist */ -public class CollectionModel extends RepresentationModel> implements Iterable { - - private final Collection content; +public class CollectionModel extends AbstractCollectionModel, T> implements Iterable { /** * Creates an empty {@link CollectionModel} instance. @@ -64,16 +62,7 @@ public CollectionModel(Iterable content, Link... links) { */ @Deprecated public CollectionModel(Iterable content, Iterable links) { - - Assert.notNull(content, "Content must not be null!"); - - this.content = new ArrayList<>(); - - for (T element : content) { - this.content.add(element); - } - - this.add(links); + super(content, links); } /** @@ -115,7 +104,6 @@ public static CollectionModel empty(Iterable links) { * Creates a {@link CollectionModel} instance with the given content. * * @param content must not be {@literal null}. - * @param links the links to be added to the {@link CollectionModel}. * @return * @since 1.1 */ @@ -168,25 +156,6 @@ public static , S> CollectionModel wrap(Iterable return CollectionModel.of(resources); } - /** - * Returns the underlying elements. - * - * @return the content will never be {@literal null}. - */ - @JsonProperty("content") - public Collection getContent() { - return Collections.unmodifiableCollection(content); - } - - /* - * (non-Javadoc) - * @see java.lang.Iterable#iterator() - */ - @Override - public Iterator iterator() { - return content.iterator(); - } - /* * (non-Javadoc) * @see org.springframework.hateoas.ResourceSupport#toString() @@ -196,37 +165,4 @@ public String toString() { return String.format("Resources { content: %s, %s }", getContent(), super.toString()); } - /* - * (non-Javadoc) - * @see org.springframework.hateoas.ResourceSupport#equals(java.lang.Object) - */ - @Override - public boolean equals(@Nullable Object obj) { - - if (obj == this) { - return true; - } - - if (obj == null || !obj.getClass().equals(getClass())) { - return false; - } - - CollectionModel that = (CollectionModel) obj; - - boolean contentEqual = this.content == null ? that.content == null : this.content.equals(that.content); - return contentEqual && super.equals(obj); - } - - /* - * (non-Javadoc) - * @see org.springframework.hateoas.ResourceSupport#hashCode() - */ - @Override - public int hashCode() { - - int result = super.hashCode(); - result += content == null ? 0 : 17 * content.hashCode(); - - return result; - } } diff --git a/src/main/java/org/springframework/hateoas/EntityModel.java b/src/main/java/org/springframework/hateoas/EntityModel.java index d7fee1632..bf24de14b 100644 --- a/src/main/java/org/springframework/hateoas/EntityModel.java +++ b/src/main/java/org/springframework/hateoas/EntityModel.java @@ -78,7 +78,6 @@ public EntityModel(T content, Iterable links) { * Creates a new {@link EntityModel} with the given content. * * @param content must not be {@literal null}. - * @param links the links to add to the {@link EntityModel}. * @return * @since 1.1 */ diff --git a/src/main/java/org/springframework/hateoas/PagedModel.java b/src/main/java/org/springframework/hateoas/PagedModel.java index 0456a2ca6..4736b53f1 100644 --- a/src/main/java/org/springframework/hateoas/PagedModel.java +++ b/src/main/java/org/springframework/hateoas/PagedModel.java @@ -19,6 +19,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Objects; import java.util.Optional; import org.springframework.lang.Nullable; @@ -33,7 +34,7 @@ * @author Oliver Gierke * @author Greg Turnquist */ -public class PagedModel extends CollectionModel { +public class PagedModel extends AbstractCollectionModel, T> { public static PagedModel NO_PAGE = new PagedModel<>(); @@ -153,7 +154,6 @@ public static PagedModel empty(@Nullable PageMetadata metadata, Iterable< * * @param content must not be {@literal null}. * @param metadata can be {@literal null}. - * @param links */ public static PagedModel of(Collection content, @Nullable PageMetadata metadata) { return new PagedModel<>(content, metadata); @@ -256,10 +256,12 @@ public boolean equals(@Nullable Object obj) { return false; } - PagedModel that = (PagedModel) obj; - boolean metadataEquals = this.metadata == null ? that.metadata == null : this.metadata.equals(that.metadata); + if (!super.equals(obj)) { + return false; + } - return metadataEquals && super.equals(obj); + PagedModel that = (PagedModel) obj; + return Objects.equals(this.metadata, that.metadata); } /* @@ -270,7 +272,7 @@ public boolean equals(@Nullable Object obj) { public int hashCode() { int result = super.hashCode(); - result += this.metadata == null ? 0 : 31 * this.metadata.hashCode(); + result += 31 * Objects.hashCode(this.metadata); return result; } diff --git a/src/main/java/org/springframework/hateoas/mediatype/collectionjson/Jackson2CollectionJsonModule.java b/src/main/java/org/springframework/hateoas/mediatype/collectionjson/Jackson2CollectionJsonModule.java index 94c2fdb77..aa41a3d89 100644 --- a/src/main/java/org/springframework/hateoas/mediatype/collectionjson/Jackson2CollectionJsonModule.java +++ b/src/main/java/org/springframework/hateoas/mediatype/collectionjson/Jackson2CollectionJsonModule.java @@ -23,6 +23,7 @@ import java.util.function.Function; import java.util.stream.Collectors; +import org.springframework.hateoas.AbstractCollectionModel; import org.springframework.hateoas.Affordance; import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.EntityModel; @@ -793,22 +794,22 @@ public JsonDeserializer createContextual(DeserializationContext ctxt, BeanPro } } - static abstract class CollectionJsonDeserializerBase> + static abstract class AbstractCollectionJsonDeserializer> extends ContainerDeserializerBase implements ContextualDeserializer { private static final long serialVersionUID = 1007769482339850545L; private final JavaType contentType; private final BiFunction, Links, T> finalizer; - private final Function> creator; + private final Function> creator; - CollectionJsonDeserializerBase(BiFunction, Links, T> finalizer, - Function> creator) { + AbstractCollectionJsonDeserializer(BiFunction, Links, T> finalizer, + Function> creator) { this(TypeFactory.defaultInstance().constructType(CollectionJson.class), finalizer, creator); } - private CollectionJsonDeserializerBase(JavaType contentType, BiFunction, Links, T> finalizer, - Function> creator) { + private AbstractCollectionJsonDeserializer(JavaType contentType, BiFunction, Links, T> finalizer, + Function> creator) { super(contentType); @@ -883,11 +884,11 @@ public T deserialize(JsonParser parser, DeserializationContext ctxt) throws IOEx } } - static class CollectionJsonResourcesDeserializer extends CollectionJsonDeserializerBase> { + static class CollectionJsonResourcesDeserializer extends AbstractCollectionJsonDeserializer> { private static final long serialVersionUID = 6406522912020578141L; private static final BiFunction, Links, CollectionModel> FINISHER = CollectionModel::of; - private static final Function>> CONTEXTUAL_CREATOR = CollectionJsonResourcesDeserializer::new; + private static final Function>> CONTEXTUAL_CREATOR = CollectionJsonResourcesDeserializer::new; CollectionJsonResourcesDeserializer() { super(FINISHER, CONTEXTUAL_CREATOR); @@ -898,12 +899,12 @@ private CollectionJsonResourcesDeserializer(JavaType contentType) { } } - static class CollectionJsonPagedResourcesDeserializer extends CollectionJsonDeserializerBase> { + static class CollectionJsonPagedResourcesDeserializer extends AbstractCollectionJsonDeserializer> { private static final long serialVersionUID = -7465448422501330790L; private static final BiFunction, Links, PagedModel> FINISHER = (content, links) -> PagedModel .of(content, null, links); - private static final Function>> CONTEXTUAL_CREATOR = CollectionJsonPagedResourcesDeserializer::new; + private static final Function>> CONTEXTUAL_CREATOR = CollectionJsonPagedResourcesDeserializer::new; CollectionJsonPagedResourcesDeserializer() { super(FINISHER, CONTEXTUAL_CREATOR); @@ -914,7 +915,7 @@ private CollectionJsonPagedResourcesDeserializer(JavaType contentType) { } } - private static List> resourcesToCollectionJsonItems(CollectionModel resources) { + private static List> resourcesToCollectionJsonItems(AbstractCollectionModel resources) { return resources.getContent().stream().map(content -> { diff --git a/src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsSerializers.java b/src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsSerializers.java index 72a80fe3a..d5e309a36 100644 --- a/src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsSerializers.java +++ b/src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsSerializers.java @@ -18,6 +18,7 @@ import java.io.IOException; import java.util.Map; +import org.springframework.hateoas.AbstractCollectionModel; import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.PagedModel; @@ -209,7 +210,7 @@ public JsonSerializer createContextual(SerializerProvider prov, BeanProperty /** * Serializer for {@link CollectionModel} */ - static class HalFormsCollectionModelSerializer extends ContainerSerializer> + static class HalFormsCollectionModelSerializer extends ContainerSerializer> implements ContextualSerializer { private static final long serialVersionUID = -3601146866067500734L; @@ -242,7 +243,7 @@ static class HalFormsCollectionModelSerializer extends ContainerSerializer value, JsonGenerator gen, SerializerProvider provider) throws IOException { + public void serialize(AbstractCollectionModel value, JsonGenerator gen, SerializerProvider provider) throws IOException { EmbeddedMapper mapper = configuration.isApplyPropertyNamingStrategy() // ? embeddedMapper.with(provider.getConfig().getPropertyNamingStrategy()) // @@ -297,7 +298,7 @@ public JsonSerializer getContentSerializer() { */ @Override @SuppressWarnings("null") - public boolean hasSingleElement(CollectionModel resources) { + public boolean hasSingleElement(AbstractCollectionModel resources) { return resources.getContent().size() == 1; } diff --git a/src/main/java/org/springframework/hateoas/mediatype/uber/UberData.java b/src/main/java/org/springframework/hateoas/mediatype/uber/UberData.java index 393b55807..61e290091 100644 --- a/src/main/java/org/springframework/hateoas/mediatype/uber/UberData.java +++ b/src/main/java/org/springframework/hateoas/mediatype/uber/UberData.java @@ -31,6 +31,7 @@ import java.util.Optional; import java.util.stream.Collectors; +import org.springframework.hateoas.AbstractCollectionModel; import org.springframework.hateoas.Affordance; import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.EntityModel; @@ -197,14 +198,13 @@ static List extractLinksAndContent(EntityModel resource) { return data; } - /** * Convert {@link CollectionModel} into a list of {@link UberData}, with each item nested in a sub-UberData. * * @param resources * @return */ - static List extractLinksAndContent(CollectionModel resources) { + private static List extractLinksAndCollectionContent(AbstractCollectionModel resources) { List data = extractLinks(resources); @@ -213,11 +213,20 @@ static List extractLinksAndContent(CollectionModel resources) { return data; } + /** + * Convert {@link CollectionModel} into a list of {@link UberData}, with each item nested in a sub-UberData. + * + * @param resources + * @return + */ + static List extractLinksAndContent(CollectionModel resources) { + return extractLinksAndCollectionContent(resources); + } @SuppressWarnings("null") static List extractLinksAndContent(PagedModel resources) { - List collectionOfResources = extractLinksAndContent((CollectionModel) resources); + List collectionOfResources = extractLinksAndCollectionContent(resources); if (resources.getMetadata() != null) { diff --git a/src/main/java/org/springframework/hateoas/server/mvc/RepresentationModelProcessorInvoker.java b/src/main/java/org/springframework/hateoas/server/mvc/RepresentationModelProcessorInvoker.java index f85316b10..947ffdfdd 100644 --- a/src/main/java/org/springframework/hateoas/server/mvc/RepresentationModelProcessorInvoker.java +++ b/src/main/java/org/springframework/hateoas/server/mvc/RepresentationModelProcessorInvoker.java @@ -23,6 +23,7 @@ import org.springframework.core.Ordered; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationAwareOrderComparator; +import org.springframework.hateoas.AbstractCollectionModel; import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.RepresentationModel; @@ -66,8 +67,8 @@ public RepresentationModelProcessorInvoker(Collection processor) { + public AbstractCollectionModelProcessorWrapper(RepresentationModelProcessor processor) { super(processor); } @@ -384,7 +385,7 @@ public boolean supports(ResolvableType type, Object value) { * @return */ - static boolean isValueTypeMatch(@Nullable CollectionModel collectionModel, ResolvableType target) { + static boolean isValueTypeMatch(@Nullable AbstractCollectionModel collectionModel, ResolvableType target) { if (collectionModel == null) { return false; @@ -398,7 +399,7 @@ static boolean isValueTypeMatch(@Nullable CollectionModel collectionModel, Re ResolvableType superType = null; - for (Class collectionModelType : Arrays.> asList(collectionModel.getClass(), CollectionModel.class)) { + for (Class collectionModelType : Arrays.> asList(collectionModel.getClass(), AbstractCollectionModel.class)) { superType = getSuperType(target, collectionModelType); @@ -412,7 +413,7 @@ static boolean isValueTypeMatch(@Nullable CollectionModel collectionModel, Re } Object element = content.iterator().next(); - ResolvableType resourceType = superType.getGeneric(0); + ResolvableType resourceType = superType.getGeneric(1); if (element instanceof EntityModel) { return EntityModelProcessorWrapper.isValueTypeMatch((EntityModel) element, resourceType); diff --git a/src/test/java/org/springframework/hateoas/CollectionModelUnitTest.java b/src/test/java/org/springframework/hateoas/CollectionModelUnitTest.java index 5a4c5b3e4..c96400e5e 100755 --- a/src/test/java/org/springframework/hateoas/CollectionModelUnitTest.java +++ b/src/test/java/org/springframework/hateoas/CollectionModelUnitTest.java @@ -63,8 +63,7 @@ void notEqualForDifferentContent() { void notEqualForDifferentLinks() { CollectionModel> left = CollectionModel.of(foo); - CollectionModel> right = CollectionModel.of(bar); - right.add(Link.of("localhost")); + CollectionModel> right = CollectionModel.of(bar).add(Link.of("localhost")); assertThat(left).isNotEqualTo(right); assertThat(right).isNotEqualTo(left); diff --git a/src/test/java/org/springframework/hateoas/PagedModelUnitTest.java b/src/test/java/org/springframework/hateoas/PagedModelUnitTest.java index ea1537a6b..20433a454 100755 --- a/src/test/java/org/springframework/hateoas/PagedModelUnitTest.java +++ b/src/test/java/org/springframework/hateoas/PagedModelUnitTest.java @@ -114,4 +114,14 @@ void allowsOneIndexedPages() { void calculatesTotalPagesCorrectly() { assertThat(new PageMetadata(5, 0, 16).getTotalPages()).isEqualTo(4L); } + + + /** + * @see #1300 + */ + @Test + void returnSelfTypeForFluentApi() { + final PagedModel foo = resources.add(Link.of("foo", IanaLinkRelations.NEXT.value())); + assertThat(foo).isSameAs(resources); + } } diff --git a/src/test/java/org/springframework/hateoas/mediatype/collectionjson/Jackson2CollectionJsonIntegrationTest.java b/src/test/java/org/springframework/hateoas/mediatype/collectionjson/Jackson2CollectionJsonIntegrationTest.java index 74ac72c79..ffee9667b 100644 --- a/src/test/java/org/springframework/hateoas/mediatype/collectionjson/Jackson2CollectionJsonIntegrationTest.java +++ b/src/test/java/org/springframework/hateoas/mediatype/collectionjson/Jackson2CollectionJsonIntegrationTest.java @@ -231,7 +231,7 @@ void deserializesPagedResource() throws Exception { assertThat(result).isEqualTo(setupAnnotatedPagedResources()); } - private static CollectionModel> setupAnnotatedPagedResources() { + private static PagedModel> setupAnnotatedPagedResources() { List> content = new ArrayList<>(); content.add(EntityModel.of(new SimplePojo("test1", 1), Link.of("localhost"))); diff --git a/src/test/java/org/springframework/hateoas/mediatype/hal/Jackson2HalIntegrationTest.java b/src/test/java/org/springframework/hateoas/mediatype/hal/Jackson2HalIntegrationTest.java index 15f7e8bbc..51d9a3c08 100755 --- a/src/test/java/org/springframework/hateoas/mediatype/hal/Jackson2HalIntegrationTest.java +++ b/src/test/java/org/springframework/hateoas/mediatype/hal/Jackson2HalIntegrationTest.java @@ -626,7 +626,7 @@ private void verifyResolvedTitle(String resourceBundleKey) throws Exception { assertThat(objectMapper.writeValueAsString(resource)).isEqualTo(LINK_WITH_TITLE); } - private static CollectionModel> setupAnnotatedPagedResources() { + private static PagedModel> setupAnnotatedPagedResources() { List> content = new ArrayList<>(); content.add(EntityModel.of(new SimpleAnnotatedPojo("test1", 1), Link.of("localhost"))); diff --git a/src/test/java/org/springframework/hateoas/mediatype/hal/forms/Jackson2HalFormsIntegrationTest.java b/src/test/java/org/springframework/hateoas/mediatype/hal/forms/Jackson2HalFormsIntegrationTest.java index bdf5c71bc..eab971635 100644 --- a/src/test/java/org/springframework/hateoas/mediatype/hal/forms/Jackson2HalFormsIntegrationTest.java +++ b/src/test/java/org/springframework/hateoas/mediatype/hal/forms/Jackson2HalFormsIntegrationTest.java @@ -585,7 +585,7 @@ private static CollectionModel> setupAnnotatedR return CollectionModel.of(content); } - private static CollectionModel> setupAnnotatedPagedResources() { + private static PagedModel> setupAnnotatedPagedResources() { List> content = new ArrayList<>(); content.add(EntityModel.of(new SimpleAnnotatedPojo("test1", 1), Link.of("localhost"))); diff --git a/src/test/java/org/springframework/hateoas/mediatype/uber/Jackson2UberIntegrationTest.java b/src/test/java/org/springframework/hateoas/mediatype/uber/Jackson2UberIntegrationTest.java index d7c23a781..e4ba6e4e3 100644 --- a/src/test/java/org/springframework/hateoas/mediatype/uber/Jackson2UberIntegrationTest.java +++ b/src/test/java/org/springframework/hateoas/mediatype/uber/Jackson2UberIntegrationTest.java @@ -30,6 +30,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; +import org.springframework.hateoas.AbstractCollectionModel; import org.springframework.hateoas.AbstractJackson2MarshallingIntegrationTest; import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.EntityModel; @@ -537,13 +538,13 @@ void handleTemplatedLinksOnDeserialization() throws IOException { assertThat(deserialized).isEqualTo(original); } - private static CollectionModel> setupAnnotatedPagedResources() { + private static AbstractCollectionModel> setupAnnotatedPagedResources() { return setupAnnotatedPagedResources(2, 4); } @NotNull - private static CollectionModel> setupAnnotatedPagedResources(int size, int totalElements) { + private static AbstractCollectionModel> setupAnnotatedPagedResources(int size, int totalElements) { List> content = new ArrayList<>(); Employee employee = new Employee("Frodo", "ring bearer"); diff --git a/src/test/java/org/springframework/hateoas/server/mvc/ResourceProcessorHandlerMethodReturnValueHandlerUnitTest.java b/src/test/java/org/springframework/hateoas/server/mvc/ResourceProcessorHandlerMethodReturnValueHandlerUnitTest.java index 87b828ee9..d2856c19d 100644 --- a/src/test/java/org/springframework/hateoas/server/mvc/ResourceProcessorHandlerMethodReturnValueHandlerUnitTest.java +++ b/src/test/java/org/springframework/hateoas/server/mvc/ResourceProcessorHandlerMethodReturnValueHandlerUnitTest.java @@ -46,7 +46,7 @@ import org.springframework.hateoas.server.RepresentationModelProcessor; import org.springframework.hateoas.server.core.EmbeddedWrappers; import org.springframework.hateoas.server.core.HeaderLinksResponseEntity; -import org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker.CollectionModelProcessorWrapper; +import org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker.AbstractCollectionModelProcessorWrapper; import org.springframework.http.HttpEntity; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -270,7 +270,7 @@ void resourcesProcessorMatchesValueSubTypes() { ResolvableType type = ResolvableType.forClass(PagedStringResources.class); - assertThat(CollectionModelProcessorWrapper.isValueTypeMatch(FOO_PAGE, type)).isTrue(); + assertThat(AbstractCollectionModelProcessorWrapper.isValueTypeMatch(FOO_PAGE, type)).isTrue(); } /** @@ -281,7 +281,7 @@ void doesNotInvokeAProcessorForASpecializedType() throws Exception { EmbeddedWrappers wrappers = new EmbeddedWrappers(false); CollectionModel value = CollectionModel.of(singleton(wrappers.emptyCollectionOf(Object.class))); - CollectionModelProcessorWrapper wrapper = new CollectionModelProcessorWrapper(new SpecialResourcesProcessor()); + AbstractCollectionModelProcessorWrapper wrapper = new AbstractCollectionModelProcessorWrapper(new SpecialResourcesProcessor()); ResolvableType type = ResolvableType.forMethodReturnType(Controller.class.getMethod("resourcesOfObject"));