@@ -1,4 +1,3 @@
|
||||
package org.springframework.data.rest.tests;
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
*
|
||||
@@ -14,11 +13,12 @@ package org.springframework.data.rest.tests;
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.rest.tests;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -41,7 +41,7 @@ import org.springframework.data.rest.webmvc.support.Projector;
|
||||
import org.springframework.hateoas.server.EntityLinks;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
@@ -53,7 +53,7 @@ import org.springframework.web.context.request.WebRequest;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public abstract class AbstractControllerIntegrationTests {
|
||||
|
||||
@@ -79,7 +79,7 @@ public abstract class AbstractControllerIntegrationTests {
|
||||
@Autowired RepositoryInvokerFactory invokerFactory;
|
||||
@Autowired ResourceMappings mappings;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void initWebInfrastructure() {
|
||||
TestMvcClient.initWebTest();
|
||||
}
|
||||
|
||||
@@ -20,13 +20,14 @@ 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.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
|
||||
import org.springframework.hateoas.Link;
|
||||
@@ -36,7 +37,7 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.ResultMatcher;
|
||||
@@ -61,7 +62,7 @@ import com.jayway.jsonpath.JsonPath;
|
||||
* @author Christoph Strobl
|
||||
* @author Ľubomír Varga
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration(classes = { RepositoryRestMvcConfiguration.class, DelegatingWebMvcConfiguration.class })
|
||||
public abstract class AbstractWebIntegrationTests {
|
||||
@@ -74,7 +75,7 @@ public abstract class AbstractWebIntegrationTests {
|
||||
protected TestMvcClient client;
|
||||
protected MockMvc mvc;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
setupMockMvc();
|
||||
this.client = new TestMvcClient(mvc, discoverers);
|
||||
|
||||
@@ -17,16 +17,17 @@ package org.springframework.data.rest.tests;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.junit.jupiter.api.Assumptions.*;
|
||||
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.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minidev.json.JSONArray;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.rest.webmvc.RestMediaTypes;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.hateoas.Link;
|
||||
@@ -57,7 +58,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
// Root test cases
|
||||
|
||||
@Test
|
||||
public void exposesRootResource() throws Exception {
|
||||
void exposesRootResource() throws Exception {
|
||||
|
||||
ResultActions actions = mvc.perform(get("/").accept(TestMvcClient.DEFAULT_MEDIA_TYPE)).andExpect(status().isOk());
|
||||
|
||||
@@ -67,7 +68,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-113, DATAREST-638
|
||||
public void exposesSchemasForResourcesExposed() throws Exception {
|
||||
void exposesSchemasForResourcesExposed() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = client.request("/");
|
||||
|
||||
@@ -92,7 +93,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-203
|
||||
public void servesHalWhenRequested() throws Exception {
|
||||
void servesHalWhenRequested() throws Exception {
|
||||
|
||||
mvc.perform(get("/")). //
|
||||
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)). //
|
||||
@@ -100,7 +101,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-203
|
||||
public void servesHalWhenJsonIsRequested() throws Exception {
|
||||
void servesHalWhenJsonIsRequested() throws Exception {
|
||||
|
||||
mvc.perform(get("/").accept(MediaType.APPLICATION_JSON)). //
|
||||
andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)). //
|
||||
@@ -108,7 +109,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-203
|
||||
public void exposesSearchesForRootResources() throws Exception {
|
||||
void exposesSearchesForRootResources() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = client.request("/");
|
||||
|
||||
@@ -135,7 +136,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nic() throws Exception {
|
||||
void nic() throws Exception {
|
||||
|
||||
Map<LinkRelation, String> payloads = getPayloadToPost();
|
||||
assumeFalse(payloads.isEmpty());
|
||||
@@ -162,7 +163,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-198
|
||||
public void accessLinkedResources() throws Exception {
|
||||
void accessLinkedResources() throws Exception {
|
||||
|
||||
MockHttpServletResponse rootResource = client.request("/");
|
||||
|
||||
@@ -188,7 +189,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-230
|
||||
public void exposesDescriptionAsAlpsDocuments() throws Exception {
|
||||
void exposesDescriptionAsAlpsDocuments() throws Exception {
|
||||
|
||||
MediaType ALPS_MEDIA_TYPE = MediaType.valueOf("application/alps+json");
|
||||
|
||||
@@ -204,14 +205,14 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-448
|
||||
public void returnsNotFoundForUriNotBackedByARepository() throws Exception {
|
||||
void returnsNotFoundForUriNotBackedByARepository() throws Exception {
|
||||
|
||||
mvc.perform(get("/index.html")).//
|
||||
andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
@Test // DATAREST-658
|
||||
public void collectionResourcesExposeLinksAsHeadersForHeadRequest() throws Exception {
|
||||
void collectionResourcesExposeLinksAsHeadersForHeadRequest() throws Exception {
|
||||
|
||||
for (LinkRelation rel : expectedRootLinkRels()) {
|
||||
|
||||
@@ -229,7 +230,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-661
|
||||
public void patchToNonExistingResourceReturnsNotFound() throws Exception {
|
||||
void patchToNonExistingResourceReturnsNotFound() throws Exception {
|
||||
|
||||
LinkRelation rel = expectedRootLinkRels().iterator().next();
|
||||
String uri = client.discoverUnique(rel).expand().getHref().concat("/");
|
||||
@@ -249,7 +250,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-1003
|
||||
public void rejectsUnsupportedAcceptTypeForResources() throws Exception {
|
||||
void rejectsUnsupportedAcceptTypeForResources() throws Exception {
|
||||
|
||||
for (LinkRelation string : expectedRootLinkRels()) {
|
||||
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.tests;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
@@ -26,10 +24,10 @@ import java.util.Iterator;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.client.LinkDiscoverer;
|
||||
import org.springframework.hateoas.client.LinkDiscoverers;
|
||||
import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.hateoas.Links;
|
||||
import org.springframework.hateoas.client.LinkDiscoverer;
|
||||
import org.springframework.hateoas.client.LinkDiscoverers;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -85,8 +83,8 @@ public class TestMvcClient {
|
||||
|
||||
HttpHeaders headers = response.getHeaders();
|
||||
|
||||
assertThat(headers.getAllow(), hasSize(methods.length));
|
||||
assertThat(headers.getAllow(), hasItems(methods));
|
||||
assertThat(headers.getAllow()).hasSize(methods.length);
|
||||
assertThat(headers.getAllow()).contains(methods);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,8 +354,10 @@ public class TestMvcClient {
|
||||
MockHttpServletResponse response = result.getResponse();
|
||||
String s = response.getContentAsString();
|
||||
|
||||
assertThat("Expected to find link with rel " + rel + " but found none in " + s, //
|
||||
getDiscoverer(response).findLinkWithRel(rel, s), notNullValue());
|
||||
assertThat(getDiscoverer(response).findLinkWithRel(rel, s)) //
|
||||
.as(() -> "Expected to find link with rel " + rel + " but found none in " + s) //
|
||||
.isNotNull();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.data.util.AnnotatedTypeScanner;
|
||||
@Configuration
|
||||
@ImportResource("classpath:META-INF/spring/cache-config.xml")
|
||||
@EnableGemfireRepositories
|
||||
public class GeodeRepositoryConfig {
|
||||
class GeodeRepositoryConfig {
|
||||
|
||||
/**
|
||||
* TODO: Remove, once Spring Data Gemfire exposes a mapping context.
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@ContextConfiguration(classes = GeodeRepositoryConfig.class)
|
||||
public class GeodeWebTests extends CommonWebTests {
|
||||
class GeodeWebTests extends CommonWebTests {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.rest.webmvc;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.rest.tests.TestMvcClient.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.rest.tests.AbstractControllerIntegrationTests;
|
||||
import org.springframework.data.rest.webmvc.jpa.JpaRepositoryConfig;
|
||||
@@ -36,24 +36,24 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*/
|
||||
@ContextConfiguration(classes = JpaRepositoryConfig.class)
|
||||
@Transactional
|
||||
public class RepositoryControllerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
class RepositoryControllerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
|
||||
@Autowired RepositoryController controller;
|
||||
|
||||
@Test // DATAREST-333
|
||||
public void rootResourceExposesGetOnly() {
|
||||
void rootResourceExposesGetOnly() {
|
||||
|
||||
HttpEntity<?> response = controller.optionsForRepositories();
|
||||
assertAllowHeaders(response, HttpMethod.GET);
|
||||
}
|
||||
|
||||
@Test // DATAREST-333, DATAREST-330
|
||||
public void headRequestReturnsNoContent() {
|
||||
void headRequestReturnsNoContent() {
|
||||
assertThat(controller.headForRepositories().getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Test // DATAREST-160, DATAREST-333, DATAREST-463
|
||||
public void exposesLinksToRepositories() {
|
||||
void exposesLinksToRepositories() {
|
||||
|
||||
RepositoryLinksResource resource = controller.listRepositories().getBody();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import static org.springframework.http.HttpMethod.*;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -62,7 +62,7 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
*/
|
||||
@ContextConfiguration(classes = { ConfigurationCustomizer.class, JpaRepositoryConfig.class })
|
||||
@Transactional
|
||||
public class RepositoryEntityControllerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
class RepositoryEntityControllerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
|
||||
@Autowired RepositoryEntityController controller;
|
||||
@Autowired AddressRepository repository;
|
||||
@@ -82,25 +82,28 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = HttpRequestMethodNotSupportedException.class) // DATAREST-217
|
||||
public void returnsNotFoundForListingEntitiesIfFindAllNotExported() throws Exception {
|
||||
@Test // DATAREST-217
|
||||
void returnsNotFoundForListingEntitiesIfFindAllNotExported() throws Exception {
|
||||
|
||||
repository.save(new Address());
|
||||
|
||||
RootResourceInformation request = getResourceInformation(Address.class);
|
||||
controller.getCollectionResource(request, null, null, null);
|
||||
|
||||
assertThatExceptionOfType(HttpRequestMethodNotSupportedException.class) //
|
||||
.isThrownBy(() -> controller.getCollectionResource(request, null, null, null));
|
||||
}
|
||||
|
||||
@Test(expected = HttpRequestMethodNotSupportedException.class) // DATAREST-217
|
||||
public void rejectsEntityCreationIfSaveIsNotExported() throws Exception {
|
||||
@Test // DATAREST-217
|
||||
void rejectsEntityCreationIfSaveIsNotExported() throws Exception {
|
||||
|
||||
RootResourceInformation request = getResourceInformation(Address.class);
|
||||
|
||||
controller.postCollectionResource(request, null, null, MediaType.APPLICATION_JSON_VALUE);
|
||||
assertThatExceptionOfType(HttpRequestMethodNotSupportedException.class) //
|
||||
.isThrownBy(() -> controller.postCollectionResource(request, null, null, MediaType.APPLICATION_JSON_VALUE));
|
||||
}
|
||||
|
||||
@Test // DATAREST-301
|
||||
public void setsExpandedSelfUriInLocationHeader() throws Exception {
|
||||
void setsExpandedSelfUriInLocationHeader() throws Exception {
|
||||
|
||||
RootResourceInformation information = getResourceInformation(Order.class);
|
||||
|
||||
@@ -114,20 +117,25 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-330
|
||||
public void exposesHeadForCollectionResourceIfExported() throws Exception {
|
||||
void exposesHeadForCollectionResourceIfExported() throws Exception {
|
||||
ResponseEntity<?> entity = controller.headCollectionResource(getResourceInformation(Person.class),
|
||||
new DefaultedPageable(Pageable.unpaged(), false));
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Test(expected = ResourceNotFoundException.class) // DATAREST-330
|
||||
public void doesNotExposeHeadForCollectionResourceIfNotExported() throws Exception {
|
||||
controller.headCollectionResource(getResourceInformation(CreditCard.class),
|
||||
new DefaultedPageable(Pageable.unpaged(), false));
|
||||
@Test // DATAREST-330
|
||||
void doesNotExposeHeadForCollectionResourceIfNotExported() throws Exception {
|
||||
|
||||
assertThatExceptionOfType(ResourceNotFoundException.class) //
|
||||
.isThrownBy(() -> {
|
||||
|
||||
controller.headCollectionResource(getResourceInformation(CreditCard.class),
|
||||
new DefaultedPageable(Pageable.unpaged(), false));
|
||||
});
|
||||
}
|
||||
|
||||
@Test // DATAREST-330
|
||||
public void exposesHeadForItemResourceIfExported() throws Exception {
|
||||
void exposesHeadForItemResourceIfExported() throws Exception {
|
||||
|
||||
Address address = repository.save(new Address());
|
||||
|
||||
@@ -137,34 +145,36 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Test(expected = ResourceNotFoundException.class) // DATAREST-330
|
||||
public void doesNotExposeHeadForItemResourceIfNotExisting() throws Exception {
|
||||
controller.headForItemResource(getResourceInformation(CreditCard.class), 1L, assembler);
|
||||
@Test // DATAREST-330
|
||||
void doesNotExposeHeadForItemResourceIfNotExisting() throws Exception {
|
||||
|
||||
assertThatExceptionOfType(ResourceNotFoundException.class) //
|
||||
.isThrownBy(() -> controller.headForItemResource(getResourceInformation(CreditCard.class), 1L, assembler));
|
||||
}
|
||||
|
||||
@Test // DATAREST-333
|
||||
public void doesNotExposeMethodsForOptionsIfNotHttpMethodsSupportedForCollectionResource() {
|
||||
void doesNotExposeMethodsForOptionsIfNotHttpMethodsSupportedForCollectionResource() {
|
||||
|
||||
HttpEntity<?> response = controller.optionsForCollectionResource(getResourceInformation(Address.class));
|
||||
assertAllowHeaders(response, OPTIONS);
|
||||
}
|
||||
|
||||
@Test // DATAREST-333
|
||||
public void exposesSupportedHttpMethodsInAllowHeaderForOptionsRequestToCollectionResource() {
|
||||
void exposesSupportedHttpMethodsInAllowHeaderForOptionsRequestToCollectionResource() {
|
||||
|
||||
HttpEntity<?> response = controller.optionsForCollectionResource(getResourceInformation(Person.class));
|
||||
assertAllowHeaders(response, GET, POST, HEAD, OPTIONS);
|
||||
}
|
||||
|
||||
@Test // DATAREST-333
|
||||
public void exposesSupportedHttpMethodsInAllowHeaderForOptionsRequestToItemResource() {
|
||||
void exposesSupportedHttpMethodsInAllowHeaderForOptionsRequestToItemResource() {
|
||||
|
||||
HttpEntity<?> response = controller.optionsForItemResource(getResourceInformation(Person.class));
|
||||
assertAllowHeaders(response, GET, PUT, PATCH, DELETE, HEAD, OPTIONS);
|
||||
}
|
||||
|
||||
@Test // DATAREST-333, DATAREST-348
|
||||
public void optionsForItermResourceSetsAllowPatchHeader() {
|
||||
void optionsForItermResourceSetsAllowPatchHeader() {
|
||||
|
||||
ResponseEntity<?> entity = controller.optionsForItemResource(getResourceInformation(Person.class));
|
||||
|
||||
@@ -176,7 +186,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-34
|
||||
public void returnsBodyOnPutForUpdateIfAcceptHeaderPresentByDefault() throws Exception {
|
||||
void returnsBodyOnPutForUpdateIfAcceptHeaderPresentByDefault() throws Exception {
|
||||
|
||||
RootResourceInformation request = getResourceInformation(Order.class);
|
||||
Order order = request.getInvoker().invokeSave(new Order(new Person()));
|
||||
@@ -189,7 +199,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-34
|
||||
public void returnsBodyForCreatingPutIfAcceptHeaderPresentByDefault() throws HttpRequestMethodNotSupportedException {
|
||||
void returnsBodyForCreatingPutIfAcceptHeaderPresentByDefault() throws HttpRequestMethodNotSupportedException {
|
||||
|
||||
RootResourceInformation request = getResourceInformation(Order.class);
|
||||
PersistentEntityResource persistentEntityResource = PersistentEntityResource
|
||||
@@ -200,7 +210,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-34
|
||||
public void returnsBodyForPostIfAcceptHeaderIsPresentByDefault() throws Exception {
|
||||
void returnsBodyForPostIfAcceptHeaderIsPresentByDefault() throws Exception {
|
||||
|
||||
RootResourceInformation request = getResourceInformation(Order.class);
|
||||
PersistentEntityResource persistentEntityResource = PersistentEntityResource
|
||||
@@ -212,7 +222,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-34
|
||||
public void doesNotReturnBodyForPostIfNoAcceptHeaderPresentByDefault() throws Exception {
|
||||
void doesNotReturnBodyForPostIfNoAcceptHeaderPresentByDefault() throws Exception {
|
||||
|
||||
RootResourceInformation request = getResourceInformation(Order.class);
|
||||
PersistentEntityResource persistentEntityResource = PersistentEntityResource
|
||||
@@ -224,7 +234,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-581
|
||||
public void createsEtagForProjectedEntityCorrectly() throws Exception {
|
||||
void createsEtagForProjectedEntityCorrectly() throws Exception {
|
||||
|
||||
Address address = repository.save(new Address());
|
||||
|
||||
@@ -244,7 +254,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-724
|
||||
public void deletesEntityWithCustomLookupCorrectly() throws Exception {
|
||||
void deletesEntityWithCustomLookupCorrectly() throws Exception {
|
||||
|
||||
Address address = repository.save(new Address());
|
||||
assertThat(repository.findById(address.id)).isNotNull();
|
||||
@@ -262,7 +272,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-948
|
||||
public void rejectsPutForCreationIfConfigured() throws HttpRequestMethodNotSupportedException {
|
||||
void rejectsPutForCreationIfConfigured() throws HttpRequestMethodNotSupportedException {
|
||||
|
||||
RootResourceInformation request = getResourceInformation(Address.class);
|
||||
PersistentEntityResource persistentEntityResource = PersistentEntityResource
|
||||
|
||||
@@ -18,9 +18,8 @@ package org.springframework.data.rest.webmvc;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.rest.tests.AbstractControllerIntegrationTests;
|
||||
import org.springframework.data.rest.webmvc.jpa.Book;
|
||||
@@ -36,7 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*/
|
||||
@ContextConfiguration(classes = JpaRepositoryConfig.class)
|
||||
@Transactional
|
||||
public class RepositoryPropertyReferenceControllerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
class RepositoryPropertyReferenceControllerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
|
||||
@Autowired RepositoryPropertyReferenceController controller;
|
||||
@Autowired TestDataPopulator populator;
|
||||
@@ -45,8 +44,8 @@ public class RepositoryPropertyReferenceControllerIntegrationTests extends Abstr
|
||||
PersistentEntityResourceAssembler assembler;
|
||||
RootResourceInformation information;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
this.assembler = mock(PersistentEntityResourceAssembler.class);
|
||||
this.information = getResourceInformation(Book.class);
|
||||
@@ -54,7 +53,7 @@ public class RepositoryPropertyReferenceControllerIntegrationTests extends Abstr
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exposesResourceForCustomizedPropertyResourcePath() throws Exception {
|
||||
void exposesResourceForCustomizedPropertyResourcePath() throws Exception {
|
||||
|
||||
Book book = books.findAll().iterator().next();
|
||||
|
||||
@@ -62,11 +61,12 @@ public class RepositoryPropertyReferenceControllerIntegrationTests extends Abstr
|
||||
.isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Test(expected = ResourceNotFoundException.class)
|
||||
public void doesNotExposeOriginalPathIfPropertyResourcePathIsCustomized() throws Exception {
|
||||
@Test
|
||||
void doesNotExposeOriginalPathIfPropertyResourcePathIsCustomized() {
|
||||
|
||||
Book book = books.findAll().iterator().next();
|
||||
|
||||
controller.followPropertyReference(information, book.id, "authors", assembler);
|
||||
assertThatExceptionOfType(ResourceNotFoundException.class) //
|
||||
.isThrownBy(() -> controller.followPropertyReference(information, book.id, "authors", assembler));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.data.rest.webmvc;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.rest.tests.TestMvcClient.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -35,9 +35,9 @@ import org.springframework.data.rest.webmvc.jpa.JpaRepositoryConfig;
|
||||
import org.springframework.data.rest.webmvc.jpa.Person;
|
||||
import org.springframework.data.rest.webmvc.jpa.TestDataPopulator;
|
||||
import org.springframework.data.rest.webmvc.support.DefaultedPageable;
|
||||
import org.springframework.hateoas.CollectionModel;
|
||||
import org.springframework.hateoas.PagedModel;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.hateoas.CollectionModel;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -55,7 +55,7 @@ import org.springframework.util.MultiValueMap;
|
||||
*/
|
||||
@ContextConfiguration(classes = JpaRepositoryConfig.class)
|
||||
@Transactional
|
||||
public class RepositorySearchControllerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
class RepositorySearchControllerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
|
||||
static final DefaultedPageable PAGEABLE = new DefaultedPageable(PageRequest.of(0, 10), true);
|
||||
|
||||
@@ -63,16 +63,16 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll
|
||||
@Autowired RepositorySearchController controller;
|
||||
@Autowired PersistentEntityResourceAssembler assembler;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
loader.populateRepositories();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rendersCorrectSearchLinksForPersons() throws Exception {
|
||||
void rendersCorrectSearchLinksForPersons() throws Exception {
|
||||
|
||||
RootResourceInformation request = getResourceInformation(Person.class);
|
||||
RepresentationModel resource = controller.listSearches(request);
|
||||
RepresentationModel<?> resource = controller.listSearches(request);
|
||||
|
||||
ResourceTester tester = ResourceTester.of(resource);
|
||||
tester.assertNumberOfLinks(7); // Self link included
|
||||
@@ -86,18 +86,22 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll
|
||||
tester.assertHasLinkEndingWith("findCreatedDateByLastName", "findCreatedDateByLastName{?lastname}");
|
||||
}
|
||||
|
||||
@Test(expected = ResourceNotFoundException.class)
|
||||
public void returns404ForUnexportedRepository() {
|
||||
controller.listSearches(getResourceInformation(CreditCard.class));
|
||||
}
|
||||
@Test
|
||||
void returns404ForUnexportedRepository() {
|
||||
|
||||
@Test(expected = ResourceNotFoundException.class)
|
||||
public void returns404ForRepositoryWithoutSearches() {
|
||||
controller.listSearches(getResourceInformation(Author.class));
|
||||
assertThatExceptionOfType(ResourceNotFoundException.class) //
|
||||
.isThrownBy(() -> controller.listSearches(getResourceInformation(CreditCard.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void executesSearchAgainstRepository() {
|
||||
void returns404ForRepositoryWithoutSearches() {
|
||||
|
||||
assertThatExceptionOfType(ResourceNotFoundException.class) //
|
||||
.isThrownBy(() -> controller.listSearches(getResourceInformation(Author.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void executesSearchAgainstRepository() {
|
||||
|
||||
RootResourceInformation resourceInformation = getResourceInformation(Person.class);
|
||||
MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>(1);
|
||||
@@ -114,43 +118,51 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll
|
||||
tester.withContentResource(new HasSelfLink(BASE.slash(metadata.getPath()).slash("{id}")));
|
||||
}
|
||||
|
||||
@Test(expected = ResourceNotFoundException.class) // DATAREST-330
|
||||
public void doesNotExposeHeadForSearchResourceIfResourceDoesnHaveSearches() {
|
||||
controller.headForSearches(getResourceInformation(Author.class));
|
||||
}
|
||||
@Test // DATAREST-330
|
||||
void doesNotExposeHeadForSearchResourceIfResourceDoesnHaveSearches() {
|
||||
|
||||
@Test(expected = ResourceNotFoundException.class) // DATAREST-330
|
||||
public void exposesHeadForSearchResourceIfResourceIsNotExposed() {
|
||||
controller.headForSearches(getResourceInformation(CreditCard.class));
|
||||
assertThatExceptionOfType(ResourceNotFoundException.class) //
|
||||
.isThrownBy(() -> controller.headForSearches(getResourceInformation(Author.class)));
|
||||
}
|
||||
|
||||
@Test // DATAREST-330
|
||||
public void exposesHeadForSearchResourceIfResourceIsExposed() {
|
||||
void exposesHeadForSearchResourceIfResourceIsNotExposed() {
|
||||
|
||||
assertThatExceptionOfType(ResourceNotFoundException.class) //
|
||||
.isThrownBy(() -> controller.headForSearches(getResourceInformation(CreditCard.class)));
|
||||
}
|
||||
|
||||
@Test // DATAREST-330
|
||||
void exposesHeadForSearchResourceIfResourceIsExposed() {
|
||||
controller.headForSearches(getResourceInformation(Person.class));
|
||||
}
|
||||
|
||||
@Test // DATAREST-330
|
||||
public void exposesHeadForExistingQueryMethodResource() {
|
||||
void exposesHeadForExistingQueryMethodResource() {
|
||||
controller.headForSearch(getResourceInformation(Person.class), "findByCreatedUsingISO8601Date");
|
||||
}
|
||||
|
||||
@Test(expected = ResourceNotFoundException.class) // DATAREST-330
|
||||
public void doesNotExposeHeadForInvalidQueryMethodResource() {
|
||||
controller.headForSearch(getResourceInformation(Person.class), "foobar");
|
||||
@Test // DATAREST-330
|
||||
void doesNotExposeHeadForInvalidQueryMethodResource() {
|
||||
|
||||
assertThatExceptionOfType(ResourceNotFoundException.class) //
|
||||
.isThrownBy(() -> controller.headForSearch(getResourceInformation(Person.class), "foobar"));
|
||||
}
|
||||
|
||||
@Test // DATAREST-333
|
||||
public void searchResourceSupportsGetOnly() {
|
||||
void searchResourceSupportsGetOnly() {
|
||||
assertAllowHeaders(controller.optionsForSearches(getResourceInformation(Person.class)), HttpMethod.GET);
|
||||
}
|
||||
|
||||
@Test(expected = ResourceNotFoundException.class) // DATAREST-333
|
||||
public void returns404ForOptionsForRepositoryWithoutSearches() {
|
||||
controller.optionsForSearches(getResourceInformation(Address.class));
|
||||
@Test // DATAREST-333
|
||||
void returns404ForOptionsForRepositoryWithoutSearches() {
|
||||
|
||||
assertThatExceptionOfType(ResourceNotFoundException.class) //
|
||||
.isThrownBy(() -> controller.optionsForSearches(getResourceInformation(Address.class)));
|
||||
}
|
||||
|
||||
@Test // DATAREST-333
|
||||
public void queryMethodResourceSupportsGetOnly() {
|
||||
void queryMethodResourceSupportsGetOnly() {
|
||||
|
||||
RootResourceInformation resourceInformation = getResourceInformation(Person.class);
|
||||
HttpEntity<Object> response = controller.optionsForSearch(resourceInformation, "firstname");
|
||||
@@ -159,7 +171,7 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-502
|
||||
public void interpretsUriAsReferenceToRelatedEntity() {
|
||||
void interpretsUriAsReferenceToRelatedEntity() {
|
||||
|
||||
MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>(1);
|
||||
parameters.add("author", "/author/1");
|
||||
@@ -173,7 +185,7 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-515
|
||||
public void repositorySearchResourceExposesDomainType() {
|
||||
void repositorySearchResourceExposesDomainType() {
|
||||
|
||||
RepositorySearchesResource searches = controller.listSearches(getResourceInformation(Person.class));
|
||||
|
||||
@@ -181,7 +193,7 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll
|
||||
}
|
||||
|
||||
@Test // DATAREST-1121
|
||||
public void returnsSimpleResponseEntityForQueryMethod() {
|
||||
void returnsSimpleResponseEntityForQueryMethod() {
|
||||
|
||||
MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>();
|
||||
parameters.add("lastname", "Thornton");
|
||||
|
||||
@@ -19,14 +19,15 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.rest.core.mapping.ResourceType.*;
|
||||
import static org.springframework.http.HttpMethod.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.data.rest.core.mapping.ResourceType;
|
||||
import org.springframework.data.rest.core.mapping.SupportedHttpMethods;
|
||||
import org.springframework.data.rest.tests.AbstractControllerIntegrationTests;
|
||||
import org.springframework.data.rest.webmvc.jpa.Address;
|
||||
import org.springframework.data.rest.webmvc.jpa.JpaRepositoryConfig;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
@@ -34,20 +35,20 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = JpaRepositoryConfig.class)
|
||||
@Transactional
|
||||
public class RootResourceInformationIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
class RootResourceInformationIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
|
||||
@Test // DATAREST-217
|
||||
public void getIsNotSupportedIfFindAllIsNotExported() {
|
||||
void getIsNotSupportedIfFindAllIsNotExported() {
|
||||
|
||||
SupportedHttpMethods supportedMethods = getResourceInformation(Address.class).getSupportedMethods();
|
||||
assertThat(supportedMethods.getMethodsFor(COLLECTION)).doesNotContain(GET);
|
||||
}
|
||||
|
||||
@Test // DATAREST-217
|
||||
public void postIsNotSupportedIfSaveIsNotExported() {
|
||||
void postIsNotSupportedIfSaveIsNotExported() {
|
||||
|
||||
SupportedHttpMethods supportedMethods = getResourceInformation(Address.class).getSupportedMethods();
|
||||
assertThat(supportedMethods.getMethodsFor(COLLECTION)).doesNotContain(POST);
|
||||
|
||||
@@ -15,15 +15,16 @@
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.alps;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import net.minidev.json.JSONArray;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -48,8 +49,6 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
|
||||
import net.minidev.json.JSONArray;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link AlpsController}.
|
||||
*
|
||||
@@ -58,7 +57,7 @@ import net.minidev.json.JSONArray;
|
||||
*/
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration(classes = { JpaRepositoryConfig.class, AlpsControllerIntegrationTests.Config.class })
|
||||
public class AlpsControllerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
class AlpsControllerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
|
||||
@Autowired WebApplicationContext context;
|
||||
@Autowired LinkDiscoverers discoverers;
|
||||
@@ -81,20 +80,20 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
|
||||
TestMvcClient client;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
MockMvc mvc = MockMvcBuilders.webAppContextSetup(context).build();
|
||||
this.client = new TestMvcClient(mvc, this.discoverers);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
configuration.setEnableEnumTranslation(false);
|
||||
}
|
||||
|
||||
@Test // DATAREST-230
|
||||
public void exposesAlpsCollectionResources() throws Exception {
|
||||
void exposesAlpsCollectionResources() throws Exception {
|
||||
|
||||
Link profileLink = client.discoverUnique("profile");
|
||||
Link peopleLink = client.discoverUnique(profileLink, "people", MediaType.ALL);
|
||||
@@ -105,7 +104,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
}
|
||||
|
||||
@Test // DATAREST-638
|
||||
public void verifyThatAlpsIsDefaultProfileFormat() throws Exception {
|
||||
void verifyThatAlpsIsDefaultProfileFormat() throws Exception {
|
||||
|
||||
Link profileLink = client.discoverUnique("profile");
|
||||
Link peopleLink = client.discoverUnique(profileLink, "people", MediaType.ALL);
|
||||
@@ -117,7 +116,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
}
|
||||
|
||||
@Test // DATAREST-463
|
||||
public void verifyThatAttributesIgnoredDontAppearInAlps() throws Exception {
|
||||
void verifyThatAttributesIgnoredDontAppearInAlps() throws Exception {
|
||||
|
||||
Link profileLink = client.discoverUnique("profile");
|
||||
Link itemsLink = client.discoverUnique(profileLink, "items", MediaType.ALL);
|
||||
@@ -132,7 +131,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
}
|
||||
|
||||
@Test // DATAREST-494
|
||||
public void linksToJsonSchemaFromRepresentationDescriptor() throws Exception {
|
||||
void linksToJsonSchemaFromRepresentationDescriptor() throws Exception {
|
||||
|
||||
Link profileLink = client.discoverUnique("profile");
|
||||
Link itemsLink = client.discoverUnique(profileLink, "items", MediaType.ALL);
|
||||
@@ -143,11 +142,11 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
String href = JsonPath.<JSONArray> read(result, "$.alps.descriptor[?(@.id == 'item-representation')].href").get(0)
|
||||
.toString();
|
||||
|
||||
assertThat(href, endsWith("/profile/items"));
|
||||
assertThat(href).endsWith("/profile/items");
|
||||
}
|
||||
|
||||
@Test // DATAREST-516
|
||||
public void referenceToAssociatedEntityDesciptorPointsToRepresentationDescriptor() throws Exception {
|
||||
void referenceToAssociatedEntityDesciptorPointsToRepresentationDescriptor() throws Exception {
|
||||
|
||||
Link profileLink = client.discoverUnique("profile");
|
||||
Link usersLink = client.discoverUnique(profileLink, "people", MediaType.ALL);
|
||||
@@ -164,7 +163,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
}
|
||||
|
||||
@Test // DATAREST-630
|
||||
public void onlyExposesIdAttributesWhenExposedInTheConfiguration() throws Exception {
|
||||
void onlyExposesIdAttributesWhenExposedInTheConfiguration() throws Exception {
|
||||
|
||||
Link profileLink = client.discoverUnique("profile");
|
||||
Link itemsLink = client.discoverUnique(profileLink, "items", MediaType.ALL);
|
||||
@@ -175,7 +174,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
}
|
||||
|
||||
@Test // DATAREST-683
|
||||
public void enumValueListingsAreTranslatedIfEnabled() throws Exception {
|
||||
void enumValueListingsAreTranslatedIfEnabled() throws Exception {
|
||||
|
||||
configuration.setEnableEnumTranslation(true);
|
||||
|
||||
@@ -193,7 +192,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
}
|
||||
|
||||
@Test // DATAREST-753
|
||||
public void alpsCanHandleGroovyDomainObjects() throws Exception {
|
||||
void alpsCanHandleGroovyDomainObjects() throws Exception {
|
||||
|
||||
Link profileLink = client.discoverUnique("profile");
|
||||
Link groovyDomainObjectLink = client.discoverUnique(profileLink, "simulatedGroovyDomainClasses");
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.rest.tests.AbstractWebIntegrationTests;
|
||||
@@ -48,7 +48,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
* @soundtrack 2 Unlimited - No Limit
|
||||
*/
|
||||
@ContextConfiguration
|
||||
public class CorsIntegrationTests extends AbstractWebIntegrationTests {
|
||||
class CorsIntegrationTests extends AbstractWebIntegrationTests {
|
||||
|
||||
@Configuration
|
||||
static class CorsConfig extends JpaRepositoryConfig {
|
||||
@@ -81,7 +81,7 @@ public class CorsIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-573
|
||||
public void appliesSelectiveDefaultCorsConfiguration() throws Exception {
|
||||
void appliesSelectiveDefaultCorsConfiguration() throws Exception {
|
||||
|
||||
Link findItems = client.discoverUnique(LinkRelation.of("items"));
|
||||
|
||||
@@ -98,7 +98,7 @@ public class CorsIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-573
|
||||
public void appliesGlobalCorsConfiguration() throws Exception {
|
||||
void appliesGlobalCorsConfiguration() throws Exception {
|
||||
|
||||
Link findBooks = client.discoverUnique(LinkRelation.of("books"));
|
||||
|
||||
@@ -119,7 +119,7 @@ public class CorsIntegrationTests extends AbstractWebIntegrationTests {
|
||||
* @see BooksXmlController
|
||||
*/
|
||||
@Test // DATAREST-573
|
||||
public void appliesCorsConfigurationOnCustomControllers() throws Exception {
|
||||
void appliesCorsConfigurationOnCustomControllers() throws Exception {
|
||||
|
||||
// Preflight request
|
||||
mvc.perform(options("/books/xml/1234") //
|
||||
@@ -143,7 +143,7 @@ public class CorsIntegrationTests extends AbstractWebIntegrationTests {
|
||||
* @see BooksPdfController
|
||||
*/
|
||||
@Test // DATAREST-573
|
||||
public void appliesCorsConfigurationOnCustomControllerMethod() throws Exception {
|
||||
void appliesCorsConfigurationOnCustomControllerMethod() throws Exception {
|
||||
|
||||
// Preflight request
|
||||
mvc.perform(options("/books/pdf/1234").header(HttpHeaders.ORIGIN, "http://far.far.example")
|
||||
@@ -156,7 +156,7 @@ public class CorsIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-573
|
||||
public void appliesCorsConfigurationOnRepository() throws Exception {
|
||||
void appliesCorsConfigurationOnRepository() throws Exception {
|
||||
|
||||
Link authorsLink = client.discoverUnique(LinkRelation.of("authors"));
|
||||
|
||||
@@ -170,7 +170,7 @@ public class CorsIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-573
|
||||
public void appliesCorsConfigurationOnRepositoryToCustomControllers() throws Exception {
|
||||
void appliesCorsConfigurationOnRepositoryToCustomControllers() throws Exception {
|
||||
|
||||
// Preflight request
|
||||
mvc.perform(options("/authors/pdf/1234").header(HttpHeaders.ORIGIN, "http://not.so.far.example")
|
||||
|
||||
@@ -25,10 +25,9 @@ import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -46,7 +45,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
@@ -61,9 +60,9 @@ import com.jayway.jsonpath.JsonPath;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class DataRest262Tests {
|
||||
class DataRest262Tests {
|
||||
|
||||
@Configuration
|
||||
@Import({ RepositoryRestMvcConfiguration.class, JpaInfrastructureConfig.class })
|
||||
@@ -78,8 +77,8 @@ public class DataRest262Tests {
|
||||
|
||||
ObjectMapper mapper;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
this.mapper = beanFactory //
|
||||
.getBean("halJacksonHttpMessageConverter", AbstractJackson2HttpMessageConverter.class) //
|
||||
@@ -90,7 +89,7 @@ public class DataRest262Tests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-262
|
||||
public void deserializesNestedAssociation() throws Exception {
|
||||
void deserializesNestedAssociation() throws Exception {
|
||||
|
||||
Airport airport = repository.save(new Airport());
|
||||
String payload = "{\"orgOrDstFlightPart\":{\"airport\":\"/api/airports/" + airport.id + "\"}}";
|
||||
@@ -100,7 +99,7 @@ public class DataRest262Tests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-262
|
||||
public void serializesLinksToNestedAssociations() throws Exception {
|
||||
void serializesLinksToNestedAssociations() throws Exception {
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addHeader(HttpHeaders.ACCEPT, MediaTypes.HAL_JSON_VALUE);
|
||||
|
||||
@@ -19,10 +19,9 @@ import static org.hamcrest.Matchers.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -34,7 +33,7 @@ import org.springframework.hateoas.client.LinkDiscoverer;
|
||||
import org.springframework.hateoas.client.LinkDiscoverers;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
@@ -47,11 +46,11 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
* @author Greg Turnquist
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration(
|
||||
classes = { JpaRepositoryConfig.class, RepositoryRestMvcConfiguration.class, DataRest363Tests.Config.class })
|
||||
public class DataRest363Tests {
|
||||
class DataRest363Tests {
|
||||
|
||||
private static MediaType MEDIA_TYPE = MediaType.APPLICATION_JSON;
|
||||
|
||||
@@ -78,8 +77,8 @@ public class DataRest363Tests {
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
MockMvc mvc = MockMvcBuilders.webAppContextSetup(context).//
|
||||
defaultRequest(get("/")).build();
|
||||
@@ -89,7 +88,7 @@ public class DataRest363Tests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-363
|
||||
public void testBasics() throws Exception {
|
||||
void testBasics() throws Exception {
|
||||
|
||||
ResultActions frodoActions = testMvcClient.follow("/people/".concat(frodo.getId().toString()));
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -50,7 +50,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@ContextConfiguration
|
||||
public class JpaDefaultPageableWebTests extends AbstractWebIntegrationTests {
|
||||
class JpaDefaultPageableWebTests extends AbstractWebIntegrationTests {
|
||||
|
||||
@Configuration
|
||||
@Import({ RepositoryRestMvcConfiguration.class, JpaRepositoryConfig.class })
|
||||
@@ -87,14 +87,14 @@ public class JpaDefaultPageableWebTests extends AbstractWebIntegrationTests {
|
||||
@Autowired ApplicationContext context;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
loader.populateRepositories();
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test // DATAREST-906
|
||||
public void executesSearchThatTakesAMappedSortProperty() throws Exception {
|
||||
void executesSearchThatTakesAMappedSortProperty() throws Exception {
|
||||
|
||||
Link findBySortedLink = client.discoverUnique(LinkRelation.of("books"), IanaLinkRelations.SEARCH,
|
||||
LinkRelation.of("find-spring-books-sorted"));
|
||||
@@ -114,7 +114,7 @@ public class JpaDefaultPageableWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-906
|
||||
public void shouldApplyDefaultPageable() throws Exception {
|
||||
void shouldApplyDefaultPageable() throws Exception {
|
||||
|
||||
mvc.perform(get("/books/default-pageable"))//
|
||||
.andExpect(jsonPath("$.content[0].sales").value(0)) //
|
||||
@@ -122,7 +122,7 @@ public class JpaDefaultPageableWebTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-906
|
||||
public void shouldOverrideDefaultPageable() throws Exception {
|
||||
void shouldOverrideDefaultPageable() throws Exception {
|
||||
|
||||
mvc.perform(get("/books/default-pageable?size=10"))//
|
||||
.andExpect(jsonPath("$.content[0].sales").value(0)) //
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Configuration
|
||||
public class JpaInfrastructureConfig {
|
||||
class JpaInfrastructureConfig {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.springframework.data.rest.webmvc.util.TestUtils.*;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
|
||||
import static org.springframework.http.HttpHeaders.*;
|
||||
@@ -33,8 +32,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
@@ -123,7 +122,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
* @see org.springframework.data.rest.webmvc.AbstractWebIntegrationTests#setUp()
|
||||
*/
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
loader.populateRepositories();
|
||||
super.setUp();
|
||||
@@ -162,7 +161,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-99
|
||||
public void doesNotExposeCreditCardRepository() throws Exception {
|
||||
void doesNotExposeCreditCardRepository() throws Exception {
|
||||
|
||||
mvc.perform(get("/")). //
|
||||
andExpect(status().isOk()). //
|
||||
@@ -170,7 +169,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessPersons() throws Exception {
|
||||
void accessPersons() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = client.request("/people?page=0&size=1");
|
||||
|
||||
@@ -187,7 +186,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-169
|
||||
public void exposesLinkForRelatedResource() throws Exception {
|
||||
void exposesLinkForRelatedResource() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = client.request("/");
|
||||
Link ordersLink = client.assertHasLinkWithRel(LinkRelation.of("orders"), response);
|
||||
@@ -199,7 +198,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-200
|
||||
public void exposesInlinedEntities() throws Exception {
|
||||
void exposesInlinedEntities() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = client.request("/");
|
||||
Link ordersLink = client.assertHasLinkWithRel(LinkRelation.of("orders"), response);
|
||||
@@ -209,7 +208,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-199
|
||||
public void createsOrderUsingPut() throws Exception {
|
||||
void createsOrderUsingPut() throws Exception {
|
||||
|
||||
mvc.perform(//
|
||||
put("/orders/{id}", 4711).//
|
||||
@@ -218,7 +217,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-117
|
||||
public void createPersonThenVerifyIgnoredAttributesDontExist() throws Exception {
|
||||
void createPersonThenVerifyIgnoredAttributesDontExist() throws Exception {
|
||||
|
||||
Link peopleLink = client.discoverUnique(LinkRelation.of("people"));
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@@ -238,7 +237,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-95
|
||||
public void createThenPatch() throws Exception {
|
||||
void createThenPatch() throws Exception {
|
||||
|
||||
Link peopleLink = client.discoverUnique(LinkRelation.of("people"));
|
||||
|
||||
@@ -262,7 +261,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-150
|
||||
public void createThenPut() throws Exception {
|
||||
void createThenPut() throws Exception {
|
||||
|
||||
Link peopleLink = client.discoverUnique(LinkRelation.of("people"));
|
||||
|
||||
@@ -272,29 +271,29 @@ public class JpaWebTests extends CommonWebTests {
|
||||
|
||||
Link bilboLink = client.assertHasLinkWithRel(IanaLinkRelations.SELF, bilbo);
|
||||
|
||||
assertThat((String) JsonPath.read(bilbo.getContentAsString(), "$.firstName"), equalTo("Bilbo"));
|
||||
assertThat((String) JsonPath.read(bilbo.getContentAsString(), "$.lastName"), equalTo("Baggins"));
|
||||
assertThat((String) JsonPath.read(bilbo.getContentAsString(), "$.firstName")).isEqualTo("Bilbo");
|
||||
assertThat((String) JsonPath.read(bilbo.getContentAsString(), "$.lastName")).isEqualTo("Baggins");
|
||||
|
||||
MockHttpServletResponse frodo = putAndGet(bilboLink, //
|
||||
"{ \"firstName\" : \"Frodo\" }", //
|
||||
MediaType.APPLICATION_JSON);
|
||||
|
||||
assertThat((String) JsonPath.read(frodo.getContentAsString(), "$.firstName"), equalTo("Frodo"));
|
||||
assertNull(JsonPath.read(frodo.getContentAsString(), "$.lastName"));
|
||||
assertThat((String) JsonPath.read(frodo.getContentAsString(), "$.firstName")).isEqualTo("Frodo");
|
||||
assertThat(JsonPath.<Object> read(frodo.getContentAsString(), "$.lastName")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listsSiblingsWithContentCorrectly() throws Exception {
|
||||
void listsSiblingsWithContentCorrectly() throws Exception {
|
||||
assertPersonWithNameAndSiblingLink("John");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listsEmptySiblingsCorrectly() throws Exception {
|
||||
void listsEmptySiblingsCorrectly() throws Exception {
|
||||
assertPersonWithNameAndSiblingLink("Billy Bob");
|
||||
}
|
||||
|
||||
@Test // DATAREST-219
|
||||
public void manipulatePropertyCollectionRestfullyWithMultiplePosts() throws Exception {
|
||||
void manipulatePropertyCollectionRestfullyWithMultiplePosts() throws Exception {
|
||||
|
||||
List<Link> links = preparePersonResources(new Person("Frodo", "Baggins"), //
|
||||
new Person("Bilbo", "Baggins"), //
|
||||
@@ -311,7 +310,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-219
|
||||
public void manipulatePropertyCollectionRestfullyWithSinglePost() throws Exception {
|
||||
void manipulatePropertyCollectionRestfullyWithSinglePost() throws Exception {
|
||||
|
||||
List<Link> links = preparePersonResources(new Person("Frodo", "Baggins"), //
|
||||
new Person("Bilbo", "Baggins"), //
|
||||
@@ -326,7 +325,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-219
|
||||
public void manipulatePropertyCollectionRestfullyWithMultiplePuts() throws Exception {
|
||||
void manipulatePropertyCollectionRestfullyWithMultiplePuts() throws Exception {
|
||||
|
||||
List<Link> links = preparePersonResources(new Person("Frodo", "Baggins"), //
|
||||
new Person("Bilbo", "Baggins"), //
|
||||
@@ -345,7 +344,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-219
|
||||
public void manipulatePropertyCollectionRestfullyWithSinglePut() throws Exception {
|
||||
void manipulatePropertyCollectionRestfullyWithSinglePut() throws Exception {
|
||||
|
||||
List<Link> links = preparePersonResources(new Person("Frodo", "Baggins"), //
|
||||
new Person("Bilbo", "Baggins"), //
|
||||
@@ -369,7 +368,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
* checks for its first name. Than it sets Pippin Baggins as creator of the Order. Check for first name is done again.
|
||||
*/
|
||||
@Test // DATAREST-1356
|
||||
public void associateCreatorToOrderWithSinglePut() throws Exception {
|
||||
void associateCreatorToOrderWithSinglePut() throws Exception {
|
||||
|
||||
Link firstCreatorLink = preparePersonResource(new Person("Frodo", "Baggins"));
|
||||
Link secondCreatorLink = preparePersonResource(new Person("Pippin", "Baggins"));
|
||||
@@ -387,7 +386,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
* will contain "send only 1 link" substring.
|
||||
*/
|
||||
@Test // DATAREST-1356
|
||||
public void associateTwoCreatorsToOrderWithSinglePut() throws Exception {
|
||||
void associateTwoCreatorsToOrderWithSinglePut() throws Exception {
|
||||
|
||||
Link firstCreatorLink = preparePersonResource(new Person("Frodo", "Baggins"));
|
||||
Link secondCreatorLink = preparePersonResource(new Person("Pippin", "Baggins"));
|
||||
@@ -399,7 +398,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-219
|
||||
public void manipulatePropertyCollectionRestfullyWithDelete() throws Exception {
|
||||
void manipulatePropertyCollectionRestfullyWithDelete() throws Exception {
|
||||
|
||||
List<Link> links = preparePersonResources(new Person("Frodo", "Baggins"), //
|
||||
new Person("Bilbo", "Baggins"), //
|
||||
@@ -419,7 +418,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-50
|
||||
public void propertiesCanHaveNulls() throws Exception {
|
||||
void propertiesCanHaveNulls() throws Exception {
|
||||
|
||||
Link peopleLink = client.discoverUnique(LinkRelation.of("people"));
|
||||
|
||||
@@ -436,7 +435,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-238
|
||||
public void putShouldWorkDespiteExistingLinks() throws Exception {
|
||||
void putShouldWorkDespiteExistingLinks() throws Exception {
|
||||
|
||||
Link peopleLink = client.discoverUnique(LinkRelation.of("people"));
|
||||
|
||||
@@ -458,7 +457,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-217
|
||||
public void doesNotAllowGetToCollectionResourceIfFindAllIsNotExported() throws Exception {
|
||||
void doesNotAllowGetToCollectionResourceIfFindAllIsNotExported() throws Exception {
|
||||
|
||||
Link link = client.discoverUnique(LinkRelation.of("addresses"));
|
||||
|
||||
@@ -467,7 +466,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-217
|
||||
public void doesNotAllowPostToCollectionResourceIfSaveIsNotExported() throws Exception {
|
||||
void doesNotAllowPostToCollectionResourceIfSaveIsNotExported() throws Exception {
|
||||
|
||||
Link link = client.discoverUnique(LinkRelation.of("addresses"));
|
||||
|
||||
@@ -481,7 +480,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
* @see OrderSummary
|
||||
*/
|
||||
@Test // DATAREST-221
|
||||
public void returnsProjectionIfRequested() throws Exception {
|
||||
void returnsProjectionIfRequested() throws Exception {
|
||||
|
||||
Link orders = client.discoverUnique(LinkRelation.of("orders"));
|
||||
|
||||
@@ -500,12 +499,12 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-261
|
||||
public void relProviderDetectsCustomizedMapping() {
|
||||
void relProviderDetectsCustomizedMapping() {
|
||||
assertThat(relProvider.getCollectionResourceRelFor(Person.class)).isEqualTo(LinkRelation.of("people"));
|
||||
}
|
||||
|
||||
@Test // DATAREST-311
|
||||
public void onlyLinksShouldAppearWhenExecuteSearchCompact() throws Exception {
|
||||
void onlyLinksShouldAppearWhenExecuteSearchCompact() throws Exception {
|
||||
|
||||
Link peopleLink = client.discoverUnique(LinkRelation.of("people"));
|
||||
Person daenerys = new Person("Daenerys", "Targaryen");
|
||||
@@ -531,7 +530,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-317
|
||||
public void rendersExcerptProjectionsCorrectly() throws Exception {
|
||||
void rendersExcerptProjectionsCorrectly() throws Exception {
|
||||
|
||||
Link authorsLink = client.discoverUnique("authors");
|
||||
|
||||
@@ -554,7 +553,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-353
|
||||
public void returns404WhenTryingToDeleteANonExistingResource() throws Exception {
|
||||
void returns404WhenTryingToDeleteANonExistingResource() throws Exception {
|
||||
|
||||
Link receiptsLink = client.discoverUnique("receipts");
|
||||
|
||||
@@ -563,7 +562,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-384
|
||||
public void exectuesSearchThatTakesASort() throws Exception {
|
||||
void exectuesSearchThatTakesASort() throws Exception {
|
||||
|
||||
Link booksLink = client.discoverUnique("books");
|
||||
Link searchLink = client.discoverUnique(booksLink, "search");
|
||||
@@ -586,7 +585,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-160
|
||||
public void returnConflictWhenConcurrentlyEditingVersionedEntity() throws Exception {
|
||||
void returnConflictWhenConcurrentlyEditingVersionedEntity() throws Exception {
|
||||
|
||||
Link receiptLink = client.discoverUnique("receipts");
|
||||
|
||||
@@ -613,7 +612,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-423
|
||||
public void invokesCustomControllerAndBindsDomainObjectCorrectly() throws Exception {
|
||||
void invokesCustomControllerAndBindsDomainObjectCorrectly() throws Exception {
|
||||
|
||||
MockHttpServletResponse authorsResponse = client.request(client.discoverUnique("authors"));
|
||||
|
||||
@@ -624,7 +623,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-523
|
||||
public void augmentsCollectionAssociationUsingPost() throws Exception {
|
||||
void augmentsCollectionAssociationUsingPost() throws Exception {
|
||||
|
||||
List<Link> links = preparePersonResources(new Person("Frodo", "Baggins"), //
|
||||
new Person("Bilbo", "Baggins"));
|
||||
@@ -645,7 +644,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-658
|
||||
public void returnsLinkHeadersForHeadRequestToItemResource() throws Exception {
|
||||
void returnsLinkHeadersForHeadRequestToItemResource() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = client.request(client.discoverUnique(LinkRelation.of("people")));
|
||||
String personHref = JsonPath.read(response.getContentAsString(), "$._embedded.people[0]._links.self.href");
|
||||
@@ -660,7 +659,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-883
|
||||
public void exectuesSearchThatTakesAMappedSortProperty() throws Exception {
|
||||
void exectuesSearchThatTakesAMappedSortProperty() throws Exception {
|
||||
|
||||
Link findBySortedLink = client.discoverUnique("books", "search", "find-by-sorted");
|
||||
|
||||
@@ -681,7 +680,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-883
|
||||
public void exectuesCustomQuerySearchThatTakesAMappedSortProperty() throws Exception {
|
||||
void exectuesCustomQuerySearchThatTakesAMappedSortProperty() throws Exception {
|
||||
|
||||
Link findByLink = client.discoverUnique("books", "search", "find-spring-books-sorted");
|
||||
|
||||
@@ -701,14 +700,14 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-910
|
||||
public void callUnmappedCustomRepositoryController() throws Exception {
|
||||
void callUnmappedCustomRepositoryController() throws Exception {
|
||||
|
||||
mvc.perform(post("/orders/search/sort")).andExpect(status().isOk());
|
||||
mvc.perform(post("/orders/search/sort?sort=type&page=1&size=10")).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test // DATAREST-976
|
||||
public void appliesSortByEmbeddedAssociation() throws Exception {
|
||||
void appliesSortByEmbeddedAssociation() throws Exception {
|
||||
|
||||
Link booksLink = client.discoverUnique("books");
|
||||
Link searchLink = client.discoverUnique(booksLink, "search");
|
||||
@@ -731,7 +730,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-1213
|
||||
public void createThenPatchWithProjection() throws Exception {
|
||||
void createThenPatchWithProjection() throws Exception {
|
||||
|
||||
Link link = createCategory();
|
||||
String payload = "{ \"name\" : \"patched\" }";
|
||||
@@ -744,7 +743,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-1213
|
||||
public void createThenPutWithProjection() throws Exception {
|
||||
void createThenPutWithProjection() throws Exception {
|
||||
|
||||
Link link = createCategory();
|
||||
String payload = "{ \"name\" : \"put\" }";
|
||||
@@ -757,7 +756,7 @@ public class JpaWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // #1991
|
||||
public void answersToHalFormsRequests() throws Exception {
|
||||
void answersToHalFormsRequests() throws Exception {
|
||||
|
||||
mvc.perform(get("/")
|
||||
.accept(MediaTypes.HAL_FORMS_JSON))
|
||||
|
||||
@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.rest.tests.AbstractWebIntegrationTests;
|
||||
import org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping;
|
||||
@@ -37,7 +37,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
* @soundtrack RFLKTD - Liquid Crystals
|
||||
*/
|
||||
@ContextConfiguration
|
||||
public class LocalConfigCorsIntegrationTests extends AbstractWebIntegrationTests {
|
||||
class LocalConfigCorsIntegrationTests extends AbstractWebIntegrationTests {
|
||||
|
||||
static class CorsConfig extends JpaRepositoryConfig {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class LocalConfigCorsIntegrationTests extends AbstractWebIntegrationTests
|
||||
* @see ItemRepository
|
||||
*/
|
||||
@Test // DATAREST-1397
|
||||
public void appliesRepositoryCorsConfiguration() throws Exception {
|
||||
void appliesRepositoryCorsConfiguration() throws Exception {
|
||||
|
||||
Link findItems = client.discoverUnique(LinkRelation.of("items"));
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -49,7 +49,7 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
*/
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration(classes = { JpaRepositoryConfig.class, ProfileIntegrationTests.Config.class })
|
||||
public class ProfileIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
class ProfileIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
|
||||
@Autowired WebApplicationContext context;
|
||||
@Autowired LinkDiscoverers discoverers;
|
||||
@@ -67,15 +67,15 @@ public class ProfileIntegrationTests extends AbstractControllerIntegrationTests
|
||||
|
||||
TestMvcClient client;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
MockMvc mvc = MockMvcBuilders.webAppContextSetup(context).build();
|
||||
this.client = new TestMvcClient(mvc, this.discoverers);
|
||||
}
|
||||
|
||||
@Test // DATAREST-230, DATAREST-638
|
||||
public void exposesProfileLink() throws Exception {
|
||||
void exposesProfileLink() throws Exception {
|
||||
|
||||
client.follow(ROOT_URI)//
|
||||
.andExpect(status().is2xxSuccessful())//
|
||||
@@ -83,7 +83,7 @@ public class ProfileIntegrationTests extends AbstractControllerIntegrationTests
|
||||
}
|
||||
|
||||
@Test // DATAREST-230, DATAREST-638
|
||||
public void profileRootLinkContainsMetadataForEachRepo() throws Exception {
|
||||
void profileRootLinkContainsMetadataForEachRepo() throws Exception {
|
||||
|
||||
Link profileLink = client.discoverUnique(Link.of(ROOT_URI), ProfileResourceProcessor.PROFILE_REL);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ProfileIntegrationTests extends AbstractControllerIntegrationTests
|
||||
}
|
||||
|
||||
@Test // DATAREST-638
|
||||
public void profileLinkOnCollectionResourceLeadsToRepositorySpecificMetadata() throws Exception {
|
||||
void profileLinkOnCollectionResourceLeadsToRepositorySpecificMetadata() throws Exception {
|
||||
|
||||
Link peopleLink = client.discoverUnique(Link.of(ROOT_URI), "people");
|
||||
Link profileLink = client.discoverUnique(peopleLink, ProfileResourceProcessor.PROFILE_REL);
|
||||
|
||||
@@ -29,7 +29,7 @@ import javax.persistence.Id;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Entity
|
||||
public class SimulatedGroovyDomainClass implements GroovyObject {
|
||||
class SimulatedGroovyDomainClass implements GroovyObject {
|
||||
|
||||
private @Id @GeneratedValue Long id;
|
||||
private String name;
|
||||
@@ -38,7 +38,7 @@ public class SimulatedGroovyDomainClass implements GroovyObject {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class SimulatedGroovyDomainClass implements GroovyObject {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.rest.webmvc.jpa.groovy;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.rest.webmvc.jpa.groovy.SimulatedGroovyDomainClass;
|
||||
|
||||
/**
|
||||
* Simulates a repository built on a Groovy domain object.
|
||||
|
||||
@@ -19,9 +19,9 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
@@ -36,7 +36,7 @@ import org.springframework.data.rest.webmvc.jpa.Person;
|
||||
import org.springframework.data.rest.webmvc.jpa.PersonRepository;
|
||||
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -46,10 +46,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = { JpaRepositoryConfig.class, RepositoryRestMvcConfiguration.class })
|
||||
@Transactional
|
||||
public class Jackson2DatatypeHelperIntegrationTests {
|
||||
class Jackson2DatatypeHelperIntegrationTests {
|
||||
|
||||
@Autowired PersistentEntities entities;
|
||||
@Autowired ApplicationContext context;
|
||||
@@ -62,8 +62,8 @@ public class Jackson2DatatypeHelperIntegrationTests {
|
||||
|
||||
Order order;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
this.order = orders.save(new Order(people.save(new Person("Dave", "Matthews"))));
|
||||
this.objectMapper = context.getBean("halJacksonHttpMessageConverter", AbstractJackson2HttpMessageConverter.class)
|
||||
@@ -75,7 +75,7 @@ public class Jackson2DatatypeHelperIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-500
|
||||
public void configuresHibernate4ModuleToLoadLazyLoadingProxies() throws Exception {
|
||||
void configuresHibernate4ModuleToLoadLazyLoadingProxies() throws Exception {
|
||||
|
||||
PersistentEntity<?, ?> entity = entities.getRequiredPersistentEntity(Order.class);
|
||||
PersistentProperty<?> property = entity.getRequiredPersistentProperty("creator");
|
||||
|
||||
@@ -22,9 +22,9 @@ import java.io.StringWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -48,7 +48,7 @@ import org.springframework.hateoas.server.core.EmbeddedWrapper;
|
||||
import org.springframework.hateoas.server.core.EmbeddedWrappers;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
@@ -65,10 +65,10 @@ import com.jayway.jsonpath.JsonPath;
|
||||
* @author Oliver Gierke
|
||||
* @author Alex Leigh
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = { JpaRepositoryConfig.class, PersistentEntitySerializationTests.TestConfig.class })
|
||||
@Transactional
|
||||
public class PersistentEntitySerializationTests {
|
||||
class PersistentEntitySerializationTests {
|
||||
|
||||
private static final String PERSON_JSON_IN = "{\"firstName\": \"John\",\"lastName\": \"Doe\"}";
|
||||
|
||||
@@ -94,8 +94,8 @@ public class PersistentEntitySerializationTests {
|
||||
LinkDiscoverer discoverer;
|
||||
ProjectionFactory projectionFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
RequestContextHolder.setRequestAttributes(new ServletWebRequest(new MockHttpServletRequest()));
|
||||
|
||||
@@ -104,7 +104,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deserializesPersonEntity() throws IOException {
|
||||
void deserializesPersonEntity() throws IOException {
|
||||
|
||||
Person p = mapper.readValue(PERSON_JSON_IN, Person.class);
|
||||
|
||||
@@ -114,7 +114,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-238
|
||||
public void deserializePersonWithLinks() throws IOException {
|
||||
void deserializePersonWithLinks() throws IOException {
|
||||
|
||||
String bilbo = "{\n" + " \"_links\" : {\n" + " \"self\" : {\n"
|
||||
+ " \"href\" : \"http://localhost/people/4\"\n" + " },\n" + " \"siblings\" : {\n"
|
||||
@@ -129,7 +129,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-238
|
||||
public void serializesPersonEntity() throws IOException, InterruptedException {
|
||||
void serializesPersonEntity() throws IOException, InterruptedException {
|
||||
|
||||
PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(Person.class);
|
||||
Person person = people.save(new Person("John", "Doe"));
|
||||
@@ -154,7 +154,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-248
|
||||
public void deserializesPersonWithLinkToOtherPersonCorrectly() throws Exception {
|
||||
void deserializesPersonWithLinkToOtherPersonCorrectly() throws Exception {
|
||||
|
||||
Person father = people.save(new Person("John", "Doe"));
|
||||
|
||||
@@ -165,7 +165,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-248
|
||||
public void deserializesPersonWithLinkToOtherPersonsCorrectly() throws Exception {
|
||||
void deserializesPersonWithLinkToOtherPersonsCorrectly() throws Exception {
|
||||
|
||||
Person firstSibling = people.save(new Person("John", "Doe"));
|
||||
Person secondSibling = people.save(new Person("Dave", "Doe"));
|
||||
@@ -178,7 +178,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-248
|
||||
public void deserializesEmbeddedAssociationsCorrectly() throws Exception {
|
||||
void deserializesEmbeddedAssociationsCorrectly() throws Exception {
|
||||
|
||||
String content = TestUtils.readFileFromClasspath("order.json");
|
||||
|
||||
@@ -187,7 +187,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-250
|
||||
public void serializesReferencesWithinPagedResourceCorrectly() throws Exception {
|
||||
void serializesReferencesWithinPagedResourceCorrectly() throws Exception {
|
||||
|
||||
Person creator = new Person("Dave", "Matthews");
|
||||
|
||||
@@ -209,7 +209,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-521
|
||||
public void serializesLinksForExcerpts() throws Exception {
|
||||
void serializesLinksForExcerpts() throws Exception {
|
||||
|
||||
Person dave = new Person("Dave", "Matthews");
|
||||
dave.setId(1L);
|
||||
@@ -232,7 +232,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-521
|
||||
public void rendersAdditionalLinksRegisteredWithResource() throws Exception {
|
||||
void rendersAdditionalLinksRegisteredWithResource() throws Exception {
|
||||
|
||||
Person dave = new Person("Dave", "Matthews");
|
||||
|
||||
@@ -248,7 +248,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-697
|
||||
public void rendersProjectionWithinSimpleResourceCorrectly() throws Exception {
|
||||
void rendersProjectionWithinSimpleResourceCorrectly() throws Exception {
|
||||
|
||||
Person person = new Person("Dave", "Matthews");
|
||||
person.setId(1L);
|
||||
@@ -262,7 +262,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-880
|
||||
public void unwrapsNestedTypeCorrectly() throws Exception {
|
||||
void unwrapsNestedTypeCorrectly() throws Exception {
|
||||
|
||||
CreditCard creditCard = new CreditCard(new CreditCard.CCN("1234123412341234"));
|
||||
|
||||
@@ -270,7 +270,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-872
|
||||
public void serializesInheritance() throws Exception {
|
||||
void serializesInheritance() throws Exception {
|
||||
|
||||
Suite suite = new Suite();
|
||||
suite.setSuiteCode("Suite 42");
|
||||
|
||||
@@ -72,7 +72,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
*/
|
||||
@Configuration
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RepositoryTestsConfig {
|
||||
class RepositoryTestsConfig {
|
||||
|
||||
@Autowired ApplicationContext appCtx;
|
||||
@Autowired(required = false) List<MappingContext<?, ?>> mappingContexts = Collections.emptyList();
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.data.rest.tests.AbstractControllerIntegrationTests;
|
||||
@@ -38,13 +38,13 @@ import org.springframework.web.context.request.ServletWebRequest;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@ContextConfiguration(classes = JpaRepositoryConfig.class)
|
||||
public class BackendIdConverterHandlerMethodArgumentResolverIntegrationTests
|
||||
class BackendIdConverterHandlerMethodArgumentResolverIntegrationTests
|
||||
extends AbstractControllerIntegrationTests {
|
||||
|
||||
@Autowired BackendIdHandlerMethodArgumentResolver resolver;
|
||||
|
||||
@Test // DATAREST-155
|
||||
public void translatesUriToBackendId() throws Exception {
|
||||
void translatesUriToBackendId() throws Exception {
|
||||
|
||||
Method method = ReflectionUtils.findMethod(SampleController.class, "resolveId", Serializable.class);
|
||||
MethodParameter parameter = new MethodParameter(method, 0);
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.rest.webmvc.support;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.Ordered;
|
||||
@@ -41,7 +41,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@ContextConfiguration
|
||||
public class ExceptionHandlingCustomizationIntegrationTests extends AbstractWebIntegrationTests {
|
||||
class ExceptionHandlingCustomizationIntegrationTests extends AbstractWebIntegrationTests {
|
||||
|
||||
@Configuration
|
||||
@Import(JpaRepositoryConfig.class)
|
||||
@@ -63,7 +63,7 @@ public class ExceptionHandlingCustomizationIntegrationTests extends AbstractWebI
|
||||
}
|
||||
|
||||
@Test
|
||||
public void httpRequestMethodNotSupportedExceptionShouldNowReturnHttpStatus500Over405() throws Exception {
|
||||
void httpRequestMethodNotSupportedExceptionShouldNowReturnHttpStatus500Over405() throws Exception {
|
||||
|
||||
Link link = client.discoverUnique("addresses");
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.rest.webmvc.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -40,13 +40,13 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@ContextConfiguration(classes = JpaRepositoryConfig.class)
|
||||
public class RepositoryEntityLinksIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
class RepositoryEntityLinksIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
|
||||
@Autowired RepositoryRestConfiguration configuration;
|
||||
@Autowired RepositoryEntityLinks entityLinks;
|
||||
|
||||
@Test
|
||||
public void returnsLinkToSingleResource() {
|
||||
void returnsLinkToSingleResource() {
|
||||
|
||||
Link link = entityLinks.linkToItemResource(Person.class, 1);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsTemplatedLinkForPagingResource() {
|
||||
void returnsTemplatedLinkForPagingResource() {
|
||||
|
||||
Link link = entityLinks.linkToCollectionResource(Person.class);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void returnsLinkWithProjectionTemplateVariableIfProjectionIsDefined() {
|
||||
void returnsLinkWithProjectionTemplateVariableIfProjectionIsDefined() {
|
||||
|
||||
Link link = entityLinks.linkToItemResource(Order.class, 1);
|
||||
|
||||
@@ -74,14 +74,14 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
|
||||
}
|
||||
|
||||
@Test // DATAREST-155
|
||||
public void usesCustomGeneratedBackendId() {
|
||||
void usesCustomGeneratedBackendId() {
|
||||
|
||||
Link link = entityLinks.linkToItemResource(Book.class, 7L);
|
||||
assertThat(link.expand().getHref()).endsWith("/7-7-7-7-7-7-7");
|
||||
}
|
||||
|
||||
@Test // DATAREST-317
|
||||
public void adaptsToExistingPageable() {
|
||||
void adaptsToExistingPageable() {
|
||||
|
||||
Link link = entityLinks.linkToPagedResource(Person.class, PageRequest.of(0, 10));
|
||||
|
||||
@@ -91,7 +91,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
|
||||
}
|
||||
|
||||
@Test // DATAREST-467
|
||||
public void returnsLinksToSearchResources() {
|
||||
void returnsLinksToSearchResources() {
|
||||
|
||||
Links links = entityLinks.linksToSearchResources(Person.class);
|
||||
|
||||
@@ -103,7 +103,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
|
||||
}
|
||||
|
||||
@Test // DATAREST-467
|
||||
public void returnsLinkToSearchResource() {
|
||||
void returnsLinkToSearchResource() {
|
||||
|
||||
Link link = entityLinks.linkToSearchResource(Person.class, LinkRelation.of("firstname"));
|
||||
|
||||
@@ -113,7 +113,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
|
||||
}
|
||||
|
||||
@Test // DATAREST-467, DATAREST-519
|
||||
public void prepopulatesPaginationInformationForSearchResourceLink() {
|
||||
void prepopulatesPaginationInformationForSearchResourceLink() {
|
||||
|
||||
Link link = entityLinks.linkToSearchResource(Person.class, LinkRelation.of("firstname"), PageRequest.of(0, 10));
|
||||
|
||||
@@ -127,7 +127,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
|
||||
}
|
||||
|
||||
@Test // DATAREST-467
|
||||
public void returnsTemplatedLinkForSortedSearchResource() {
|
||||
void returnsTemplatedLinkForSortedSearchResource() {
|
||||
|
||||
Link link = entityLinks.linkToSearchResource(Person.class, LinkRelation.of("lastname"));
|
||||
|
||||
@@ -136,7 +136,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
|
||||
}
|
||||
|
||||
@Test // DATAREST-467, DATAREST-519
|
||||
public void prepopulatesSortInformationForSearchResourceLink() {
|
||||
void prepopulatesSortInformationForSearchResourceLink() {
|
||||
|
||||
Link link = entityLinks.linkToSearchResource(Person.class, LinkRelation.of("lastname"), Sort.by("firstname"));
|
||||
|
||||
@@ -150,7 +150,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
|
||||
}
|
||||
|
||||
@Test // DATAREST-668, DATAREST-519, DATAREST-467
|
||||
public void addsProjectVariableToSearchResourceIfAvailable() {
|
||||
void addsProjectVariableToSearchResourceIfAvailable() {
|
||||
|
||||
for (Link link : entityLinks.linksToSearchResources(Book.class)) {
|
||||
assertThat(link.getVariableNames()).contains("projection");
|
||||
@@ -158,7 +158,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
|
||||
}
|
||||
|
||||
@Test // #1980
|
||||
public void considersIdConverterInLinkForItemResource() {
|
||||
void considersIdConverterInLinkForItemResource() {
|
||||
|
||||
Link link = entityLinks.linkForItemResource(Book.class, 7L).withSelfRel();
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.rest.tests.CommonWebTests;
|
||||
import org.springframework.data.rest.tests.TestMatchers;
|
||||
@@ -62,7 +62,7 @@ import com.jayway.jsonpath.JsonPath;
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
@ContextConfiguration(classes = MongoDbRepositoryConfig.class)
|
||||
public class MongoWebTests extends CommonWebTests {
|
||||
class MongoWebTests extends CommonWebTests {
|
||||
|
||||
private static final MediaType TEXT_URI_LIST = MediaType.parseMediaType("text/uri-list");
|
||||
|
||||
@@ -72,8 +72,8 @@ public class MongoWebTests extends CommonWebTests {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Before
|
||||
public void populateProfiles() {
|
||||
@BeforeEach
|
||||
void populateProfiles() {
|
||||
|
||||
mapper.setSerializationInclusion(Include.NON_NULL);
|
||||
|
||||
@@ -122,8 +122,8 @@ public class MongoWebTests extends CommonWebTests {
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
@AfterEach
|
||||
void cleanUp() {
|
||||
repository.deleteAll();
|
||||
userRepository.deleteAll();
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void foo() throws Exception {
|
||||
void foo() throws Exception {
|
||||
|
||||
Link profileLink = client.discoverUnique("profiles");
|
||||
client.follow(profileLink).//
|
||||
@@ -146,7 +146,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rendersEmbeddedDocuments() throws Exception {
|
||||
void rendersEmbeddedDocuments() throws Exception {
|
||||
|
||||
Link usersLink = client.discoverUnique("users");
|
||||
Link userLink = assertHasContentLinkWithRel(IanaLinkRelations.SELF, client.request(usersLink));
|
||||
@@ -155,7 +155,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-247
|
||||
public void executeQueryMethodWithPrimitiveReturnType() throws Exception {
|
||||
void executeQueryMethodWithPrimitiveReturnType() throws Exception {
|
||||
|
||||
Link profiles = client.discoverUnique("profiles");
|
||||
Link profileSearches = client.discoverUnique(profiles, "search");
|
||||
@@ -169,7 +169,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testname() throws Exception {
|
||||
void testname() throws Exception {
|
||||
|
||||
Link usersLink = client.discoverUnique("users");
|
||||
Link userLink = assertHasContentLinkWithRel(IanaLinkRelations.SELF, client.request(usersLink));
|
||||
@@ -183,7 +183,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testname2() throws Exception {
|
||||
void testname2() throws Exception {
|
||||
|
||||
Link usersLink = client.discoverUnique("users");
|
||||
Link userLink = assertHasContentLinkWithRel(IanaLinkRelations.SELF, client.request(usersLink));
|
||||
@@ -199,7 +199,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-160
|
||||
public void returnConflictWhenConcurrentlyEditingVersionedEntity() throws Exception {
|
||||
void returnConflictWhenConcurrentlyEditingVersionedEntity() throws Exception {
|
||||
|
||||
Link receiptLink = client.discoverUnique("receipts");
|
||||
|
||||
@@ -226,7 +226,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-471
|
||||
public void auditableResourceHasLastModifiedHeaderSet() throws Exception {
|
||||
void auditableResourceHasLastModifiedHeaderSet() throws Exception {
|
||||
|
||||
Profile profile = repository.findAll().iterator().next();
|
||||
|
||||
@@ -237,7 +237,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-482
|
||||
public void putDoesNotRemoveAssociations() throws Exception {
|
||||
void putDoesNotRemoveAssociations() throws Exception {
|
||||
|
||||
Link usersLink = client.discoverUnique("users");
|
||||
Link userLink = assertHasContentLinkWithRel(IanaLinkRelations.SELF, client.request(usersLink));
|
||||
@@ -260,7 +260,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-482
|
||||
public void emptiesAssociationForEmptyUriList() throws Exception {
|
||||
void emptiesAssociationForEmptyUriList() throws Exception {
|
||||
|
||||
Link usersLink = client.discoverUnique("users");
|
||||
Link userLink = assertHasContentLinkWithRel(IanaLinkRelations.SELF, client.request(usersLink));
|
||||
@@ -274,7 +274,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-491
|
||||
public void updatesMapPropertyCorrectly() throws Exception {
|
||||
void updatesMapPropertyCorrectly() throws Exception {
|
||||
|
||||
Link profilesLink = client.discoverUnique("profiles");
|
||||
Link profileLink = assertHasContentLinkWithRel(IanaLinkRelations.SELF, client.request(profilesLink));
|
||||
@@ -288,7 +288,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-506
|
||||
public void supportsConditionalGetsOnItemResource() throws Exception {
|
||||
void supportsConditionalGetsOnItemResource() throws Exception {
|
||||
|
||||
Receipt receipt = new Receipt();
|
||||
receipt.amount = new BigDecimal(50);
|
||||
@@ -313,7 +313,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-511
|
||||
public void invokesQueryResourceReturningAnOptional() throws Exception {
|
||||
void invokesQueryResourceReturningAnOptional() throws Exception {
|
||||
|
||||
Profile profile = repository.findAll().iterator().next();
|
||||
|
||||
@@ -324,7 +324,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-517
|
||||
public void returnsNotFoundIfQueryExecutionDoesNotReturnResult() throws Exception {
|
||||
void returnsNotFoundIfQueryExecutionDoesNotReturnResult() throws Exception {
|
||||
|
||||
Link link = client.discoverUnique("profiles", "search", "findProfileById");
|
||||
|
||||
@@ -333,7 +333,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-712
|
||||
public void invokesQueryMethodTakingAReferenceCorrectly() throws Exception {
|
||||
void invokesQueryMethodTakingAReferenceCorrectly() throws Exception {
|
||||
|
||||
Link link = client.discoverUnique("users", "search", "findByColleaguesContains");
|
||||
|
||||
@@ -346,7 +346,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-835
|
||||
public void exposesETagHeaderForSearchResourceYieldingItemResource() throws Exception {
|
||||
void exposesETagHeaderForSearchResourceYieldingItemResource() throws Exception {
|
||||
|
||||
Link link = client.discoverUnique("profiles", "search", "findProfileById");
|
||||
|
||||
@@ -358,7 +358,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-835
|
||||
public void doesNotAddETagHeaderForCollectionQueryResource() throws Exception {
|
||||
void doesNotAddETagHeaderForCollectionQueryResource() throws Exception {
|
||||
|
||||
Link link = client.discoverUnique("profiles", "search", "findByType");
|
||||
|
||||
@@ -370,7 +370,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-1458
|
||||
public void accessCollectionAssociationResourceAsUriList() throws Exception {
|
||||
void accessCollectionAssociationResourceAsUriList() throws Exception {
|
||||
|
||||
Link usersLink = client.discoverUnique("users");
|
||||
Link userLink = assertHasContentLinkWithRel(IanaLinkRelations.SELF, client.request(usersLink));
|
||||
@@ -383,7 +383,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-1458
|
||||
public void accessAssociationResourceAsUriList() throws Exception {
|
||||
void accessAssociationResourceAsUriList() throws Exception {
|
||||
|
||||
Link usersLink = client.discoverUnique("users");
|
||||
Link userLink = assertHasContentLinkWithRel(IanaLinkRelations.SELF, client.request(usersLink));
|
||||
@@ -395,7 +395,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-1458
|
||||
public void accessMapCollectionAssociationResourceAsUriList() throws Exception {
|
||||
void accessMapCollectionAssociationResourceAsUriList() throws Exception {
|
||||
|
||||
Link usersLink = client.discoverUnique("users");
|
||||
Link userLink = assertHasContentLinkWithRel(IanaLinkRelations.SELF, client.request(usersLink));
|
||||
@@ -409,7 +409,7 @@ public class MongoWebTests extends CommonWebTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-762
|
||||
public void paginatedLinksContainQuerydslPropertyReferences() throws Exception {
|
||||
void paginatedLinksContainQuerydslPropertyReferences() throws Exception {
|
||||
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("page", "0");
|
||||
|
||||
@@ -22,7 +22,7 @@ import static org.mockito.Mockito.*;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.internal.stubbing.answers.ReturnsArgumentAt;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
@@ -46,14 +46,14 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@ContextConfiguration(classes = { TestConfiguration.class, MongoDbRepositoryConfig.class })
|
||||
public class PersistentEntityResourceAssemblerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
class PersistentEntityResourceAssemblerIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
|
||||
@Autowired PersistentEntities entities;
|
||||
@Autowired EntityLinks entityLinks;
|
||||
@Autowired Associations associations;
|
||||
|
||||
@Test // DATAREST-609
|
||||
public void addsSelfAndSingleResourceLinkToResourceByDefault() throws Exception {
|
||||
void addsSelfAndSingleResourceLinkToResourceByDefault() throws Exception {
|
||||
|
||||
Projector projector = mock(Projector.class);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.rest.webmvc;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.rest.tests.AbstractControllerIntegrationTests;
|
||||
import org.springframework.data.rest.tests.mongodb.MongoDbRepositoryConfig;
|
||||
@@ -34,12 +34,12 @@ import org.springframework.web.servlet.HandlerMapping;
|
||||
* @soundtrack Elephants Crossing - Echo (Irrelephant)
|
||||
*/
|
||||
@ContextConfiguration(classes = MongoDbRepositoryConfig.class)
|
||||
public class RepositoryRestHandlerMappingIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
class RepositoryRestHandlerMappingIntegrationTests extends AbstractControllerIntegrationTests {
|
||||
|
||||
@Autowired HandlerMapping mapping;
|
||||
|
||||
@Test // DATAREST-617
|
||||
public void usesMethodsWithoutProducesClauseForGeneralJsonRequests() throws Exception {
|
||||
void usesMethodsWithoutProducesClauseForGeneralJsonRequests() throws Exception {
|
||||
|
||||
MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", "/users");
|
||||
mockRequest.addHeader("Accept", "application/*+json");
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.config;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
@@ -29,15 +29,15 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@WebAppConfiguration
|
||||
public abstract class AbstractRepositoryRestMvcConfigurationIntegrationTests {
|
||||
|
||||
@Autowired WebApplicationContext context;
|
||||
protected MockMvc mvc;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(context).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,11 @@ import static org.springframework.data.rest.tests.mongodb.TestUtils.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.data.mapping.context.PersistentEntities;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
||||
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
|
||||
@@ -47,17 +45,16 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class JsonPatchHandlerUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class JsonPatchHandlerUnitTests {
|
||||
|
||||
JsonPatchHandler handler;
|
||||
User user;
|
||||
|
||||
@Mock ResourceMappings mappings;
|
||||
public @Rule ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
MongoMappingContext context = new MongoMappingContext();
|
||||
context.getPersistentEntity(User.class);
|
||||
@@ -79,7 +76,7 @@ public class JsonPatchHandlerUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-348
|
||||
public void appliesRemoveOperationCorrectly() throws Exception {
|
||||
void appliesRemoveOperationCorrectly() throws Exception {
|
||||
|
||||
String input = "[{ \"op\": \"replace\", \"path\": \"/address/zipCode\", \"value\": \"ZIP\" },"
|
||||
+ "{ \"op\": \"remove\", \"path\": \"/lastname\" }]";
|
||||
@@ -91,7 +88,7 @@ public class JsonPatchHandlerUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-348
|
||||
public void appliesMergePatchCorrectly() throws Exception {
|
||||
void appliesMergePatchCorrectly() throws Exception {
|
||||
|
||||
String input = "{ \"address\" : { \"zipCode\" : \"ZIP\"}, \"lastname\" : null }";
|
||||
|
||||
@@ -105,7 +102,7 @@ public class JsonPatchHandlerUnitTests {
|
||||
* DATAREST-537
|
||||
*/
|
||||
@Test
|
||||
public void removesArrayItemCorrectly() throws Exception {
|
||||
void removesArrayItemCorrectly() throws Exception {
|
||||
|
||||
User thomas = new User();
|
||||
thomas.firstname = "Thomas";
|
||||
@@ -124,11 +121,10 @@ public class JsonPatchHandlerUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-609
|
||||
public void hintsToMediaTypeIfBodyCantBeRead() throws Exception {
|
||||
void hintsToMediaTypeIfBodyCantBeRead() throws Exception {
|
||||
|
||||
exception.expect(HttpMessageNotReadableException.class);
|
||||
exception.expectMessage(RestMediaTypes.JSON_PATCH_JSON.toString());
|
||||
|
||||
handler.applyPatch(asStream("{ \"foo\" : \"bar\" }"), new User());
|
||||
assertThatExceptionOfType(HttpMessageNotReadableException.class)
|
||||
.isThrownBy(() -> handler.applyPatch(asStream("{ \"foo\" : \"bar\" }"), new User()))
|
||||
.withMessageContaining(RestMediaTypes.JSON_PATCH_JSON.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
||||
import org.springframework.data.querydsl.QuerydslRepositoryInvokerAdapter;
|
||||
@@ -54,23 +54,23 @@ import com.querydsl.core.types.Predicate;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class QuerydslAwareRootResourceInformationHandlerMethodArgumentResolverUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class QuerydslAwareRootResourceInformationHandlerMethodArgumentResolverUnitTests {
|
||||
|
||||
static final Map<String, String[]> NO_PARAMETERS = Collections.emptyMap();
|
||||
|
||||
@Mock Repositories repositories;
|
||||
@Mock RepositoryInvokerFactory invokerFactory;
|
||||
@Mock ResourceMetadataHandlerMethodArgumentResolver resourceMetadataResolver;
|
||||
@Mock QuerydslPredicateBuilder builder;
|
||||
@Mock(lenient = true) QuerydslPredicateBuilder builder;
|
||||
|
||||
@Mock RepositoryInvoker invoker;
|
||||
@Mock MethodParameter parameter;
|
||||
|
||||
QuerydslAwareRootResourceInformationHandlerMethodArgumentResolver resolver;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
QuerydslBindingsFactory factory = new QuerydslBindingsFactory(SimpleEntityPathResolver.INSTANCE);
|
||||
ReflectionTestUtils.setField(factory, "repositories", Optional.of(repositories));
|
||||
@@ -83,7 +83,7 @@ public class QuerydslAwareRootResourceInformationHandlerMethodArgumentResolverUn
|
||||
}
|
||||
|
||||
@Test // DATAREST-616
|
||||
public void returnsInvokerIfRepositoryIsNotQuerydslAware() {
|
||||
void returnsInvokerIfRepositoryIsNotQuerydslAware() {
|
||||
|
||||
ReceiptRepository repository = mock(ReceiptRepository.class);
|
||||
when(repositories.getRepositoryFor(Receipt.class)).thenReturn(Optional.of(repository));
|
||||
@@ -94,7 +94,7 @@ public class QuerydslAwareRootResourceInformationHandlerMethodArgumentResolverUn
|
||||
}
|
||||
|
||||
@Test // DATAREST-616
|
||||
public void wrapsInvokerInQuerydslAdapter() {
|
||||
void wrapsInvokerInQuerydslAdapter() {
|
||||
|
||||
Object repository = mock(QuerydslUserRepository.class);
|
||||
when(repositories.getRepositoryFor(User.class)).thenReturn(Optional.of(repository));
|
||||
@@ -105,7 +105,7 @@ public class QuerydslAwareRootResourceInformationHandlerMethodArgumentResolverUn
|
||||
}
|
||||
|
||||
@Test // DATAREST-616
|
||||
public void invokesCustomizationOnRepositoryIfItImplementsCustomizer() {
|
||||
void invokesCustomizationOnRepositoryIfItImplementsCustomizer() {
|
||||
|
||||
QuerydslCustomizingUserRepository repository = mock(QuerydslCustomizingUserRepository.class);
|
||||
when(repositories.getRepositoryFor(User.class)).thenReturn(Optional.of(repository));
|
||||
|
||||
@@ -20,9 +20,9 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -45,7 +45,7 @@ import org.springframework.hateoas.mediatype.MessageResolver;
|
||||
import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
@@ -60,10 +60,10 @@ import com.jayway.jsonpath.ReadContext;
|
||||
* @author Greg Turnquist
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = { MongoDbRepositoryConfig.class, RepositoryTestsConfig.class,
|
||||
PersistentEntitySerializationTests.TestConfig.class })
|
||||
public class PersistentEntitySerializationTests {
|
||||
class PersistentEntitySerializationTests {
|
||||
|
||||
@Autowired ObjectMapper mapper;
|
||||
@Autowired Repositories repositories;
|
||||
@@ -86,8 +86,8 @@ public class PersistentEntitySerializationTests {
|
||||
LinkDiscoverer linkDiscoverer;
|
||||
ProjectionFactory projectionFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
RequestContextHolder.setRequestAttributes(new ServletWebRequest(new MockHttpServletRequest()));
|
||||
|
||||
@@ -96,7 +96,7 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-250
|
||||
public void serializesEmbeddedReferencesCorrectly() throws Exception {
|
||||
void serializesEmbeddedReferencesCorrectly() throws Exception {
|
||||
|
||||
User user = new User();
|
||||
user.address = new Address();
|
||||
@@ -116,12 +116,12 @@ public class PersistentEntitySerializationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-654
|
||||
public void deserializesTranslatedEnumProperty() throws Exception {
|
||||
void deserializesTranslatedEnumProperty() throws Exception {
|
||||
assertThat(mapper.readValue("{ \"gender\" : \"Male\" }", User.class).gender).isEqualTo(Gender.MALE);
|
||||
}
|
||||
|
||||
@Test // DATAREST-864
|
||||
public void createsNestedResourceForMap() throws Exception {
|
||||
void createsNestedResourceForMap() throws Exception {
|
||||
|
||||
User dave = users.save(new User());
|
||||
dave.colleaguesMap = new HashMap<String, Nested>();
|
||||
|
||||
@@ -15,18 +15,18 @@
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.json;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -48,7 +48,7 @@ import org.springframework.data.rest.webmvc.json.PersistentEntityToJsonSchemaCon
|
||||
import org.springframework.data.rest.webmvc.mapping.Associations;
|
||||
import org.springframework.hateoas.mediatype.MessageResolver;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -59,9 +59,9 @@ import com.jayway.jsonpath.PathNotFoundException;
|
||||
* @author Oliver Gierke
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = { MongoDbRepositoryConfig.class, TestConfiguration.class })
|
||||
public class PersistentEntityToJsonSchemaConverterUnitTests {
|
||||
class PersistentEntityToJsonSchemaConverterUnitTests {
|
||||
|
||||
@Autowired MessageResolver resolver;
|
||||
@Autowired RepositoryRestConfiguration configuration;
|
||||
@@ -89,8 +89,8 @@ public class PersistentEntityToJsonSchemaConverterUnitTests {
|
||||
|
||||
PersistentEntityToJsonSchemaConverter converter;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
TestMvcClient.initWebTest();
|
||||
|
||||
@@ -101,7 +101,7 @@ public class PersistentEntityToJsonSchemaConverterUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-631, DATAREST-632
|
||||
public void fulfillsConstraintsForProfile() {
|
||||
void fulfillsConstraintsForProfile() {
|
||||
|
||||
List<Constraint> constraints = new ArrayList<Constraint>();
|
||||
constraints.add(new Constraint("$.properties.id", is(notNullValue()), "Has descriptor for id property"));
|
||||
@@ -114,7 +114,7 @@ public class PersistentEntityToJsonSchemaConverterUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-632
|
||||
public void fulfillsConstraintsForUser() throws Exception {
|
||||
void fulfillsConstraintsForUser() throws Exception {
|
||||
|
||||
List<Constraint> constraints = new ArrayList<Constraint>();
|
||||
constraints.add(new Constraint("$.properties.id", is(nullValue()), "Does NOT have descriptor for id property"));
|
||||
@@ -166,7 +166,7 @@ public class PersistentEntityToJsonSchemaConverterUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-754
|
||||
public void handlesGroovyDomainObjects() {
|
||||
void handlesGroovyDomainObjects() {
|
||||
|
||||
List<Constraint> constraints = new ArrayList<Constraint>();
|
||||
constraints.add(new Constraint("$.properties.name", is(notNullValue()), "Has descriptor for name property"));
|
||||
@@ -182,11 +182,12 @@ public class PersistentEntityToJsonSchemaConverterUnitTests {
|
||||
for (Constraint constraint : constraints) {
|
||||
|
||||
try {
|
||||
assertThat(constraint.description, JsonPath.read(writeSchemaFor, constraint.selector), constraint.matcher);
|
||||
MatcherAssert.assertThat(constraint.description, JsonPath.read(writeSchemaFor, constraint.selector),
|
||||
constraint.matcher);
|
||||
} catch (PathNotFoundException e) {
|
||||
assertThat(constraint.matcher.matches(null)).isTrue();
|
||||
} catch (RuntimeException e) {
|
||||
assertThat(e, constraint.matcher);
|
||||
MatcherAssert.assertThat(e, constraint.matcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.mapping.context.PersistentEntities;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
||||
import org.springframework.data.rest.core.mapping.PersistentEntitiesResourceMappings;
|
||||
@@ -34,12 +34,12 @@ import org.springframework.hateoas.Link;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class RepositoryLinkBuildUnitTests {
|
||||
class RepositoryLinkBuildUnitTests {
|
||||
|
||||
MongoMappingContext context = new MongoMappingContext();
|
||||
|
||||
@Test // DATAREST-292
|
||||
public void usesCurrentRequestsUriBaseForRelativeBaseUri() {
|
||||
void usesCurrentRequestsUriBaseForRelativeBaseUri() {
|
||||
|
||||
TestMvcClient.initWebTest();
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RepositoryLinkBuildUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-292, DATAREST-296
|
||||
public void usesBaseUriOnlyIfItIsAbsolute() {
|
||||
void usesBaseUriOnlyIfItIsAbsolute() {
|
||||
assertRootUriFor("http://foobar/api", "http://foobar/api/profile");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
||||
@Configuration // <1>
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true) // <2>
|
||||
public class SecurityConfiguration extends WebSecurityConfigurerAdapter { // <3>
|
||||
class SecurityConfiguration extends WebSecurityConfigurerAdapter { // <3>
|
||||
// end::code[]
|
||||
@Autowired
|
||||
public void configureAuth(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureAuth(AuthenticationManagerBuilder auth) throws Exception {
|
||||
|
||||
auth.inMemoryAuthentication()
|
||||
.withUser("user").password("user").roles("USER").and()
|
||||
|
||||
@@ -20,9 +20,9 @@ import static org.springframework.security.test.web.servlet.setup.SecurityMockMv
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.map.repository.config.EnableMapRepositories;
|
||||
@@ -36,7 +36,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
@@ -48,10 +48,10 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
* @author Greg Turnquist
|
||||
* @author Rob Winch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = { SecurityIntegrationTests.Config.class, SecurityConfiguration.class,
|
||||
RepositoryRestMvcConfiguration.class })
|
||||
public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
|
||||
@Autowired WebApplicationContext context;
|
||||
@Autowired MethodSecurityInterceptor methodSecurityInterceptor;
|
||||
@@ -63,7 +63,7 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
@EnableMapRepositories
|
||||
static class Config {}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
@Override
|
||||
public void setUp() {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void deletePersonAccessDeniedForNoCredentials() throws Exception {
|
||||
void deletePersonAccessDeniedForNoCredentials() throws Exception {
|
||||
|
||||
// Getting the collection is not tested here. This is to get the URI that will later be tested for DELETE
|
||||
final String people = client.discoverUnique("people").expand().getHref();
|
||||
@@ -113,7 +113,7 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void deletePersonAccessDeniedForUsers() throws Exception {
|
||||
void deletePersonAccessDeniedForUsers() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = mvc.perform(get(client.discoverUnique("people").expand().getHref()).//
|
||||
with(user("user").roles("USER"))).//
|
||||
@@ -128,7 +128,7 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void deletePersonAccessGrantedForAdmins() throws Exception {
|
||||
void deletePersonAccessGrantedForAdmins() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = mvc.perform(get(client.discoverUnique("people").expand().getHref()).//
|
||||
with(user("user").roles("USER", "ADMIN"))).//
|
||||
@@ -143,14 +143,14 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void findAllPeopleAccessDeniedForNoCredentials() throws Throwable {
|
||||
void findAllPeopleAccessDeniedForNoCredentials() throws Throwable {
|
||||
|
||||
mvc.perform(get(client.discoverUnique("people").expand().getHref())).//
|
||||
andExpect(status().isUnauthorized());
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void findAllPeopleAccessGrantedForUsers() throws Throwable {
|
||||
void findAllPeopleAccessGrantedForUsers() throws Throwable {
|
||||
|
||||
mvc.perform(get(client.discoverUnique("people").expand().getHref()).//
|
||||
with(user("user").roles("USER"))).//
|
||||
@@ -158,7 +158,7 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void findAllPeopleAccessGrantedForAdmins() throws Throwable {
|
||||
void findAllPeopleAccessGrantedForAdmins() throws Throwable {
|
||||
|
||||
mvc.perform(get(client.discoverUnique("people").expand().getHref()).//
|
||||
with(user("user").roles("USER", "ADMIN"))).//
|
||||
@@ -166,7 +166,7 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void deleteOrderAccessDeniedForNoCredentials() throws Exception {
|
||||
void deleteOrderAccessDeniedForNoCredentials() throws Exception {
|
||||
|
||||
// Getting the collection is not tested here. This is to get the URI that will later be tested for DELETE
|
||||
MockHttpServletResponse response = mvc.perform(get(client.discoverUnique("orders").expand().getHref()).//
|
||||
@@ -181,7 +181,7 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void deleteOrderAccessDeniedForUsers() throws Exception {
|
||||
void deleteOrderAccessDeniedForUsers() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = mvc.perform(get(client.discoverUnique("orders").expand().getHref()).//
|
||||
with(user("user").roles("USER"))).//
|
||||
@@ -193,7 +193,7 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void deleteOrderAccessGrantedForAdmins() throws Exception {
|
||||
void deleteOrderAccessGrantedForAdmins() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = mvc.perform(get(client.discoverUnique("orders").expand().getHref()).//
|
||||
with(user("user").roles("USER"))).//
|
||||
@@ -208,14 +208,14 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void findAllOrdersAccessDeniedForNoCredentials() throws Throwable {
|
||||
void findAllOrdersAccessDeniedForNoCredentials() throws Throwable {
|
||||
|
||||
mvc.perform(get(client.discoverUnique("orders").expand().getHref())).//
|
||||
andExpect(status().isUnauthorized());
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void findAllOrdersAccessGrantedForUsers() throws Throwable {
|
||||
void findAllOrdersAccessGrantedForUsers() throws Throwable {
|
||||
|
||||
mvc.perform(get(client.discoverUnique("orders").expand().getHref()).//
|
||||
with(user("user").roles("USER"))).//
|
||||
@@ -223,7 +223,7 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
public void findAllOrdersAccessGrantedForAdmins() throws Throwable {
|
||||
void findAllOrdersAccessGrantedForAdmins() throws Throwable {
|
||||
|
||||
mvc.perform(get(client.discoverUnique("orders").expand().getHref()).//
|
||||
with(user("user").roles("USER", "ADMIN"))).//
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.springframework.hateoas.server.RepresentationModelProcessor;
|
||||
*/
|
||||
@Configuration
|
||||
@EnableMapRepositories
|
||||
public class ShopConfiguration {
|
||||
class ShopConfiguration {
|
||||
|
||||
@Autowired CustomerRepository customers;
|
||||
@Autowired OrderRepository orders;
|
||||
@@ -77,7 +77,7 @@ public class ShopConfiguration {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
void init() {
|
||||
|
||||
LineItemType lineItemType = lineItemTypes.save(new LineItemType("good"));
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.data.rest.tests.AbstractWebIntegrationTests;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
@@ -37,12 +37,12 @@ import com.jayway.jsonpath.JsonPath;
|
||||
* @author Oliver Gierke
|
||||
* @author Craig Andrews
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = ShopConfiguration.class)
|
||||
public class ShopIntegrationTests extends AbstractWebIntegrationTests {
|
||||
class ShopIntegrationTests extends AbstractWebIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void rendersRepresentationCorrectly() throws Exception {
|
||||
void rendersRepresentationCorrectly() throws Exception {
|
||||
|
||||
Link ordersLink = client.discoverUnique("orders");
|
||||
String selfLink = JsonPath.parse(client.request(ordersLink).getContentAsString())
|
||||
@@ -63,7 +63,7 @@ public class ShopIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void renderProductNameOnlyProjection() throws Exception {
|
||||
void renderProductNameOnlyProjection() throws Exception {
|
||||
|
||||
Map<String, Object> arguments = Collections.singletonMap("projection", "nameOnly");
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ShopIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void renderProductNameOnlyProjectionResourceProcessor() throws Exception {
|
||||
void renderProductNameOnlyProjectionResourceProcessor() throws Exception {
|
||||
|
||||
Map<String, Object> arguments = Collections.singletonMap("projection", "nameOnly");
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ShopIntegrationTests extends AbstractWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void renderOrderItemsOnlyProjectionResourceProcessor() throws Exception {
|
||||
void renderOrderItemsOnlyProjectionResourceProcessor() throws Exception {
|
||||
|
||||
Map<String, Object> arguments = Collections.singletonMap("projection", "itemsOnly");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user