diff --git a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/AbstractIntegrationTests.java b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/AbstractIntegrationTests.java index d5b94c4e0..65d1d5e7c 100755 --- a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/AbstractIntegrationTests.java +++ b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/AbstractIntegrationTests.java @@ -21,7 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.rest.core.domain.Person; import org.springframework.data.rest.core.domain.PersonRepository; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; /** * Base class for integration tests loading {@link RepositoryTestsConfig} and populating the {@link PersonRepository} @@ -29,7 +29,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * * @author Oliver Gierke */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration(classes = RepositoryTestsConfig.class) public abstract class AbstractIntegrationTests { diff --git a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/RepositoryEventIntegrationTests.java b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/RepositoryEventIntegrationTests.java index 885c09d1f..e563d1015 100755 --- a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/RepositoryEventIntegrationTests.java +++ b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/RepositoryEventIntegrationTests.java @@ -18,6 +18,7 @@ package org.springframework.data.rest.core.context; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; @@ -29,19 +30,9 @@ import org.springframework.data.rest.core.domain.EventHandlerInvokedException; import org.springframework.data.rest.core.domain.Person; import org.springframework.data.rest.core.domain.PersonBeforeSaveHandler; import org.springframework.data.rest.core.domain.PersonRepository; -import org.springframework.data.rest.core.event.AfterCreateEvent; -import org.springframework.data.rest.core.event.AfterDeleteEvent; -import org.springframework.data.rest.core.event.AfterLinkDeleteEvent; -import org.springframework.data.rest.core.event.AfterLinkSaveEvent; -import org.springframework.data.rest.core.event.AfterSaveEvent; -import org.springframework.data.rest.core.event.AnnotatedEventHandlerInvoker; -import org.springframework.data.rest.core.event.BeforeCreateEvent; -import org.springframework.data.rest.core.event.BeforeDeleteEvent; -import org.springframework.data.rest.core.event.BeforeLinkDeleteEvent; -import org.springframework.data.rest.core.event.BeforeLinkSaveEvent; -import org.springframework.data.rest.core.event.BeforeSaveEvent; +import org.springframework.data.rest.core.event.*; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; /** * Tests around the {@link org.springframework.context.ApplicationEvent} handling abstractions. @@ -49,7 +40,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Jon Brisbin * @author Oliver Gierke */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration public class RepositoryEventIntegrationTests { diff --git a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/ValidatorIntegrationTests.java b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/ValidatorIntegrationTests.java index 2e13c6687..961b669bb 100755 --- a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/ValidatorIntegrationTests.java +++ b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/ValidatorIntegrationTests.java @@ -33,7 +33,7 @@ import org.springframework.data.rest.core.domain.PersonNameValidator; import org.springframework.data.rest.core.event.BeforeSaveEvent; import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; /** * Tests to check the {@link org.springframework.validation.Validator} integration. @@ -41,7 +41,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Jon Brisbin * @author Oliver Gierke */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration public class ValidatorIntegrationTests { diff --git a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappingsIntegrationTests.java b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappingsIntegrationTests.java index fb2dc5399..4c7d075d2 100755 --- a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappingsIntegrationTests.java +++ b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappingsIntegrationTests.java @@ -44,7 +44,7 @@ import org.springframework.data.rest.core.domain.Person; import org.springframework.data.rest.core.domain.Profile; import org.springframework.hateoas.LinkRelation; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; /** * Integration tests for {@link RepositoryResourceMappings}. @@ -52,7 +52,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Oliver Gierke * @author Greg Turnquist */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration(classes = JpaRepositoryConfig.class) public class RepositoryResourceMappingsIntegrationTests { diff --git a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DefaultSelfLinkProviderUnitTests.java b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DefaultSelfLinkProviderUnitTests.java index cd286c85d..a53dec655 100755 --- a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DefaultSelfLinkProviderUnitTests.java +++ b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DefaultSelfLinkProviderUnitTests.java @@ -15,7 +15,7 @@ */ package org.springframework.data.rest.core.support; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; @@ -23,14 +23,12 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.hamcrest.Matchers; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; + import org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingContext; import org.springframework.data.mapping.context.PersistentEntities; import org.springframework.data.rest.core.domain.Profile; @@ -52,8 +50,6 @@ public class DefaultSelfLinkProviderUnitTests { PersistentEntities entities; List> lookups; - public @Rule ExpectedException exception = ExpectedException.none(); - @Before public void setUp() { @@ -95,7 +91,7 @@ public class DefaultSelfLinkProviderUnitTests { Profile profile = new Profile("Name", "Type"); Link link = provider.createSelfLinkFor(profile); - assertThat(link.getHref(), Matchers.endsWith(profile.getId().toString())); + assertThat(link.getHref()).endsWith(profile.getId().toString()); } @Test // DATAREST-724 @@ -106,20 +102,18 @@ public class DefaultSelfLinkProviderUnitTests { when(lookup.supports(Profile.class)).thenReturn(true); when(lookup.getResourceIdentifier(any(Profile.class))).thenReturn("foo"); - this.provider = new DefaultSelfLinkProvider(entities, entityLinks, Arrays.asList(lookup)); + this.provider = new DefaultSelfLinkProvider(entities, entityLinks, Collections.singletonList(lookup)); Link link = provider.createSelfLinkFor(new Profile("Name", "Type")); - assertThat(link.getHref(), Matchers.endsWith("foo")); + assertThat(link.getHref()).endsWith("foo"); } @Test // DATAREST-724 public void rejectsLinkCreationForUnknownEntity() { - exception.expect(IllegalArgumentException.class); - exception.expectMessage(Object.class.getName()); - exception.expectMessage("Couldn't find PersistentEntity for"); - - provider.createSelfLinkFor(new Object()); + assertThatIllegalArgumentException().isThrownBy(() -> provider.createSelfLinkFor(new Object())) // + .withMessageContaining(Object.class.getName()) // + .withMessageContaining("Couldn't find PersistentEntity for"); } } diff --git a/spring-data-rest-hal-browser/src/test/java/org/springframework/data/rest/webmvc/halbrowser/HalBrowserIntegrationTests.java b/spring-data-rest-hal-browser/src/test/java/org/springframework/data/rest/webmvc/halbrowser/HalBrowserIntegrationTests.java index c1a6f9871..2643a26e6 100755 --- a/spring-data-rest-hal-browser/src/test/java/org/springframework/data/rest/webmvc/halbrowser/HalBrowserIntegrationTests.java +++ b/spring-data-rest-hal-browser/src/test/java/org/springframework/data/rest/webmvc/halbrowser/HalBrowserIntegrationTests.java @@ -34,7 +34,7 @@ import org.springframework.hateoas.MediaTypes; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; @@ -47,7 +47,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc; * @author Oliver Gierke * @soundtrack Miles Davis - Blue in green (Kind of blue) */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @WebAppConfiguration @ContextConfiguration public class HalBrowserIntegrationTests { diff --git a/spring-data-rest-hal-browser/src/test/java/org/springframework/data/rest/webmvc/halbrowser/HalBrowserUnitTests.java b/spring-data-rest-hal-browser/src/test/java/org/springframework/data/rest/webmvc/halbrowser/HalBrowserUnitTests.java index 54fe1cb3c..bc581bb85 100755 --- a/spring-data-rest-hal-browser/src/test/java/org/springframework/data/rest/webmvc/halbrowser/HalBrowserUnitTests.java +++ b/spring-data-rest-hal-browser/src/test/java/org/springframework/data/rest/webmvc/halbrowser/HalBrowserUnitTests.java @@ -15,9 +15,7 @@ */ package org.springframework.data.rest.webmvc.halbrowser; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.*; import java.io.IOException; import java.util.Collections; @@ -26,6 +24,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import org.junit.Test; + import org.springframework.http.HttpHeaders; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; @@ -61,7 +60,7 @@ public class HalBrowserUnitTests { UriComponents components = UriComponentsBuilder.fromUriString(response.getHeader(HttpHeaders.LOCATION)).build(); - assertThat(components.getPath(), startsWith("/context")); + assertThat(components.getPath()).startsWith("/context"); assertThat(components.getFragment()).isEqualTo("/context"); } @@ -83,8 +82,7 @@ public class HalBrowserUnitTests { String url = ((RedirectView) view).getUrl(); - assertThat(url, startsWith("https://somehost:4711/prefix")); - assertThat(url, endsWith("/prefix")); + assertThat(url).startsWith("https://somehost:4711/prefix").endsWith("/prefix"); }); } } diff --git a/spring-data-rest-hal-explorer/src/test/java/org/springframework/data/rest/webmvc/halexplorer/HalExplorerIntegrationTests.java b/spring-data-rest-hal-explorer/src/test/java/org/springframework/data/rest/webmvc/halexplorer/HalExplorerIntegrationTests.java index 1ae89141d..820e97cf5 100755 --- a/spring-data-rest-hal-explorer/src/test/java/org/springframework/data/rest/webmvc/halexplorer/HalExplorerIntegrationTests.java +++ b/spring-data-rest-hal-explorer/src/test/java/org/springframework/data/rest/webmvc/halexplorer/HalExplorerIntegrationTests.java @@ -34,7 +34,7 @@ import org.springframework.hateoas.MediaTypes; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; @@ -47,7 +47,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc; * @author Oliver Gierke * @soundtrack Miles Davis - Blue in green (Kind of blue) */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @WebAppConfiguration @ContextConfiguration public class HalExplorerIntegrationTests { diff --git a/spring-data-rest-hal-explorer/src/test/java/org/springframework/data/rest/webmvc/halexplorer/HalExplorerUnitTests.java b/spring-data-rest-hal-explorer/src/test/java/org/springframework/data/rest/webmvc/halexplorer/HalExplorerUnitTests.java index b943a5bea..3154709a2 100755 --- a/spring-data-rest-hal-explorer/src/test/java/org/springframework/data/rest/webmvc/halexplorer/HalExplorerUnitTests.java +++ b/spring-data-rest-hal-explorer/src/test/java/org/springframework/data/rest/webmvc/halexplorer/HalExplorerUnitTests.java @@ -15,9 +15,7 @@ */ package org.springframework.data.rest.webmvc.halexplorer; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.*; import java.io.IOException; import java.util.Collections; @@ -26,12 +24,12 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import org.junit.Test; + import org.springframework.http.HttpHeaders; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.web.filter.ForwardedHeaderFilter; import org.springframework.web.servlet.View; -import org.springframework.web.servlet.view.AbstractView; import org.springframework.web.servlet.view.RedirectView; import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder; @@ -57,11 +55,11 @@ public class HalExplorerUnitTests { assertThat(view).isInstanceOf(RedirectView.class); - ((AbstractView) view).render(Collections. emptyMap(), request, response); + view.render(Collections.emptyMap(), request, response); UriComponents components = UriComponentsBuilder.fromUriString(response.getHeader(HttpHeaders.LOCATION)).build(); - assertThat(components.getPath(), startsWith("/context")); + assertThat(components.getPath()).startsWith("/context"); assertThat(components.getFragment()).isEqualTo("uri=/context"); } @@ -83,8 +81,7 @@ public class HalExplorerUnitTests { String url = ((RedirectView) view).getUrl(); - assertThat(url, startsWith("https://somehost:4711/prefix")); - assertThat(url, endsWith("/prefix")); + assertThat(url).startsWith("https://somehost:4711/prefix").endsWith("/prefix"); }); } } diff --git a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractControllerIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractControllerIntegrationTests.java index 6f5ebd122..38b61fda5 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractControllerIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractControllerIntegrationTests.java @@ -40,7 +40,7 @@ import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguratio import org.springframework.data.rest.webmvc.support.Projector; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.Assert; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -52,7 +52,7 @@ import org.springframework.web.context.request.WebRequest; * * @author Oliver Gierke */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration public abstract class AbstractControllerIntegrationTests { diff --git a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java index d93d14a25..209a972b1 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java @@ -28,16 +28,17 @@ import java.util.Optional; import org.junit.Before; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; import org.springframework.hateoas.Link; -import org.springframework.hateoas.client.LinkDiscoverers; import org.springframework.hateoas.LinkRelation; +import org.springframework.hateoas.client.LinkDiscoverers; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultMatcher; @@ -61,7 +62,7 @@ import com.jayway.jsonpath.JsonPath; * @author Greg Turnquist * @author Christoph Strobl */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @WebAppConfiguration @ContextConfiguration(classes = { RepositoryRestMvcConfiguration.class, DelegatingWebMvcConfiguration.class }) public abstract class AbstractWebIntegrationTests { diff --git a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/ResourceTester.java b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/ResourceTester.java index 1c01de0d0..b0f56bebe 100644 --- a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/ResourceTester.java +++ b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/ResourceTester.java @@ -15,17 +15,15 @@ */ package org.springframework.data.rest.tests; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.*; + +import java.util.function.Consumer; -import org.hamcrest.Matcher; import org.springframework.data.rest.core.Path; +import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.Link; import org.springframework.hateoas.PagedModel; -import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.RepresentationModel; -import org.springframework.hateoas.CollectionModel; import org.springframework.util.Assert; import org.springframework.web.util.UriTemplate; @@ -39,7 +37,7 @@ public class ResourceTester { private final RepresentationModel resource; public static ResourceTester of(Object object) { - assertThat(object, is(instanceOf(RepresentationModel.class))); + assertThat(object).isInstanceOf(RepresentationModel.class); return new ResourceTester((RepresentationModel) object); } @@ -69,7 +67,12 @@ public class ResourceTester { * @param href can be {@literal null}, if so, only the presence of a {@link Link} with the given rel is checked. */ public Link assertHasLink(String rel, String href) { - return assertHasLinkMatching(rel, href == null ? null : is(href)); + return assertHasLinkMatching(rel, it -> { + if (href == null) { + return; + } + assertThat(it).isEqualTo(href); + }); } /** @@ -79,17 +82,22 @@ public class ResourceTester { * @param href can be {@literal null}, if so, only the presence of a {@link Link} with the given rel is checked. */ public Link assertHasLinkEndingWith(String rel, String hrefEnd) { - return assertHasLinkMatching(rel, hrefEnd == null ? null : endsWith(hrefEnd)); + return assertHasLinkMatching(rel, it -> { + if (hrefEnd == null) { + return; + } + assertThat(it).endsWith(hrefEnd); + }); } - private final Link assertHasLinkMatching(String rel, Matcher hrefMatcher) { + private Link assertHasLinkMatching(String rel, Consumer hrefMatcher) { Link link = resource.getRequiredLink(rel); - assertThat("Expected link with rel '" + rel + "' but didn't find it in " + resource.getLinks(), link, - is(notNullValue())); + assertThat(link).as("Expected link with rel '" + rel + "' but didn't find it in " + resource.getLinks()) + .isNotNull(); if (hrefMatcher != null) { - assertThat(link.getHref(), is(hrefMatcher)); + assertThat(link.getHref()).satisfies(hrefMatcher); } return link; @@ -98,25 +106,25 @@ public class ResourceTester { @SuppressWarnings("unchecked") public PagedModel assertIsPage() { - assertThat(resource, is(instanceOf(PagedModel.class))); + assertThat(resource).isInstanceOf(PagedModel.class); return (PagedModel) resource; } public ResourceTester getContentResource() { - assertThat(resource, is(instanceOf(CollectionModel.class))); + assertThat(resource).isInstanceOf(CollectionModel.class); Object next = ((CollectionModel) resource).getContent().iterator().next(); - assertThat(next, is(instanceOf(RepresentationModel.class))); + assertThat(next).isInstanceOf(RepresentationModel.class); return new ResourceTester((RepresentationModel) next); } public void withContentResource(ContentResourceHandler handler) { - assertThat(resource, is(instanceOf(CollectionModel.class))); + assertThat(resource).isInstanceOf(CollectionModel.class); for (Object element : ((CollectionModel) resource).getContent()) { - assertThat(element, is(instanceOf(RepresentationModel.class))); + assertThat(element).isInstanceOf(RepresentationModel.class); handler.doWith(of(element)); } } @@ -144,8 +152,8 @@ public class ResourceTester { String href = content.assertHasLink("self", null).getHref(); UriTemplate uriTemplate = new UriTemplate(template.toString()); - assertThat(String.format("Expected %s to match %s!", href, uriTemplate.toString()), uriTemplate.matches(href), - is(true)); + assertThat(uriTemplate.matches(href)).as(String.format("Expected %s to match %s!", href, uriTemplate.toString())) + .isTrue(); } } } diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryEntityControllerIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryEntityControllerIntegrationTests.java index 94b725703..d089f5a5b 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryEntityControllerIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryEntityControllerIntegrationTests.java @@ -16,10 +16,6 @@ package org.springframework.data.rest.webmvc; import static org.assertj.core.api.Assertions.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.*; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; import static org.mockito.Mockito.*; import static org.springframework.data.rest.tests.TestMvcClient.*; import static org.springframework.http.HttpMethod.*; @@ -27,9 +23,9 @@ import static org.springframework.http.HttpMethod.*; import java.util.List; import java.util.Optional; -import org.hamcrest.Matchers; import org.junit.Test; import org.mockito.Mockito; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -114,7 +110,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll ResponseEntity entity = controller.putItemResource(information, persistentEntityResource, 1L, assembler, ETag.NO_ETAG, MediaType.APPLICATION_JSON_VALUE); - assertThat(entity.getHeaders().getLocation().toString(), not(Matchers.endsWith("{?projection}"))); + assertThat(entity.getHeaders().getLocation().toString()).doesNotEndWith("{?projection}"); } @Test // DATAREST-330 @@ -174,10 +170,8 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll List value = entity.getHeaders().get("Accept-Patch"); assertThat(value).hasSize(3); - assertThat(value, hasItems(// - RestMediaTypes.JSON_PATCH_JSON.toString(), // - RestMediaTypes.MERGE_PATCH_JSON.toString(), // - MediaType.APPLICATION_JSON_VALUE)); + assertThat(value).contains(RestMediaTypes.JSON_PATCH_JSON.toString(), RestMediaTypes.MERGE_PATCH_JSON.toString(), + MediaType.APPLICATION_JSON_VALUE); } @Test // DATAREST-34 @@ -190,7 +184,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll .build(new Order(new Person()), entities.getRequiredPersistentEntity(Order.class)).build(); assertThat(controller.putItemResource(request, persistentEntityResource, order.getId(), assembler, ETag.NO_ETAG, - MediaType.APPLICATION_JSON_VALUE).hasBody(), is(true)); + MediaType.APPLICATION_JSON_VALUE).hasBody()).isTrue(); } @Test // DATAREST-34 @@ -201,7 +195,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll .build(new Order(new Person()), entities.getRequiredPersistentEntity(Order.class)).forCreation(); assertThat(controller.putItemResource(request, persistentEntityResource, 1L, assembler, ETag.NO_ETAG, - MediaType.APPLICATION_JSON_VALUE).hasBody(), is(true)); + MediaType.APPLICATION_JSON_VALUE).hasBody()).isTrue(); } @Test // DATAREST-34 @@ -213,7 +207,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll assertThat(controller .postCollectionResource(request, persistentEntityResource, assembler, MediaType.APPLICATION_JSON_VALUE) - .hasBody(), is(true)); + .hasBody()).isTrue(); } @Test // DATAREST-34 @@ -223,10 +217,9 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll PersistentEntityResource persistentEntityResource = PersistentEntityResource .build(new Order(new Person()), entities.getRequiredPersistentEntity(Order.class)).build(); - assertThat(controller.postCollectionResource(request, persistentEntityResource, assembler, null).hasBody(), - is(false)); - assertThat(controller.postCollectionResource(request, persistentEntityResource, assembler, "").hasBody(), - is(false)); + assertThat(controller.postCollectionResource(request, persistentEntityResource, assembler, null).hasBody()) + .isFalse(); + assertThat(controller.postCollectionResource(request, persistentEntityResource, assembler, "").hasBody()).isFalse(); } @Test // DATAREST-581 @@ -243,8 +236,8 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll Mockito.when(assembler.toFullResource(Mockito.any(Object.class))).thenReturn(resource); - ResponseEntity> entity = controller.getItemResource(getResourceInformation(Address.class), address.id, - assembler, new HttpHeaders()); + ResponseEntity> entity = controller.getItemResource(getResourceInformation(Address.class), + address.id, assembler, new HttpHeaders()); assertThat(entity.getHeaders().getETag()).isNotNull(); } diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceControllerIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceControllerIntegrationTests.java index 8315ebb3e..fe981d178 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceControllerIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceControllerIntegrationTests.java @@ -15,12 +15,12 @@ */ package org.springframework.data.rest.webmvc; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; import org.junit.Before; import org.junit.Test; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.rest.tests.AbstractControllerIntegrationTests; import org.springframework.data.rest.webmvc.jpa.Book; @@ -58,8 +58,8 @@ public class RepositoryPropertyReferenceControllerIntegrationTests extends Abstr Book book = books.findAll().iterator().next(); - assertThat(controller.followPropertyReference(information, book.id, "creators", assembler).getStatusCode(), - is(HttpStatus.OK)); + assertThat(controller.followPropertyReference(information, book.id, "creators", assembler).getStatusCode()) + .isEqualTo(HttpStatus.OK); } @Test(expected = ResourceNotFoundException.class) diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RootResourceInformationIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RootResourceInformationIntegrationTests.java index aab3742dd..cc55db725 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RootResourceInformationIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RootResourceInformationIntegrationTests.java @@ -26,7 +26,7 @@ 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.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; /** @@ -34,7 +34,7 @@ import org.springframework.transaction.annotation.Transactional; * * @author Oliver Gierke */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration(classes = JpaRepositoryConfig.class) @Transactional public class RootResourceInformationIntegrationTests extends AbstractControllerIntegrationTests { diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest262Tests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest262Tests.java index 9a319a584..ca3a003b2 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest262Tests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest262Tests.java @@ -28,6 +28,7 @@ import javax.validation.constraints.NotNull; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Configuration; @@ -38,14 +39,14 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.repository.CrudRepository; import org.springframework.data.rest.webmvc.PersistentEntityResource; import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; +import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.Link; import org.springframework.hateoas.MediaTypes; -import org.springframework.hateoas.EntityModel; 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.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -60,7 +61,7 @@ import com.jayway.jsonpath.JsonPath; * * @author Oliver Gierke */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration public class DataRest262Tests { diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest363Tests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest363Tests.java index 429a4ff57..d285112fb 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest363Tests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest363Tests.java @@ -22,18 +22,19 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.rest.tests.TestMvcClient; import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; +import org.springframework.hateoas.client.JsonPathLinkDiscoverer; import org.springframework.hateoas.client.LinkDiscoverer; import org.springframework.hateoas.client.LinkDiscoverers; -import org.springframework.hateoas.client.JsonPathLinkDiscoverer; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; @@ -46,7 +47,7 @@ import org.springframework.web.context.WebApplicationContext; * @author Greg Turnquist * @author Oliver Gierke */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @WebAppConfiguration @ContextConfiguration( classes = { JpaRepositoryConfig.class, RepositoryRestMvcConfiguration.class, DataRest363Tests.Config.class }) diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaDefaultPageableWebTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaDefaultPageableWebTests.java index 89941e80c..3c2dd05a8 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaDefaultPageableWebTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaDefaultPageableWebTests.java @@ -41,7 +41,7 @@ import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.Link; import org.springframework.hateoas.LinkRelation; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -52,7 +52,7 @@ import org.springframework.web.bind.annotation.ResponseBody; * * @author Mark Paluch */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @WebAppConfiguration @ContextConfiguration(classes = JpaDefaultPageableWebTests.Config.class) public class JpaDefaultPageableWebTests extends AbstractWebIntegrationTests { diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/Jackson2DatatypeHelperIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/Jackson2DatatypeHelperIntegrationTests.java index 549bda84a..b4b60b23b 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/Jackson2DatatypeHelperIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/Jackson2DatatypeHelperIntegrationTests.java @@ -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.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; @@ -46,7 +46,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; * * @author Oliver Gierke */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration(classes = { JpaRepositoryConfig.class, RepositoryRestMvcConfiguration.class }) @Transactional public class Jackson2DatatypeHelperIntegrationTests { diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java index 1b3fc6afb..3b1eb260e 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java @@ -15,9 +15,7 @@ */ package org.springframework.data.rest.webmvc.json; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.assertj.core.api.Assertions.*; import java.io.IOException; import java.io.StringWriter; @@ -27,6 +25,7 @@ import java.util.Collections; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -40,18 +39,18 @@ import org.springframework.data.repository.support.Repositories; import org.springframework.data.rest.webmvc.PersistentEntityResource; import org.springframework.data.rest.webmvc.jpa.*; import org.springframework.data.rest.webmvc.util.TestUtils; +import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.Link; -import org.springframework.hateoas.client.LinkDiscoverer; import org.springframework.hateoas.LinkRelation; import org.springframework.hateoas.PagedModel; import org.springframework.hateoas.PagedModel.PageMetadata; -import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.client.LinkDiscoverer; +import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer; import org.springframework.hateoas.server.core.EmbeddedWrapper; import org.springframework.hateoas.server.core.EmbeddedWrappers; -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.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletWebRequest; @@ -68,7 +67,7 @@ import com.jayway.jsonpath.JsonPath; * @author Oliver Gierke * @author Alex Leigh */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration(classes = { JpaRepositoryConfig.class, PersistentEntitySerializationTests.TestConfig.class }) @Transactional public class PersistentEntitySerializationTests { @@ -128,8 +127,8 @@ public class PersistentEntitySerializationTests { + " \"created\" : \"2014-01-31T21:07:45.574+0000\"\n" + "}\n"; Person p = mapper.readValue(bilbo, Person.class); - assertThat(p.getFirstName(), equalTo("Bilbo")); - assertThat(p.getLastName(), equalTo("Baggins")); + assertThat(p.getFirstName()).isEqualTo("Bilbo"); + assertThat(p.getLastName()).isEqualTo("Baggins"); } @Test // DATAREST-238 diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinksIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinksIntegrationTests.java index 9f403fe44..1fbb5230d 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinksIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinksIntegrationTests.java @@ -15,12 +15,10 @@ */ package org.springframework.data.rest.webmvc.support; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.*; -import static org.hamcrest.Matchers.allOf; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.*; import org.junit.Test; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; @@ -53,7 +51,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt Link link = entityLinks.linkToItemResource(Person.class, 1); - assertThat(link.getHref(), endsWith("/people/1{?projection}")); + assertThat(link.getHref()).endsWith("/people/1{?projection}"); assertThat(link.getRel()).isEqualTo(LinkRelation.of("person")); } @@ -80,7 +78,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt public void usesCustomGeneratedBackendId() { Link link = entityLinks.linkToItemResource(Book.class, 7L); - assertThat(link.expand().getHref(), endsWith("/7-7-7-7-7-7-7")); + assertThat(link.expand().getHref()).endsWith("/7-7-7-7-7-7-7"); } @Test // DATAREST-317 @@ -126,7 +124,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt assertThat(link.getVariableNames()).doesNotContain("page", "size"); UriComponents components = UriComponentsBuilder.fromUriString(link.getHref()).build(); - assertThat(components.getQueryParams(), allOf(hasKey("page"), hasKey("size"))); + assertThat(components.getQueryParams()).containsKey("page").containsKey("size"); } @Test // DATAREST-467 @@ -149,7 +147,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt assertThat(link.getVariableNames()).doesNotContain("sort"); UriComponents components = UriComponentsBuilder.fromUriString(link.getHref()).build(); - assertThat(components.getQueryParams(), hasKey("sort")); + assertThat(components.getQueryParams()).containsKey("sort"); } @Test // DATAREST-668, DATAREST-519, DATAREST-467 diff --git a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/config/AbstractRepositoryRestMvcConfigurationIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/config/AbstractRepositoryRestMvcConfigurationIntegrationTests.java index 7be61c53f..fef7649f4 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/config/AbstractRepositoryRestMvcConfigurationIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/config/AbstractRepositoryRestMvcConfigurationIntegrationTests.java @@ -18,7 +18,7 @@ package org.springframework.data.rest.webmvc.config; import org.junit.Before; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; @@ -29,7 +29,7 @@ import org.springframework.web.context.WebApplicationContext; * * @author Oliver Gierke */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @WebAppConfiguration public abstract class AbstractRepositoryRestMvcConfigurationIntegrationTests { diff --git a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java index 58149a1c7..a21867ab7 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java @@ -15,9 +15,7 @@ */ package org.springframework.data.rest.webmvc.json; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.assertj.core.api.Assertions.*; import java.util.Arrays; import java.util.HashMap; @@ -25,6 +23,7 @@ import java.util.HashMap; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -42,13 +41,13 @@ import org.springframework.data.rest.tests.mongodb.User.Nested; import org.springframework.data.rest.tests.mongodb.UserRepository; import org.springframework.data.rest.webmvc.PersistentEntityResource; import org.springframework.hateoas.Link; -import org.springframework.hateoas.client.LinkDiscoverer; import org.springframework.hateoas.PagedModel; import org.springframework.hateoas.PagedModel.PageMetadata; +import org.springframework.hateoas.client.LinkDiscoverer; 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.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletWebRequest; @@ -62,7 +61,7 @@ import com.jayway.jsonpath.JsonPath; * @author Greg Turnquist * @author Oliver Gierke */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration(classes = { MongoDbRepositoryConfig.class, RepositoryTestsConfig.class, PersistentEntitySerializationTests.TestConfig.class }) public class PersistentEntitySerializationTests { @@ -133,6 +132,6 @@ public class PersistentEntitySerializationTests { .build(dave, repositories.getPersistentEntity(User.class)).build(); assertThat(JsonPath.parse(mapper.writeValueAsString(resource)).read("$.colleaguesMap.carter._links.user.href", - String.class), is(notNullValue())); + String.class)).isNotNull(); } } diff --git a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntityToJsonSchemaConverterUnitTests.java b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntityToJsonSchemaConverterUnitTests.java index 54a9b363b..f7dc281cd 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntityToJsonSchemaConverterUnitTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntityToJsonSchemaConverterUnitTests.java @@ -48,7 +48,7 @@ import org.springframework.data.rest.webmvc.json.PersistentEntityToJsonSchemaCon import org.springframework.data.rest.webmvc.json.PersistentEntityToJsonSchemaConverterUnitTests.TestConfiguration; import org.springframework.data.rest.webmvc.mapping.Associations; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -59,7 +59,7 @@ import com.jayway.jsonpath.PathNotFoundException; * @author Oliver Gierke * @author Greg Turnquist */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration(classes = { MongoDbRepositoryConfig.class, TestConfiguration.class }) public class PersistentEntityToJsonSchemaConverterUnitTests { diff --git a/spring-data-rest-tests/spring-data-rest-tests-security/src/test/java/org/springframework/data/rest/tests/security/SecurityIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-security/src/test/java/org/springframework/data/rest/tests/security/SecurityIntegrationTests.java index 6fd262c34..b1b504ffa 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-security/src/test/java/org/springframework/data/rest/tests/security/SecurityIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-security/src/test/java/org/springframework/data/rest/tests/security/SecurityIntegrationTests.java @@ -36,7 +36,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio import org.springframework.security.core.authority.AuthorityUtils; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; @@ -48,7 +48,7 @@ import org.springframework.web.context.WebApplicationContext; * @author Greg Turnquist * @author Rob Winch */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration(classes = { SecurityIntegrationTests.Config.class, SecurityConfiguration.class, RepositoryRestMvcConfiguration.class }) public class SecurityIntegrationTests extends AbstractWebIntegrationTests { @@ -101,10 +101,8 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests { // Getting the collection is not tested here. This is to get the URI that will later be tested for DELETE final String people = client.discoverUnique("people").expand().getHref(); - MockHttpServletResponse response = mvc - .perform(get(people).// - with(user("user").roles("USER"))) - .// + MockHttpServletResponse response = mvc.perform(get(people).// + with(user("user").roles("USER"))).// andReturn().getResponse(); String href = assertHasJsonPathValue("$._embedded.people[0]._links.self.href", response); @@ -117,10 +115,8 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests { @Test // DATAREST-327 public void deletePersonAccessDeniedForUsers() throws Exception { - MockHttpServletResponse response = mvc - .perform(get(client.discoverUnique("people").expand().getHref()).// - with(user("user").roles("USER"))) - .// + MockHttpServletResponse response = mvc.perform(get(client.discoverUnique("people").expand().getHref()).// + with(user("user").roles("USER"))).// andReturn().getResponse(); String href = assertHasJsonPathValue("$._embedded.people[0]._links.self.href", response); @@ -134,10 +130,8 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests { @Test // DATAREST-327 public void deletePersonAccessGrantedForAdmins() throws Exception { - MockHttpServletResponse response = mvc - .perform(get(client.discoverUnique("people").expand().getHref()).// - with(user("user").roles("USER", "ADMIN"))) - .// + MockHttpServletResponse response = mvc.perform(get(client.discoverUnique("people").expand().getHref()).// + with(user("user").roles("USER", "ADMIN"))).// andReturn().getResponse(); String href = assertHasJsonPathValue("$._embedded.people[0]._links.self.href", response); @@ -175,10 +169,8 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests { public void deleteOrderAccessDeniedForNoCredentials() throws Exception { // Getting the collection is not tested here. This is to get the URI that will later be tested for DELETE - MockHttpServletResponse response = mvc - .perform(get(client.discoverUnique("orders").expand().getHref()).// - with(user("user").roles("USER"))) - .// + MockHttpServletResponse response = mvc.perform(get(client.discoverUnique("orders").expand().getHref()).// + with(user("user").roles("USER"))).// andReturn().getResponse(); String href = assertHasJsonPathValue("$._embedded.orders[0]._links.self.href", response); @@ -191,10 +183,8 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests { @Test // DATAREST-327 public void deleteOrderAccessDeniedForUsers() throws Exception { - MockHttpServletResponse response = mvc - .perform(get(client.discoverUnique("orders").expand().getHref()).// - with(user("user").roles("USER"))) - .// + MockHttpServletResponse response = mvc.perform(get(client.discoverUnique("orders").expand().getHref()).// + with(user("user").roles("USER"))).// andReturn().getResponse(); String href = assertHasJsonPathValue("$._embedded.orders[0]._links.self.href", response); @@ -205,10 +195,8 @@ public class SecurityIntegrationTests extends AbstractWebIntegrationTests { @Test // DATAREST-327 public void deleteOrderAccessGrantedForAdmins() throws Exception { - MockHttpServletResponse response = mvc - .perform(get(client.discoverUnique("orders").expand().getHref()).// - with(user("user").roles("USER"))) - .// + MockHttpServletResponse response = mvc.perform(get(client.discoverUnique("orders").expand().getHref()).// + with(user("user").roles("USER"))).// andReturn().getResponse(); String href = assertHasJsonPathValue("$._embedded.orders[0]._links.self.href", response); diff --git a/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopIntegrationTests.java index 13fc168d1..068db1547 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopIntegrationTests.java @@ -26,7 +26,7 @@ import org.junit.runner.RunWith; import org.springframework.data.rest.tests.AbstractWebIntegrationTests; import org.springframework.hateoas.Link; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.ResultActions; import com.jayway.jsonpath.JsonPath; @@ -37,7 +37,7 @@ import com.jayway.jsonpath.JsonPath; * @author Oliver Gierke * @author Craig Andrews */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration(classes = ShopConfiguration.class) public class ShopIntegrationTests extends AbstractWebIntegrationTests { diff --git a/spring-data-rest-tests/spring-data-rest-tests-solr/src/test/java/org/springframework/data/rest/webmvc/solr/SolrInfrastructureConfig.java b/spring-data-rest-tests/spring-data-rest-tests-solr/src/test/java/org/springframework/data/rest/webmvc/solr/SolrInfrastructureConfig.java index babafa8ea..56a7477d6 100644 --- a/spring-data-rest-tests/spring-data-rest-tests-solr/src/test/java/org/springframework/data/rest/webmvc/solr/SolrInfrastructureConfig.java +++ b/spring-data-rest-tests/spring-data-rest-tests-solr/src/test/java/org/springframework/data/rest/webmvc/solr/SolrInfrastructureConfig.java @@ -40,7 +40,7 @@ import org.springframework.core.io.Resource; import org.springframework.data.solr.core.SolrTemplate; import org.springframework.data.solr.server.SolrClientFactory; import org.springframework.data.solr.server.support.EmbeddedSolrServerFactory; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.FileCopyUtils; import org.springframework.util.StringUtils; import org.xml.sax.SAXException; @@ -106,9 +106,8 @@ public class SolrInfrastructureConfig { } /** - * {@link SpringJUnit4ClassRunner} executes {@link ClassRule}s before the actual shutdown of the - * {@link ApplicationContext}. This causes the {@link TemporaryFolder} to vanish before Solr can gracefully shutdown. - *
+ * {@link SpringRunner} executes {@link ClassRule}s before the actual shutdown of the {@link ApplicationContext}. This + * causes the {@link TemporaryFolder} to vanish before Solr can gracefully shutdown.
* To prevent error messages popping up we register a {@link CloseHook} re adding the index directory and removing it * after {@link SolrCore#close()}. * diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java index 5ae638ed4..6ced5d44a 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java @@ -15,9 +15,7 @@ */ package org.springframework.data.rest.webmvc; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.*; import java.net.URI; @@ -42,7 +40,7 @@ public class BaseUriUnitTests { BaseUri uri = new BaseUri(URI.create("foo")); - assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString()); + assertThat(uri.getRepositoryLookupPath("/foo")).isEmpty(); } @Test // DATAREST-276 @@ -50,8 +48,8 @@ public class BaseUriUnitTests { BaseUri uri = new BaseUri(URI.create("foo/")); - assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString()); - assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString()); + assertThat(uri.getRepositoryLookupPath("/foo")).isEmpty(); + assertThat(uri.getRepositoryLookupPath("/foo/")).isEmpty(); } @Test // DATAREST-276 @@ -59,8 +57,8 @@ public class BaseUriUnitTests { BaseUri uri = new BaseUri(URI.create("/foo")); - assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString()); - assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString()); + assertThat(uri.getRepositoryLookupPath("/foo")).isEmpty(); + assertThat(uri.getRepositoryLookupPath("/foo/")).isEmpty(); } @Test // DATAREST-276 @@ -68,8 +66,8 @@ public class BaseUriUnitTests { BaseUri uri = new BaseUri(URI.create("http://localhost:8080/foo/")); - assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString()); - assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString()); + assertThat(uri.getRepositoryLookupPath("/foo")).isEmpty(); + assertThat(uri.getRepositoryLookupPath("/foo/")).isEmpty(); assertThat(uri.getRepositoryLookupPath("/foo/people")).isEqualTo("/people"); assertThat(uri.getRepositoryLookupPath("/foo/people/")).isEqualTo("/people"); } diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/CustomAcceptHeaderHttpServletRequestUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/CustomAcceptHeaderHttpServletRequestUnitTests.java index 62b69b830..1d4a5c4af 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/CustomAcceptHeaderHttpServletRequestUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/CustomAcceptHeaderHttpServletRequestUnitTests.java @@ -15,9 +15,7 @@ */ package org.springframework.data.rest.webmvc; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.*; import java.util.Arrays; import java.util.Collections; @@ -26,6 +24,7 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import org.junit.Test; + import org.springframework.data.rest.webmvc.BasePathAwareHandlerMapping.CustomAcceptHeaderHttpServletRequest; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -48,8 +47,8 @@ public class CustomAcceptHeaderHttpServletRequestUnitTests { List mediaTypes = Arrays.asList(MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_ATOM_XML); HttpServletRequest servletRequest = new CustomAcceptHeaderHttpServletRequest(request, mediaTypes); - assertThat(servletRequest.getHeader(HttpHeaders.ACCEPT), - is(StringUtils.collectionToCommaDelimitedString(mediaTypes))); + assertThat(servletRequest.getHeader(HttpHeaders.ACCEPT)) + .isEqualTo(StringUtils.collectionToCommaDelimitedString(mediaTypes)); List expected = Collections.list(servletRequest.getHeaders(HttpHeaders.ACCEPT)); diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/HttpEntityMatcher.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/HttpEntityMatcher.java deleted file mode 100644 index 1be15b70a..000000000 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/HttpEntityMatcher.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.springframework.data.rest.webmvc; - -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; -import org.springframework.http.HttpEntity; -import org.springframework.http.ResponseEntity; -import org.springframework.util.Assert; - -/** - * @author Jon Brisbin - */ -class HttpEntityMatcher extends BaseMatcher> { - - private final HttpEntity expected; - - public HttpEntityMatcher(HttpEntity expected) { - Assert.notNull(expected, "HttpEntity cannot be null"); - this.expected = expected; - } - - public static HttpEntityMatcher httpEntity(HttpEntity httpEntity) { - return new HttpEntityMatcher(httpEntity); - } - - @Override - public boolean matches(Object item) { - if (!(item instanceof HttpEntity)) { - return false; - } - - if (item instanceof ResponseEntity && expected instanceof ResponseEntity) { - ResponseEntity left = (ResponseEntity) expected; - ResponseEntity right = (ResponseEntity) item; - - if (!left.getStatusCode().equals(right.getStatusCode())) { - return false; - } - } - - HttpEntity left = expected; - HttpEntity right = (HttpEntity) item; - - return left.getBody().equals(right.getBody()) && left.getHeaders().equals(right.getHeaders()); - } - - @Override - public void describeTo(Description description) { - description.appendText(expected.toString()); - } - -} diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryCorsConfigurationAccessorUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryCorsConfigurationAccessorUnitTests.java index 5b5549be3..d4574b1a2 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryCorsConfigurationAccessorUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryCorsConfigurationAccessorUnitTests.java @@ -15,9 +15,7 @@ */ package org.springframework.data.rest.webmvc; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; import java.util.Optional; @@ -27,6 +25,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; + import org.springframework.data.repository.support.Repositories; import org.springframework.data.rest.core.mapping.ResourceMappings; import org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping.NoOpStringValueResolver; @@ -66,8 +65,8 @@ public class RepositoryCorsConfigurationAccessorUnitTests { assertThat(configuration.getAllowCredentials()).isFalse(); assertThat(configuration.getAllowedHeaders()).contains("*"); assertThat(configuration.getAllowedOrigins()).contains("*"); - assertThat(configuration.getAllowedMethods(), - hasItems("OPTIONS", "HEAD", "GET", "PATCH", "POST", "PUT", "DELETE", "TRACE")); + assertThat(configuration.getAllowedMethods()).contains("OPTIONS", "HEAD", "GET", "PATCH", "POST", "PUT", "DELETE", + "TRACE"); assertThat(configuration.getMaxAge()).isEqualTo(1800L); } diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/DomainObjectReaderUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/DomainObjectReaderUnitTests.java index 6b62ccd94..55fe8bd6b 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/DomainObjectReaderUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/DomainObjectReaderUnitTests.java @@ -16,9 +16,7 @@ package org.springframework.data.rest.webmvc.json; import static com.fasterxml.jackson.annotation.JsonProperty.Access.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; import lombok.AllArgsConstructor; @@ -38,6 +36,7 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; + import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Immutable; @@ -210,9 +209,9 @@ public class DomainObjectReaderUnitTests { SampleUser result = reader.readPut(node, sampleUser, mapper); - assertThat(result.name, is("another")); - assertThat(result.password, notNullValue()); - assertThat(result.lastLogin, notNullValue()); + assertThat(result.name).isEqualTo("another"); + assertThat(result.password).isNotNull(); + assertThat(result.lastLogin).isNotNull(); } @Test // DATAREST-873 @@ -487,7 +486,7 @@ public class DomainObjectReaderUnitTests { CollectionOfEnumWithMethods result = reader.merge((ObjectNode) node, sample, mapper); - assertThat(result.enums, contains(SampleEnum.SECOND, SampleEnum.FIRST)); + assertThat(result.enums).containsExactly(SampleEnum.SECOND, SampleEnum.FIRST); } @Test // DATAREST-944 diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/JacksonSerializersUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/JacksonSerializersUnitTests.java index 8e249c8c0..32b9f3ddc 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/JacksonSerializersUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/JacksonSerializersUnitTests.java @@ -15,9 +15,7 @@ */ package org.springframework.data.rest.webmvc.json; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; import java.util.Collection; @@ -25,6 +23,7 @@ import java.util.Map; import org.junit.Before; import org.junit.Test; + import org.springframework.data.rest.webmvc.json.JacksonSerializersUnitTests.Sample.SampleEnum; import com.fasterxml.jackson.databind.ObjectMapper; @@ -70,7 +69,7 @@ public class JacksonSerializersUnitTests { Sample result = mapper.readValue("{ \"array\" : [ \"value\" ] }", Sample.class); - assertThat(result.array, hasItemInArray(SampleEnum.VALUE)); + assertThat(result.array).contains(SampleEnum.VALUE); } @Test // DATAREST-929