@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user