From cb067ee00c17c8b66da854436e8e02f221fb3e53 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 18 Mar 2015 16:16:58 +0000 Subject: [PATCH] =?UTF-8?q?Align=20expectations=20with=20Spring=20Data=20R?= =?UTF-8?q?EST=E2=80=99s=20new=20behaviour=20in=20Fowler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The response produced by Spring Data REST to a search that will always return a single result, i.e. the return type is Foo rather than List or Page has improved in Fowler. Previously, the response would contain a single embedded resource. In Fowler, the response now contains the resource that used to be embedded as a top-level resource. This commit updates the expectations in one of the sample’s tests to match this new behaviour. See gh-2673 --- .../sample/data/jpa/SampleDataRestApplicationTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-boot-samples/spring-boot-sample-data-rest/src/test/java/sample/data/jpa/SampleDataRestApplicationTests.java b/spring-boot-samples/spring-boot-sample-data-rest/src/test/java/sample/data/jpa/SampleDataRestApplicationTests.java index 719db9365c5..f6530f87323 100644 --- a/spring-boot-samples/spring-boot-sample-data-rest/src/test/java/sample/data/jpa/SampleDataRestApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-data-rest/src/test/java/sample/data/jpa/SampleDataRestApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 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. @@ -29,6 +29,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; @@ -71,7 +72,8 @@ public class SampleDataRestApplicationTests { this.mvc.perform( get("/api/cities/search/findByNameAndCountryAllIgnoringCase?name=Melbourne&country=Australia")) .andExpect(status().isOk()) - .andExpect(jsonPath("_embedded.citys", hasSize(1))); + .andExpect(jsonPath("state", equalTo("Victoria"))) + .andExpect(jsonPath("name", equalTo("Melbourne"))); } @Test