From b016c0b1250ea7fbbc537708f6a5d8db3670f108 Mon Sep 17 00:00:00 2001 From: Greg Turnquist Date: Mon, 21 Oct 2019 13:03:04 -0500 Subject: [PATCH] DATAREST-1356 - Polishing. --- .../data/rest/tests/AbstractWebIntegrationTests.java | 6 +++--- .../data/rest/webmvc/jpa/JpaWebTests.java | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java index dc705d3e9..4588d20fd 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java @@ -20,12 +20,11 @@ import static org.hamcrest.CoreMatchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import net.minidev.json.JSONArray; - import java.util.Collections; import java.util.Map; import java.util.Optional; +import net.minidev.json.JSONArray; import org.junit.Before; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -121,7 +120,8 @@ public abstract class AbstractWebIntegrationTests { String href = link.isTemplated() ? link.expand().getHref() : link.getHref(); MockHttpServletResponse response = mvc.perform(put(href).content(payload.toString()).contentType(mediaType))// - .andExpect(status().is5xxServerError()).andReturn().getResponse(); + .andExpect(status().is5xxServerError())// + .andReturn().getResponse(); return StringUtils.hasText(response.getContentAsString()) ? response : client.request(link); } diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaWebTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaWebTests.java index d41a22a3d..8dc99b5da 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaWebTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaWebTests.java @@ -17,21 +17,20 @@ package org.springframework.data.rest.webmvc.jpa; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; import static org.junit.Assert.assertThat; +import static org.junit.Assert.*; import static org.springframework.data.rest.webmvc.util.TestUtils.*; import static org.springframework.http.HttpHeaders.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import net.minidev.json.JSONArray; - import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import net.minidev.json.JSONArray; import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -712,6 +711,7 @@ public class JpaWebTests extends CommonWebTests { * @return link to creator of order (associative link for given order instance) */ private Link prepareOrderResource(Order order) throws Exception { + Link orderLink = client.discoverUnique(LinkRelation.of("orders")); MockHttpServletResponse primaryResponse = postAndGet(orderLink, mapper.writeValueAsString(order), @@ -723,6 +723,7 @@ public class JpaWebTests extends CommonWebTests { * @return link to given person (canonical, self, link) */ private Link preparePersonResource(Person person) throws Exception { + Link orderLink = client.discoverUnique(LinkRelation.of("people")); MockHttpServletResponse primaryResponse = postAndGet(orderLink, mapper.writeValueAsString(person), @@ -773,7 +774,7 @@ public class JpaWebTests extends CommonWebTests { private static String toUriList(Link... links) { - List uris = new ArrayList(links.length); + List uris = new ArrayList<>(links.length); for (Link link : links) { uris.add(link.expand().getHref());