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