#236, #286 - Added test case to show how to add empty embedded collections.

This commit is contained in:
Oliver Gierke
2015-02-10 15:28:13 +01:00
parent ea4c1064c1
commit 629028a7ef

View File

@@ -36,6 +36,7 @@ import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.UriTemplate;
import org.springframework.hateoas.core.AnnotationRelProvider;
import org.springframework.hateoas.core.EmbeddedWrappers;
import org.springframework.hateoas.hal.Jackson2HalModule.HalHandlerInstantiator;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -344,6 +345,22 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
assertThat(getCuriedObjectMapper(provider).writeValueAsString(resources), is(MULTIPLE_CURIES_DOCUMENT));
}
/**
* @see #286, #236
*/
@Test
public void rendersEmptyEmbeddedCollections() throws Exception {
EmbeddedWrappers wrappers = new EmbeddedWrappers(false);
List<Object> values = new ArrayList<Object>();
values.add(wrappers.emptyCollectionOf(SimpleAnnotatedPojo.class));
Resources<Object> resources = new Resources<Object>(values);
assertThat(write(resources), is("{\"_embedded\":{\"pojos\":[]}}"));
}
private static Resources<Resource<SimpleAnnotatedPojo>> setupAnnotatedPagedResources() {
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>();