#980 - Migrate to JUnit 5.

This commit is contained in:
Greg Turnquist
2019-04-08 11:50:30 -05:00
parent a0937f7c28
commit 3a8b37b42a
94 changed files with 544 additions and 467 deletions

27
pom.xml
View File

@@ -78,6 +78,7 @@
<java-module-name>spring.hateoas</java-module-name>
<jsonpath.version>2.2.0</jsonpath.version>
<jsr305.version>3.0.2</jsr305.version>
<junit.version>5.3.2</junit.version>
<minidevjson.version>2.2.1</minidevjson.version>
<reactor-bom.version>Californium-SR4</reactor-bom.version>
<slf4j.version>1.7.25</slf4j.version>
@@ -418,6 +419,13 @@
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
@@ -548,9 +556,14 @@
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
@@ -563,7 +576,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
@@ -587,6 +600,12 @@
<artifactId>jadler-all</artifactId>
<version>1.3.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* @author Oliver Drotbohm

View File

@@ -18,7 +18,7 @@ package org.springframework.hateoas;
import java.io.StringWriter;
import java.io.Writer;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -33,7 +33,7 @@ public abstract class AbstractJackson2MarshallingIntegrationTest {
protected ObjectMapper mapper;
@Before
@BeforeEach
public void setUp() {
mapper = new ObjectMapper();
}

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.hateoas;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link CollectionModel}.

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;

View File

@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link EntityModel}.
@@ -66,8 +66,11 @@ public class EntityModelUnitTest {
assertThat(right).isNotEqualTo(left);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsCollectionContent() {
new EntityModel<Object>(Collections.emptyList());
assertThatIllegalArgumentException().isThrownBy(() -> {
new EntityModel<Object>(Collections.emptyList());
});
}
}

View File

@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
import lombok.Value;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* @author Greg Turnquist

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Integration tests for {@link org.springframework.hateoas.Link} marshaling.

View File

@@ -16,7 +16,7 @@
package org.springframework.hateoas;
import static org.assertj.core.api.Assertions.*;
import static org.hamcrest.CoreMatchers.*;
import static org.assertj.core.api.Assumptions.*;
import static org.mockito.Mockito.*;
import java.io.StringWriter;
@@ -25,8 +25,7 @@ import java.lang.reflect.Type;
import java.util.Collections;
import org.apache.commons.io.output.WriterOutputStream;
import org.junit.Assume;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpOutputMessage;
@@ -59,7 +58,7 @@ public class Jackson2PagedResourcesIntegrationTest {
@Test
public void serializesPagedResourcesCorrectly() throws Exception {
Assume.assumeThat(SPRING_4_2_WRITE_METHOD, is(notNullValue()));
assumeThat(SPRING_4_2_WRITE_METHOD).isNotNull();
User user = new User();
user.firstname = "Dave";

View File

@@ -2,7 +2,7 @@ package org.springframework.hateoas;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonAutoDetect;

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Integration tests for {@link org.springframework.hateoas.RepresentationModel}.

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Integration tests for {@link Link} marshaling.

View File

@@ -23,7 +23,7 @@ import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* @author Greg Turnquist

View File

@@ -24,7 +24,7 @@ import java.net.URI;
import java.util.Collections;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.ResolvableType;
import org.springframework.hateoas.support.Employee;
import org.springframework.http.HttpMethod;
@@ -59,25 +59,37 @@ public class LinkUnitTest {
}
@SuppressWarnings("null")
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullHref() {
new Link(null);
assertThatIllegalArgumentException().isThrownBy(() -> {
new Link(null);
});
}
@SuppressWarnings("null")
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullRel() {
new Link("foo", (String) null);
assertThatIllegalArgumentException().isThrownBy(() -> {
new Link("foo", (String) null);
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsEmptyHref() {
new Link("");
assertThatIllegalArgumentException().isThrownBy(() -> {
new Link("");
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsEmptyRel() {
new Link("foo", "");
assertThatIllegalArgumentException().isThrownBy(() -> {
new Link("foo", "");
});
}
@Test
@@ -160,19 +172,28 @@ public class LinkUnitTest {
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsMissingRelAttribute() {
Link.valueOf("</something>;title=\"title\"");
assertThatIllegalArgumentException().isThrownBy(() -> {
Link.valueOf("</something>;title=\"title\"");
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsLinkWithoutAttributesAtAll() {
Link.valueOf("</something>");
assertThatIllegalArgumentException().isThrownBy(() -> {
Link.valueOf("</something>");
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNonRFC5988String() {
Link.valueOf("foo");
assertThatIllegalArgumentException().isThrownBy(() -> {
Link.valueOf("foo");
});
}
/**

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Arrays;
import java.util.Optional;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.util.StringUtils;
/**

View File

@@ -19,8 +19,8 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.PagedModel.PageMetadata;
/**
@@ -34,7 +34,7 @@ public class PagedModelUnitTest {
PagedModel<Object> resources;
@Before
@BeforeEach
public void setUp() {
resources = new PagedModel<>(Collections.emptyList(), metadata);
}
@@ -58,33 +58,45 @@ public class PagedModelUnitTest {
/**
* @see #89
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsNegativePageSize() {
new PageMetadata(-1, 0, 0);
assertThatIllegalArgumentException().isThrownBy(() -> {
new PageMetadata(-1, 0, 0);
});
}
/**
* @see #89
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsNegativePageNumber() {
new PageMetadata(0, -1, 0);
assertThatIllegalArgumentException().isThrownBy(() -> {
new PageMetadata(0, -1, 0);
});
}
/**
* @see #89
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsNegativeTotalElements() {
new PageMetadata(0, 0, -1);
assertThatIllegalArgumentException().isThrownBy(() -> {
new PageMetadata(0, 0, -1);
});
}
/**
* @see #89
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsNegativeTotalPages() {
new PageMetadata(0, 0, 0, -1);
assertThatIllegalArgumentException().isThrownBy(() -> {
new PageMetadata(0, 0, 0, -1);
});
}
/**

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Integration tests for {@link RepresentationModel}.

View File

@@ -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;
/**
* Unit tests for {@link RepresentationModel}.
@@ -82,17 +82,22 @@ public class RepresentationModelUnitTest {
assertThat(support.getLinks(IanaLinkRelations.NEXT.value())).contains(second);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsNullLinkBeingAdded() {
RepresentationModel<?> support = new RepresentationModel<>();
support.add((Link) null);
assertThatIllegalArgumentException().isThrownBy(() -> {
RepresentationModel<?> support = new RepresentationModel<>();
support.add((Link) null);
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsNullLinksBeingAdded() {
RepresentationModel<?> support = new RepresentationModel<>();
support.add((Iterable<Link>) null);
assertThatIllegalArgumentException().isThrownBy(() -> {
RepresentationModel<?> support = new RepresentationModel<>();
support.add((Iterable<Link>) null);
});
}
@Test

View File

@@ -22,7 +22,7 @@ import lombok.Data;
import java.util.Collections;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.server.SimpleRepresentationModelAssembler;
/**

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;

View File

@@ -20,7 +20,7 @@ import static org.springframework.hateoas.TemplateVariable.VariableType.*;
import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.TemplateVariable.VariableType;
/**
@@ -174,32 +174,44 @@ public class TemplateVariablesUnitTest {
/**
* @see #228
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void variableRejectsEmptyName() {
new TemplateVariable("", PATH_VARIABLE);
assertThatIllegalArgumentException().isThrownBy(() -> {
new TemplateVariable("", PATH_VARIABLE);
});
}
/**
* @see #228
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void variableRejectsNullName() {
new TemplateVariable(null, PATH_VARIABLE);
assertThatIllegalArgumentException().isThrownBy(() -> {
new TemplateVariable(null, PATH_VARIABLE);
});
}
/**
* @see #228
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void variableRejectsNullType() {
new TemplateVariable("foo", null);
assertThatIllegalArgumentException().isThrownBy(() -> {
new TemplateVariable("foo", null);
});
}
/**
* @see #228
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void variableRejectsNullDescription() {
new TemplateVariable("foo", PATH_VARIABLE, null);
assertThatIllegalArgumentException().isThrownBy(() -> {
new TemplateVariable("foo", PATH_VARIABLE, null);
});
}
}

View File

@@ -22,7 +22,7 @@ import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.mock.web.MockFilterChain;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -40,7 +40,7 @@ public class TestUtils {
protected MockHttpServletRequest request;
@Before
@BeforeEach
public void setUp() {
request = new MockHttpServletRequest();

View File

@@ -26,7 +26,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.TemplateVariable.VariableType;
/**
@@ -147,11 +147,13 @@ public class UriTemplateUnitTest {
/**
* @see #137
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsMissingRequiredPathVariable() {
UriTemplate template = UriTemplate.of("/foo/{bar}");
template.expand(Collections.emptyMap());
assertThatIllegalArgumentException().isThrownBy(() -> {
UriTemplate template = UriTemplate.of("/foo/{bar}");
template.expand(Collections.emptyMap());
});
}
/**
@@ -246,9 +248,12 @@ public class UriTemplateUnitTest {
/**
* @see #273
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsEmptyBaseUri() {
new UriTemplate(null, TemplateVariables.NONE);
assertThatIllegalArgumentException().isThrownBy(() -> {
new UriTemplate(null, TemplateVariables.NONE);
});
}
/**

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link Hop}.
@@ -33,17 +33,23 @@ public class HopUnitTest {
/**
* @see #346
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullRelationName() {
Hop.rel(null);
assertThatIllegalArgumentException().isThrownBy(() -> {
Hop.rel(null);
});
}
/**
* @see #346
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsEmptyRelationName() {
Hop.rel("");
assertThatIllegalArgumentException().isThrownBy(() -> {
Hop.rel("");
});
}
/**

View File

@@ -22,7 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.Links;

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas.client;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.Ordered;
import org.springframework.http.MediaType;
import org.springframework.plugin.core.PluginRegistry;
@@ -30,9 +30,12 @@ import org.springframework.plugin.core.PluginRegistry;
*/
public class LinkDiscoverersUnitTest {
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullPluginRegistry() {
new LinkDiscoverers(null);
assertThatIllegalArgumentException().isThrownBy(() -> {
new LinkDiscoverers(null);
});
}
@Test

View File

@@ -15,12 +15,10 @@
*/
package org.springframework.hateoas.client;
import static net.jadler.Jadler.verifyThatRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.startsWith;
import static org.springframework.hateoas.client.Hop.rel;
import static net.jadler.Jadler.*;
import static org.assertj.core.api.Assertions.*;
import static org.hamcrest.Matchers.*;
import static org.springframework.hateoas.client.Hop.*;
import java.io.IOException;
import java.net.URI;
@@ -30,10 +28,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link;
@@ -48,6 +46,8 @@ import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.test.context.event.annotation.AfterTestClass;
import org.springframework.test.context.event.annotation.BeforeTestClass;
import org.springframework.web.client.RestTemplate;
/**
@@ -65,7 +65,7 @@ public class TraversonTest {
Traverson traverson;
@BeforeClass
@BeforeAll
public static void setUpClass() {
server = new Server();
@@ -74,13 +74,13 @@ public class TraversonTest {
setUpActors();
}
@Before
@BeforeEach
public void setUp() {
this.traverson = new Traverson(baseUri, MediaTypes.HAL_JSON_UTF8, MediaTypes.HAL_JSON);
}
@AfterClass
@AfterAll
public static void tearDown() throws IOException {
if (server != null) {
@@ -91,17 +91,23 @@ public class TraversonTest {
/**
* @see #131
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullBaseUri() {
new Traverson(null, MediaTypes.HAL_JSON);
assertThatIllegalArgumentException().isThrownBy(() -> {
new Traverson(null, MediaTypes.HAL_JSON);
});
}
/**
* @see #131
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsEmptyMediaTypes() {
new Traverson(baseUri);
assertThatIllegalArgumentException().isThrownBy(() -> {
new Traverson(baseUri);
});
}
/**

View File

@@ -19,12 +19,11 @@ import static org.springframework.hateoas.server.reactive.WebFluxLinkBuilder.*;
import static org.springframework.hateoas.support.CustomHypermediaType.*;
import static org.springframework.hateoas.support.MappingUtils.*;
import reactor.core.publisher.Mono;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -45,7 +44,7 @@ public class CustomHypermediaWebFluxTest {
WebTestClient testClient;
@Before
@BeforeEach
public void setUp() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();

View File

@@ -23,9 +23,9 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
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;
@@ -36,7 +36,7 @@ import org.springframework.hateoas.support.CustomHypermediaType;
import org.springframework.hateoas.support.Employee;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.bind.annotation.GetMapping;
@@ -49,7 +49,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
*
* @author Greg Turnquist
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class CustomHypermediaWebMvcTest {
@@ -57,7 +57,7 @@ public class CustomHypermediaWebMvcTest {
private @Autowired WebApplicationContext context;
private MockMvc mockMvc;
@Before
@BeforeEach
public void setUp() {
this.mockMvc = webAppContextSetup(this.context).build();
}

View File

@@ -17,8 +17,8 @@ package org.springframework.hateoas.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -26,7 +26,7 @@ import org.springframework.hateoas.server.ExposesResourceFor;
import org.springframework.hateoas.server.core.DelegatingEntityLinks;
import org.springframework.stereotype.Controller;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.bind.annotation.RequestMapping;
/**
@@ -34,7 +34,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
*
* @author Oliver Gierke
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration
public class EnableEntityLinksIntegrationTest {

View File

@@ -24,9 +24,9 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -70,7 +70,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
* @author Oliver Gierke
* @author Greg Turnquist
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class EnableHypermediaSupportIntegrationTest {
@Test

View File

@@ -21,7 +21,7 @@ import static org.springframework.hateoas.support.ContextTester.*;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonLinkDiscoverer;
import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer;

View File

@@ -22,11 +22,10 @@ import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.support.CustomHypermediaType;
import org.springframework.http.MediaType;

View File

@@ -22,20 +22,19 @@ import reactor.test.StepVerifier;
import java.net.URI;
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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.RepresentationModel;
import org.springframework.hateoas.client.Actor;
import org.springframework.hateoas.client.Movie;
import org.springframework.hateoas.client.Server;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.server.core.TypeReferences.EntityModelType;
import org.springframework.web.reactive.function.client.WebClient;
@@ -50,7 +49,7 @@ public class HypermediaWebClientBeanPostProcessorTest {
private URI baseUri;
private Server server;
@Before
@BeforeEach
public void setUp() {
this.server = new Server();
@@ -68,7 +67,7 @@ public class HypermediaWebClientBeanPostProcessorTest {
this.baseUri = URI.create(this.server.rootResource());
}
@After
@AfterEach
public void tearDown() {
if (this.server != null) {

View File

@@ -27,7 +27,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ClassPathXmlApplicationContext;

View File

@@ -21,12 +21,11 @@ import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Optional;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.client.LinkDiscovererUnitTest;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.mediatype.alps.AlpsLinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscovererUnitTest;
import org.springframework.util.StreamUtils;
/**

View File

@@ -22,14 +22,10 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.hateoas.mediatype.alps.Alps;
import org.springframework.hateoas.mediatype.alps.Doc;
import org.springframework.hateoas.mediatype.alps.Format;
import org.springframework.hateoas.mediatype.alps.Type;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -45,7 +41,7 @@ public class JacksonSerializationTest {
ObjectMapper mapper;
@Before
@BeforeEach
public void setUp() {
mapper = new ObjectMapper();

View File

@@ -20,12 +20,11 @@ import static org.assertj.core.api.Assertions.*;
import java.io.IOException;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonLinkDiscoverer;
import org.springframework.hateoas.support.MappingUtils;
/**
@@ -38,7 +37,7 @@ public class CollectionJsonLinkDiscovererUnitTest {
LinkDiscoverer discoverer;
@Before
@BeforeEach
public void setUp() {
this.discoverer = new CollectionJsonLinkDiscoverer();
}

View File

@@ -23,8 +23,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.EntityModel;
@@ -49,7 +49,7 @@ public class CollectionJsonSpecTest {
ObjectMapper mapper;
@Before
@BeforeEach
public void setUp() {
mapper = new ObjectMapper();

View File

@@ -20,9 +20,9 @@ import static org.hamcrest.collection.IsCollectionWithSize.*;
import static org.springframework.hateoas.support.JsonPathUtils.*;
import static org.springframework.hateoas.support.MappingUtils.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -30,12 +30,12 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.WebClientConfigurer;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.config.WebClientConfigurer;
import org.springframework.hateoas.support.WebFluxEmployeeController;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.web.reactive.config.EnableWebFlux;
@@ -43,14 +43,14 @@ import org.springframework.web.reactive.config.EnableWebFlux;
/**
* @author Greg Turnquist
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class CollectionJsonWebFluxIntegrationTest {
@Autowired WebTestClient testClient;
@Before
@BeforeEach
public void setUp() {
WebFluxEmployeeController.reset();
}

View File

@@ -28,9 +28,9 @@ import java.util.List;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -48,7 +48,7 @@ import org.springframework.hateoas.support.WebMvcEmployeeController;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.bind.annotation.GetMapping;
@@ -65,7 +65,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/**
* @author Greg Turnquist
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class CollectionJsonWebMvcIntegrationTest {
@@ -74,7 +74,7 @@ public class CollectionJsonWebMvcIntegrationTest {
MockMvc mockMvc;
@Before
@BeforeEach
public void setUp() {
this.mockMvc = webAppContextSetup(this.context).build();

View File

@@ -25,8 +25,8 @@ import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.AbstractJackson2MarshallingIntegrationTest;
import org.springframework.hateoas.CollectionModel;
@@ -54,7 +54,7 @@ public class Jackson2CollectionJsonIntegrationTest extends AbstractJackson2Marsh
new Link("foo", IanaLinkRelations.NEXT), //
new Link("bar", IanaLinkRelations.PREV));
@Before
@BeforeEach
public void setUpModule() {
mapper.registerModule(new Jackson2CollectionJsonModule());

View File

@@ -15,19 +15,16 @@
*/
package org.springframework.hateoas.mediatype.collectionjson;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.mediatype.collectionjson.CollectionJson;
import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonItem;
import org.springframework.hateoas.mediatype.collectionjson.Jackson2CollectionJsonModule;
import org.springframework.hateoas.support.MappingUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -40,7 +37,7 @@ public class JacksonSerializationTest {
ObjectMapper mapper;
@Before
@BeforeEach
public void setUp() {
mapper = new ObjectMapper();
@@ -64,6 +61,6 @@ public class JacksonSerializationTest {
String actual = mapper.writeValueAsString(collection);
assertThat(actual, is(MappingUtils.read(new ClassPathResource("reference.json", getClass()))));
assertThat(actual).isEqualTo(MappingUtils.read(new ClassPathResource("reference.json", getClass())));
}
}

View File

@@ -21,7 +21,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkRelation;
@@ -45,30 +45,45 @@ public class DefaultCurieProviderUnitTest {
CurieProvider provider = new DefaultCurieProvider("acme", URI_TEMPLATE);
@SuppressWarnings("null")
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsNullCurieName() {
new DefaultCurieProvider(null, URI_TEMPLATE);
assertThatIllegalArgumentException().isThrownBy(() -> {
new DefaultCurieProvider(null, URI_TEMPLATE);
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsEmptyCurieName() {
new DefaultCurieProvider("", URI_TEMPLATE);
assertThatIllegalArgumentException().isThrownBy(() -> {
new DefaultCurieProvider("", URI_TEMPLATE);
});
}
@SuppressWarnings("null")
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsNullUriTemplateName() {
new DefaultCurieProvider("acme", null);
assertThatIllegalArgumentException().isThrownBy(() -> {
new DefaultCurieProvider("acme", null);
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsUriTemplateWithoutVariable() {
new DefaultCurieProvider("acme", UriTemplate.of("http://localhost:8080/rels"));
assertThatIllegalArgumentException().isThrownBy(() -> {
new DefaultCurieProvider("acme", UriTemplate.of("http://localhost:8080/rels"));
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsUriTemplateWithMoreThanOneVariable() {
new DefaultCurieProvider("acme", UriTemplate.of("http://localhost:8080/rels/{rel}/{another}"));
assertThatIllegalArgumentException().isThrownBy(() -> {
new DefaultCurieProvider("acme", UriTemplate.of("http://localhost:8080/rels/{rel}/{another}"));
});
}
@Test

View File

@@ -17,9 +17,8 @@ package org.springframework.hateoas.mediatype.hal;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.mediatype.hal.HalConfiguration;
import org.springframework.hateoas.mediatype.hal.HalConfiguration.RenderSingleLinks;
/**

View File

@@ -22,8 +22,8 @@ import static org.springframework.hateoas.mediatype.hal.HalLinkRelation.*;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.UriTemplate;
import org.springframework.hateoas.server.LinkRelationProvider;
@@ -42,7 +42,7 @@ public class HalEmbeddedBuilderUnitTest {
LinkRelationProvider provider;
CurieProvider curieProvider;
@Before
@BeforeEach
public void setUp() {
provider = new EvoInflectorLinkRelationProvider();
curieProvider = new DefaultCurieProvider("curie", UriTemplate.of("http://localhost/{rel}"));
@@ -110,10 +110,13 @@ public class HalEmbeddedBuilderUnitTest {
/**
* @see #195
*/
@Test(expected = IllegalArgumentException.class)
@Test
@SuppressWarnings("null")
public void rejectsNullRelProvider() {
new HalEmbeddedBuilder(null, CurieProvider.NONE, false);
assertThatIllegalArgumentException().isThrownBy(() -> {
new HalEmbeddedBuilder(null, CurieProvider.NONE, false);
});
}
/**
@@ -170,9 +173,12 @@ public class HalEmbeddedBuilderUnitTest {
/**
* @see #286
*/
@Test(expected = IllegalStateException.class)
@Test
public void rejectsInvalidEmbeddedWrapper() {
new HalEmbeddedBuilder(provider, curieProvider, false).add(mock(EmbeddedWrapper.class));
assertThatIllegalStateException().isThrownBy(() -> {
new HalEmbeddedBuilder(provider, curieProvider, false).add(mock(EmbeddedWrapper.class));
});
}
@SuppressWarnings("unchecked")

View File

@@ -20,14 +20,13 @@ import static org.springframework.hateoas.support.MappingUtils.*;
import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.client.LinkDiscovererUnitTest;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscovererUnitTest;
/**
* Unit tests for {@link HalLinkDiscoverer}.

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas.mediatype.hal;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.mediatype.hal.HalLinkRelation.HalLinkRelationBuilder;

View File

@@ -26,8 +26,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.context.support.MessageSourceAccessor;
@@ -82,7 +82,7 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
MessageSource messageSource = mock(MessageSource.class);
@Before
@BeforeEach
public void setUpModule() {
MessageSourceAccessor accessor = new MessageSourceAccessor(messageSource);

View File

@@ -26,22 +26,22 @@ import lombok.experimental.Wither;
import java.util.ArrayList;
import java.util.List;
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;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.bind.annotation.GetMapping;
@@ -54,7 +54,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
* @author Greg Turnquist
* @author Jens Schauder
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class RenderHypermediaForDefaultAcceptHeadersTest {
@@ -63,7 +63,7 @@ public class RenderHypermediaForDefaultAcceptHeadersTest {
MockMvc mockMvc;
@Before
@BeforeEach
public void setUp() {
this.mockMvc = webAppContextSetup(this.context).build();
}

View File

@@ -20,13 +20,12 @@ import static org.springframework.hateoas.support.MappingUtils.*;
import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.client.LinkDiscovererUnitTest;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.mediatype.hal.forms.HalFormsLinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscovererUnitTest;
/**
* Unit tests for {@link HalFormsLinkDiscoverer}.

View File

@@ -15,11 +15,7 @@
*/
package org.springframework.hateoas.mediatype.hal.forms;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.io.ByteArrayOutputStream;
@@ -27,8 +23,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.MessageSource;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.core.io.ClassPathResource;
@@ -55,7 +51,7 @@ public class HalFormsMessageConverterUnitTest {
ObjectMapper mapper;
HttpMessageConverter<Object> messageConverter;
@Before
@BeforeEach
public void setUp() {
this.mapper = new ObjectMapper();
@@ -88,18 +84,18 @@ public class HalFormsMessageConverterUnitTest {
Object convertedMessage = this.messageConverter.read(HalFormsDocument.class, message);
assertThat(convertedMessage, instanceOf(HalFormsDocument.class));
assertThat(convertedMessage).isInstanceOf(HalFormsDocument.class);
HalFormsDocument<?> halFormsDocument = (HalFormsDocument<?>) convertedMessage;
assertThat(halFormsDocument.getLinks()).hasSize(2);
assertThat(halFormsDocument.getLinks()).extracting(Link::getHref).containsExactly("/employees", "/employees/1");
assertThat(halFormsDocument.getTemplates().size(), is(1));
assertThat(halFormsDocument.getTemplates().keySet(), hasItems("default"));
assertThat(halFormsDocument.getTemplates().get("default").getContentType(), is("application/hal+json"));
assertThat(halFormsDocument.getTemplates().get("default").getHttpMethod(), is(HttpMethod.GET));
assertThat(halFormsDocument.getTemplates().get("default").getMethod(), is(HttpMethod.GET.toString().toLowerCase()));
assertThat(halFormsDocument.getTemplates().size()).isEqualTo(1);
assertThat(halFormsDocument.getTemplates().keySet()).containsExactly("default");
assertThat(halFormsDocument.getTemplates().get("default").getContentType()).isEqualTo("application/hal+json");
assertThat(halFormsDocument.getTemplates().get("default").getHttpMethod()).isEqualTo(HttpMethod.GET);
assertThat(halFormsDocument.getTemplates().get("default").getMethod()).isEqualTo(HttpMethod.GET.toString().toLowerCase());
}
@Test
@@ -139,6 +135,6 @@ public class HalFormsMessageConverterUnitTest {
this.messageConverter.write(expected, MediaTypes.HAL_FORMS_JSON, convertedMessage);
assertThat(this.mapper.readValue(stream.toString(), HalFormsDocument.class), is(expected));
assertThat(this.mapper.readValue(stream.toString(), HalFormsDocument.class)).isEqualTo(expected);
}
}

View File

@@ -26,9 +26,9 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
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;
@@ -42,7 +42,7 @@ import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType
import org.springframework.hateoas.support.Employee;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.bind.annotation.GetMapping;
@@ -61,7 +61,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
*
* @author Greg Turnquist
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class HalFormsValidationIntegrationTest {
@@ -70,7 +70,7 @@ public class HalFormsValidationIntegrationTest {
MockMvc mockMvc;
@Before
@BeforeEach
public void setUp() {
this.mockMvc = webAppContextSetup(this.context).build();
}

View File

@@ -19,9 +19,9 @@ import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.collection.IsCollectionWithSize.*;
import static org.springframework.hateoas.support.JsonPathUtils.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -29,13 +29,13 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.WebClientConfigurer;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.config.WebClientConfigurer;
import org.springframework.hateoas.support.MappingUtils;
import org.springframework.hateoas.support.WebFluxEmployeeController;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.web.reactive.config.EnableWebFlux;
@@ -43,14 +43,14 @@ import org.springframework.web.reactive.config.EnableWebFlux;
/**
* @author Greg Turnquist
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class HalFormsWebFluxIntegrationTest {
@Autowired WebTestClient testClient;
@Before
@BeforeEach
public void setUp() {
WebFluxEmployeeController.reset();
}

View File

@@ -21,9 +21,9 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
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;
@@ -35,7 +35,7 @@ import org.springframework.hateoas.support.MappingUtils;
import org.springframework.hateoas.support.WebMvcEmployeeController;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.context.WebApplicationContext;
@@ -44,7 +44,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/**
* @author Greg Turnquist
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class HalFormsWebMvcIntegrationTest {
@@ -53,7 +53,7 @@ public class HalFormsWebMvcIntegrationTest {
MockMvc mockMvc;
@Before
@BeforeEach
public void setUp() {
this.mockMvc = webAppContextSetup(this.context).build();

View File

@@ -26,8 +26,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.context.support.MessageSourceAccessor;
@@ -71,7 +71,7 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
MessageSource messageSource = mock(MessageSource.class);
@Before
@BeforeEach
public void setUpModule() {
LinkRelationProvider provider = new DelegatingLinkRelationProvider(new AnnotationLinkRelationProvider(),

View File

@@ -27,8 +27,8 @@ import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.AbstractJackson2MarshallingIntegrationTest;
import org.springframework.hateoas.CollectionModel;
@@ -55,7 +55,7 @@ public class Jackson2UberIntegrationTest extends AbstractJackson2MarshallingInte
new Link("bar", IanaLinkRelations.PREV) //
);
@Before
@BeforeEach
public void setUpModule() {
this.mapper.registerModule(new Jackson2UberModule());

View File

@@ -20,13 +20,12 @@ import static org.springframework.hateoas.support.MappingUtils.*;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.client.LinkDiscovererUnitTest;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscovererUnitTest;
import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer;
import org.springframework.hateoas.mediatype.uber.UberLinkDiscoverer;
/**
* Unit tests for {@link HalLinkDiscoverer}.
@@ -38,7 +37,7 @@ public class UberLinkDiscovererUnitTest extends LinkDiscovererUnitTest {
LinkDiscoverer discoverer = new UberLinkDiscoverer();
String sample;
@Before
@BeforeEach
public void setUp() throws IOException {
this.discoverer = new UberLinkDiscoverer();

View File

@@ -20,9 +20,9 @@ import static org.hamcrest.collection.IsCollectionWithSize.*;
import static org.springframework.hateoas.support.JsonPathUtils.*;
import static org.springframework.hateoas.support.MappingUtils.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -30,12 +30,12 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.WebClientConfigurer;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.config.WebClientConfigurer;
import org.springframework.hateoas.support.WebFluxEmployeeController;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.web.reactive.config.EnableWebFlux;
@@ -43,14 +43,14 @@ import org.springframework.web.reactive.config.EnableWebFlux;
/**
* @author Greg Turnquist
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class UberWebFluxIntegrationTest {
@Autowired WebTestClient testClient;
@Before
@BeforeEach
public void setUp() {
WebFluxEmployeeController.reset();
}

View File

@@ -22,9 +22,9 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
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;
@@ -35,7 +35,7 @@ import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType
import org.springframework.hateoas.support.WebMvcEmployeeController;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.context.WebApplicationContext;
@@ -44,7 +44,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/**
* @author Greg Turnquist
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class UberWebMvcIntegrationTest {
@@ -53,7 +53,7 @@ public class UberWebMvcIntegrationTest {
MockMvc mockMvc;
@Before
@BeforeEach
public void setUp() {
this.mockMvc = webAppContextSetup(this.context).build();

View File

@@ -24,8 +24,8 @@ import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.MessageSource;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.core.io.ClassPathResource;
@@ -62,7 +62,7 @@ public class VndErrorsMarshallingTest {
json2Reference = readFile(new ClassPathResource("vnderror2.json"));
}
@Before
@BeforeEach
public void setUp() {
jackson2Mapper = new com.fasterxml.jackson.databind.ObjectMapper();

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas.mediatype.vnderror;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.mediatype.vnderrors.VndErrors;
import org.springframework.hateoas.mediatype.vnderrors.VndErrors.VndError;

View File

@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
import java.lang.reflect.Method;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -34,9 +34,12 @@ public class AnnotationMappingDiscovererUnitTest {
MappingDiscoverer discoverer = new AnnotationMappingDiscoverer(RequestMapping.class);
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullAnnotation() {
new AnnotationMappingDiscoverer(null);
assertThatIllegalArgumentException().isThrownBy(() -> {
new AnnotationMappingDiscoverer(null);
});
}
@Test

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas.server.core;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.ConfigurableApplicationContext;

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas.server.core;
import static java.util.Collections.*;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
@@ -26,10 +26,10 @@ import lombok.Value;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
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.hateoas.TestUtils;
import org.springframework.hateoas.server.EntityLinks;
import org.springframework.hateoas.server.ExposesResourceFor;
@@ -45,7 +45,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
*
* @author Oliver Gierke
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ControllerEntityLinksUnitTest extends TestUtils {
@Mock LinkBuilderFactory<LinkBuilder> linkBuilderFactory;

View File

@@ -18,13 +18,7 @@ package org.springframework.hateoas.server.core;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.TestUtils;
import org.springframework.hateoas.server.EntityLinks;
import org.springframework.hateoas.server.ExposesResourceFor;
@@ -36,26 +30,20 @@ import org.springframework.web.bind.annotation.RequestMapping;
*
* @author Oliver Gierke
*/
@RunWith(MockitoJUnitRunner.class)
public class DelegatingEntityLinksUnitTest extends TestUtils {
@Mock EntityLinks target;
@Before
@Override
public void setUp() {
when(target.supports(String.class)).thenReturn(true);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullPluginRegistry() {
new DelegatingEntityLinks(null);
assertThatIllegalArgumentException().isThrownBy(() -> {
new DelegatingEntityLinks(null);
});
}
@Test
public void throwsExceptionForUnsupportedClass() {
EntityLinks links = new DelegatingEntityLinks(SimplePluginRegistry.create());
EntityLinks links = new DelegatingEntityLinks(SimplePluginRegistry.empty());
assertThatExceptionOfType(IllegalArgumentException.class) //
.isThrownBy(() -> links.linkFor(String.class)) //
@@ -65,7 +53,10 @@ public class DelegatingEntityLinksUnitTest extends TestUtils {
@Test
public void supportsDomainTypeBackedByPlugin() {
EntityLinks links = createDelegatingEntityLinks();
EntityLinks target = mock(EntityLinks.class);
when(target.supports(String.class)).thenReturn(true);
EntityLinks links = createDelegatingEntityLinks(target);
assertThat(links.supports(String.class)).isTrue();
}
@@ -73,13 +64,16 @@ public class DelegatingEntityLinksUnitTest extends TestUtils {
@Test
public void delegatesLinkForCall() {
createDelegatingEntityLinks().linkFor(String.class);
EntityLinks target = mock(EntityLinks.class);
when(target.supports(String.class)).thenReturn(true);
createDelegatingEntityLinks(target).linkFor(String.class);
verify(target, times(1)).linkFor(String.class);
}
private EntityLinks createDelegatingEntityLinks() {
return new DelegatingEntityLinks(SimplePluginRegistry.create(Arrays.asList(target)));
private EntityLinks createDelegatingEntityLinks(EntityLinks target) {
return new DelegatingEntityLinks(SimplePluginRegistry.of(target));
}
@ExposesResourceFor(String.class)

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas.server.core;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.server.LinkRelationProvider;
import org.springframework.hateoas.server.LinkRelationProvider.LookupContext;

View File

@@ -20,10 +20,8 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Collection;
import java.util.Collections;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.server.core.EmbeddedWrapper;
import org.springframework.hateoas.server.core.EmbeddedWrappers;
/**
* Unit tests for {@link EmbeddedWrappers}.
@@ -63,9 +61,12 @@ public class EmbeddedWrappersUnitTest {
/**
* @see #286
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsEmptyCollectionWithoutExplicitRel() {
wrappers.wrap(Collections.emptySet());
assertThatIllegalArgumentException().isThrownBy(() -> {
wrappers.wrap(Collections.emptySet());
});
}
@SuppressWarnings("unchecked")

View File

@@ -17,10 +17,9 @@ package org.springframework.hateoas.server.core;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.server.LinkRelationProvider;
import org.springframework.hateoas.server.core.EvoInflectorLinkRelationProvider;
/**
* Unit tests for {@link EvoInflectorLinkRelationProvider}.

View File

@@ -15,7 +15,9 @@
*/
package org.springframework.hateoas.server.core;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.client.JsonPathLinkDiscoverer;
import org.springframework.http.MediaType;
@@ -26,8 +28,11 @@ import org.springframework.http.MediaType;
*/
public class JsonPathLinkDiscovererUnitTest {
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullPattern() {
new JsonPathLinkDiscoverer(null, MediaType.ALL);
assertThatIllegalArgumentException().isThrownBy(() -> {
new JsonPathLinkDiscoverer(null, MediaType.ALL);
});
}
}

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.Affordance;
import org.springframework.hateoas.TestUtils;
import org.springframework.web.util.UriComponentsBuilder;

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.lang.reflect.Method;
import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.MethodParameter;

View File

@@ -24,9 +24,9 @@ import lombok.Data;
import java.util.Collection;
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;
@@ -35,13 +35,12 @@ import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.server.core.TypeReferences;
import org.springframework.hateoas.server.core.TypeReferences.CollectionModelType;
import org.springframework.hateoas.server.core.TypeReferences.EntityModelType;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
@@ -51,7 +50,7 @@ import org.springframework.web.client.RestTemplate;
* @author Oliver Gierke
* @author Greg Turnquist
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration
public class TypeReferencesIntegrationTest {
@@ -88,7 +87,7 @@ public class TypeReferencesIntegrationTest {
@Autowired RestTemplate template;
MockRestServiceServer server;
@Before
@BeforeEach
public void setUp() {
this.server = createServer(template);
}

View File

@@ -25,15 +25,13 @@ import java.util.Map;
import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.MethodParameter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.TestUtils;
import org.springframework.hateoas.server.mvc.ControllerLinkBuilderFactory;
import org.springframework.hateoas.server.mvc.UriComponentsContributor;
import org.springframework.hateoas.server.mvc.ControllerLinkBuilderUnitTest.ControllerWithMethods;
import org.springframework.hateoas.server.mvc.ControllerLinkBuilderUnitTest.PersonControllerImpl;
import org.springframework.hateoas.server.mvc.ControllerLinkBuilderUnitTest.PersonsAddressesController;

View File

@@ -18,10 +18,9 @@ package org.springframework.hateoas.server.mvc;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.hateoas.server.mvc.ControllerLinkBuilder.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.server.mvc.ControllerLinkBuilder;
import org.springframework.web.context.request.RequestContextHolder;
/**
@@ -35,7 +34,7 @@ public class ControllerLinkBuilderOutsideSpringMvcUnitTest {
/**
* Clear out any existing request attributes left behind by other tests
*/
@Before
@BeforeEach
public void setUp() {
RequestContextHolder.setRequestAttributes(null);
}

View File

@@ -15,9 +15,7 @@
*/
package org.springframework.hateoas.server.mvc;
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.springframework.hateoas.server.mvc.ControllerLinkBuilder.*;
import java.lang.reflect.Method;
@@ -25,9 +23,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.TemplateVariable;
@@ -57,8 +53,6 @@ import org.springframework.web.util.UriComponentsBuilder;
@Deprecated
public class ControllerLinkBuilderUnitTest extends TestUtils {
public @Rule ExpectedException exception = ExpectedException.none();
@Test
public void createsLinkToControllerRoot() {
@@ -156,7 +150,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://somethingDifferent"));
assertThat(link.getHref()).startsWith("http://somethingDifferent");
}
/**
@@ -170,7 +164,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("https://"));
assertThat(link.getHref()).startsWith("https://");
}
/**
@@ -184,7 +178,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://"));
assertThat(link.getHref()).startsWith("http://");
}
/**
@@ -199,7 +193,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("https://somethingDifferent"));
assertThat(link.getHref()).startsWith("https://somethingDifferent");
}
/**
@@ -226,8 +220,8 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
assertThat(components.getPath()).isEqualTo("/something/1/foo");
MultiValueMap<String, String> queryParams = components.getQueryParams();
assertThat(queryParams.get("limit"), contains("5"));
assertThat(queryParams.get("offset"), contains("10"));
assertThat(queryParams.get("limit")).containsExactly("5");
assertThat(queryParams.get("offset")).containsExactly("10");
}
/**
@@ -244,8 +238,8 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
assertThat(components.getPath()).isEqualTo("/something/1/foo");
MultiValueMap<String, String> queryParams = components.getQueryParams();
assertThat(queryParams.get("limit"), contains("5"));
assertThat(queryParams.get("items"), containsInAnyOrder("3", "7"));
assertThat(queryParams.get("limit")).containsExactly("5");
assertThat(queryParams.get("items")).containsExactlyInAnyOrder("3", "7");
}
/**
@@ -272,7 +266,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://foobar:8088"));
assertThat(link.getHref()).startsWith("http://foobar:8088");
}
/**
@@ -286,7 +280,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://barfoo:8888"));
assertThat(link.getHref()).startsWith("http://barfoo:8888");
}
/**
@@ -297,7 +291,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodForOptionalNextPage(null)).withSelfRel();
assertThat(link.getVariables(), contains(new TemplateVariable("offset", VariableType.REQUEST_PARAM)));
assertThat(link.getVariables()).containsExactly(new TemplateVariable("offset", VariableType.REQUEST_PARAM));
assertThat(link.expand().getHref()).endsWith("/foo");
}
@@ -307,25 +301,25 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
@Test
public void rejectsMissingPathVariable() {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithPathVariable(null))//
.withSelfRel();
exception.expect(IllegalArgumentException.class);
link.expand();
assertThatIllegalArgumentException().isThrownBy(() -> {
linkTo(methodOn(ControllerWithMethods.class).methodWithPathVariable(null))//
.withSelfRel().expand();
});
}
/**
* @see #122, #169
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsMissingRequiredRequestParam() {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithRequestParam(null)).withSelfRel();
assertThatIllegalArgumentException().isThrownBy(() -> {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithRequestParam(null)).withSelfRel();
assertThat(link.getVariableNames(), contains("id"));
assertThat(link.getVariableNames()).containsExactly("id");
link.expand();
link.expand();
});
}
/**
@@ -342,7 +336,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://foobarhost:9090/"));
assertThat(link.getHref()).startsWith("http://foobarhost:9090/");
}
/**
@@ -357,7 +351,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://foobarhost/"));
assertThat(link.getHref()).startsWith("http://foobarhost/");
}
/**
@@ -431,7 +425,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith(proto + "://"));
assertThat(link.getHref()).startsWith(proto + "://");
}
}
@@ -449,7 +443,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith(proto.concat("://")));
assertThat(link.getHref()).startsWith(proto.concat("://"));
}
}
@@ -465,7 +459,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("bar://"));
assertThat(link.getHref()).startsWith("bar://");
}
/**
@@ -510,14 +504,13 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
@Test
public void addsRequestParameterVariablesForMissingRequiredParameter() {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodForNextPage("1", 10, null)).withSelfRel();
assertThatIllegalArgumentException().isThrownBy(() -> {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodForNextPage("1", 10, null)).withSelfRel();
assertThat(link.getVariableNames(), contains("limit"));
assertThat(link.getVariableNames()).containsExactly("limit");
exception.expect(IllegalArgumentException.class);
exception.expectMessage("limit");
link.expand();
link.expand();
}).withMessageContaining("limit");
}
/**
@@ -528,7 +521,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodForNextPage("1", null, 5)).withSelfRel();
assertThat(link.getVariables(), contains(new TemplateVariable("offset", VariableType.REQUEST_PARAM_CONTINUED)));
assertThat(link.getVariables()).containsExactly(new TemplateVariable("offset", VariableType.REQUEST_PARAM_CONTINUED));
UriComponents components = toComponents(link);
@@ -546,7 +539,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
assertThat(linkTo(PersonControllerImpl.class).withSelfRel().getHref(), startsWith("http://proxy1:1443"));
assertThat(linkTo(PersonControllerImpl.class).withSelfRel().getHref()).startsWith("http://proxy1:1443");
}
/**
@@ -558,7 +551,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
request.addHeader("X-Forwarded-Proto", "http");
request.addHeader("X-Forwarded-Ssl", "on");
assertThat(linkTo(PersonControllerImpl.class).withSelfRel().getHref(), startsWith("http://"));
assertThat(linkTo(PersonControllerImpl.class).withSelfRel().getHref()).startsWith("http://");
}
/**
@@ -583,7 +576,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithJdk8Optional(Optional.empty())).withSelfRel();
assertThat(link.isTemplated()).isTrue();
assertThat(link.getVariableNames(), contains("value"));
assertThat(link.getVariableNames()).containsExactly("value");
}
/**

View File

@@ -18,7 +18,7 @@ package org.springframework.hateoas.server.mvc;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.TestUtils;
import org.springframework.http.HttpEntity;

View File

@@ -19,9 +19,9 @@ import static org.assertj.core.api.Assertions.*;
import java.util.List;
import org.junit.Test;
import org.springframework.hateoas.Link;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.server.core.HeaderLinksResponseEntity;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;

View File

@@ -29,9 +29,9 @@ import java.util.Map;
import java.util.Optional;
import java.util.TreeMap;
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;
@@ -51,7 +51,7 @@ import org.springframework.hateoas.support.MappingUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.bind.annotation.GetMapping;
@@ -71,7 +71,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
* @author Greg Turnquist
* @author Oliver Gierke
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class MultiMediaTypeWebMvcIntegrationTest {
@@ -82,7 +82,7 @@ public class MultiMediaTypeWebMvcIntegrationTest {
private static Map<Integer, Employee> EMPLOYEES;
@Before
@BeforeEach
public void setUp() {
this.mockMvc = webAppContextSetup(this.context).build();

View File

@@ -29,24 +29,23 @@ import java.util.List;
import java.util.Map;
import java.util.function.Function;
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.aop.framework.ProxyFactory;
import org.springframework.core.MethodParameter;
import org.springframework.core.ResolvableType;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedModel;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.server.RepresentationModelProcessor;
import org.springframework.hateoas.server.core.EmbeddedWrappers;
import org.springframework.hateoas.server.core.HeaderLinksResponseEntity;
import org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker;
import org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker.ResourcesProcessorWrapper;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
@@ -59,7 +58,7 @@ import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
* @author Oliver Gierke
* @author Jon Brisbin
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ResourceProcessorHandlerMethodReturnValueHandlerUnitTest {
static final EntityModel<String> FOO = new EntityModel<>("foo");
@@ -95,7 +94,7 @@ public class ResourceProcessorHandlerMethodReturnValueHandlerUnitTest {
@Mock HandlerMethodReturnValueHandler delegate;
List<RepresentationModelProcessor<?>> resourceProcessors;
@Before
@BeforeEach
public void setUp() {
resourceProcessors = new ArrayList<>();
}

View File

@@ -18,10 +18,9 @@ package org.springframework.hateoas.server.mvc;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.http.MediaType.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.RepresentationModel;
import org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter;
import org.springframework.http.converter.GenericHttpMessageConverter;
/**
@@ -34,9 +33,12 @@ public class TypeConstrainedMappingJackson2HttpMessageConverterUnitTest {
/**
* @see #219
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullType() {
new TypeConstrainedMappingJackson2HttpMessageConverter(null);
assertThatIllegalArgumentException().isThrownBy(() -> {
new TypeConstrainedMappingJackson2HttpMessageConverter(null);
});
}
/**

View File

@@ -25,15 +25,13 @@ import java.util.Map;
import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.MethodParameter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.TestUtils;
import org.springframework.hateoas.server.mvc.UriComponentsContributor;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderUnitTest.ControllerWithMethods;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderUnitTest.PersonControllerImpl;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderUnitTest.PersonsAddressesController;

View File

@@ -18,8 +18,8 @@ package org.springframework.hateoas.server.mvc;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.Link;
import org.springframework.web.context.request.RequestContextHolder;
@@ -34,7 +34,7 @@ public class WebMvcLinkBuilderOutsideSpringMvcUnitTest {
/**
* Clear out any existing request attributes left behind by other tests
*/
@Before
@BeforeEach
public void setUp() {
RequestContextHolder.setRequestAttributes(null);
}

View File

@@ -15,9 +15,7 @@
*/
package org.springframework.hateoas.server.mvc;
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.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
import java.lang.reflect.Method;
@@ -25,9 +23,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.TemplateVariable;
@@ -56,8 +52,6 @@ import org.springframework.web.util.UriComponentsBuilder;
*/
public class WebMvcLinkBuilderUnitTest extends TestUtils {
public @Rule ExpectedException exception = ExpectedException.none();
@Test
public void createsLinkToControllerRoot() {
@@ -155,7 +149,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://somethingDifferent"));
assertThat(link.getHref()).startsWith("http://somethingDifferent");
}
/**
@@ -169,7 +163,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("https://"));
assertThat(link.getHref()).startsWith("https://");
}
/**
@@ -183,7 +177,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://"));
assertThat(link.getHref()).startsWith("http://");
}
/**
@@ -198,7 +192,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("https://somethingDifferent"));
assertThat(link.getHref()).startsWith("https://somethingDifferent");
}
/**
@@ -225,8 +219,8 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
assertThat(components.getPath()).isEqualTo("/something/1/foo");
MultiValueMap<String, String> queryParams = components.getQueryParams();
assertThat(queryParams.get("limit"), contains("5"));
assertThat(queryParams.get("offset"), contains("10"));
assertThat(queryParams.get("limit")).containsExactly("5");
assertThat(queryParams.get("offset")).containsExactly("10");
}
/**
@@ -243,8 +237,8 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
assertThat(components.getPath()).isEqualTo("/something/1/foo");
MultiValueMap<String, String> queryParams = components.getQueryParams();
assertThat(queryParams.get("limit"), contains("5"));
assertThat(queryParams.get("items"), containsInAnyOrder("3", "7"));
assertThat(queryParams.get("limit")).containsExactly("5");
assertThat(queryParams.get("items")).containsExactlyInAnyOrder("3", "7");
}
/**
@@ -271,7 +265,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://foobar:8088"));
assertThat(link.getHref()).startsWith("http://foobar:8088");
}
/**
@@ -285,7 +279,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://barfoo:8888"));
assertThat(link.getHref()).startsWith("http://barfoo:8888");
}
/**
@@ -296,7 +290,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodForOptionalNextPage(null)).withSelfRel();
assertThat(link.getVariables(), contains(new TemplateVariable("offset", VariableType.REQUEST_PARAM)));
assertThat(link.getVariables()).containsExactly(new TemplateVariable("offset", VariableType.REQUEST_PARAM));
assertThat(link.expand().getHref()).endsWith("/foo");
}
@@ -306,25 +300,25 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
@Test
public void rejectsMissingPathVariable() {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithPathVariable(null))//
.withSelfRel();
exception.expect(IllegalArgumentException.class);
link.expand();
assertThatIllegalArgumentException().isThrownBy(() -> {
linkTo(methodOn(ControllerWithMethods.class).methodWithPathVariable(null))//
.withSelfRel().expand();
});
}
/**
* @see #122, #169
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsMissingRequiredRequestParam() {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithRequestParam(null)).withSelfRel();
assertThatIllegalArgumentException().isThrownBy(() -> {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithRequestParam(null)).withSelfRel();
assertThat(link.getVariableNames(), contains("id"));
assertThat(link.getVariableNames()).containsExactly("id");
link.expand();
link.expand();
});
}
/**
@@ -341,7 +335,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://foobarhost:9090/"));
assertThat(link.getHref()).startsWith("http://foobarhost:9090/");
}
/**
@@ -356,7 +350,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("http://foobarhost/"));
assertThat(link.getHref()).startsWith("http://foobarhost/");
}
/**
@@ -430,7 +424,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith(proto + "://"));
assertThat(link.getHref()).startsWith(proto + "://");
}
}
@@ -448,7 +442,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith(proto.concat("://")));
assertThat(link.getHref()).startsWith(proto.concat("://"));
}
}
@@ -464,7 +458,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
assertThat(link.getHref(), startsWith("bar://"));
assertThat(link.getHref()).startsWith("bar://");
}
/**
@@ -509,14 +503,14 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
@Test
public void addsRequestParameterVariablesForMissingRequiredParameter() {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodForNextPage("1", 10, null)).withSelfRel();
assertThatIllegalArgumentException().isThrownBy(() -> {
assertThat(link.getVariableNames(), contains("limit"));
Link link = linkTo(methodOn(ControllerWithMethods.class).methodForNextPage("1", 10, null)).withSelfRel();
exception.expect(IllegalArgumentException.class);
exception.expectMessage("limit");
assertThat(link.getVariableNames()).containsExactly("limit");
link.expand();
link.expand();
}).withMessageContaining("limit");
}
/**
@@ -527,7 +521,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodForNextPage("1", null, 5)).withSelfRel();
assertThat(link.getVariables(), contains(new TemplateVariable("offset", VariableType.REQUEST_PARAM_CONTINUED)));
assertThat(link.getVariables()).containsExactly(new TemplateVariable("offset", VariableType.REQUEST_PARAM_CONTINUED));
UriComponents components = toComponents(link);
@@ -545,7 +539,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
adaptRequestFromForwardedHeaders();
assertThat(linkTo(PersonControllerImpl.class).withSelfRel().getHref(), startsWith("http://proxy1:1443"));
assertThat(linkTo(PersonControllerImpl.class).withSelfRel().getHref()).startsWith("http://proxy1:1443");
}
/**
@@ -557,7 +551,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
request.addHeader("X-Forwarded-Proto", "http");
request.addHeader("X-Forwarded-Ssl", "on");
assertThat(linkTo(PersonControllerImpl.class).withSelfRel().getHref(), startsWith("http://"));
assertThat(linkTo(PersonControllerImpl.class).withSelfRel().getHref()).startsWith("http://");
}
/**
@@ -582,7 +576,7 @@ public class WebMvcLinkBuilderUnitTest extends TestUtils {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithJdk8Optional(Optional.empty())).withSelfRel();
assertThat(link.isTemplated()).isTrue();
assertThat(link.getVariableNames(), contains("value"));
assertThat(link.getVariableNames()).containsExactly("value");
}
/**

View File

@@ -22,8 +22,8 @@ import static org.springframework.hateoas.server.reactive.WebFluxLinkBuilder.*;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -46,7 +46,7 @@ public class HypermediaWebFilterTest {
WebTestClient testClient;
@Before
@BeforeEach
public void setUp() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();

View File

@@ -21,6 +21,7 @@ import static org.mockito.Mockito.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -28,8 +29,8 @@ import reactor.test.StepVerifier;
import java.util.Collection;
import org.assertj.core.api.AssertionsForInterfaceTypes;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.RepresentationModel;
@@ -48,7 +49,7 @@ public class ReactiveResourceAssemblerUnitTest {
ServerWebExchange exchange;
@Before
@BeforeEach
public void setUp() {
this.assembler = new TestAssembler();

View File

@@ -18,11 +18,12 @@ package org.springframework.hateoas.server.reactive;
import static org.assertj.core.api.Assertions.*;
import lombok.Data;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.EntityModel;
@@ -40,7 +41,7 @@ public class SimpleReactiveResourceAssemblerTest {
@Mock ServerWebExchange exchange;
@Before
@BeforeEach
public void setUp() {
this.testResourceAssembler = new TestResourceAssemblerSimple();

View File

@@ -25,12 +25,11 @@ import reactor.test.StepVerifier;
import reactor.util.context.Context;
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.Test;
import org.junit.runner.RunWith;
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.hateoas.IanaLinkRelations;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest;
@@ -45,7 +44,7 @@ import org.springframework.web.server.ServerWebExchange;
* @author Greg Turnquist
* @author Oliver Drotbohm
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class WebFluxLinkBuilderTest {
@Mock ServerWebExchange exchange;

View File

@@ -25,7 +25,7 @@ import java.util.AbstractMap.SimpleEntry;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.ResolvableType;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.mediatype.PropertyUtils;

View File

@@ -16,7 +16,7 @@
package org.springframework.hateoas.mvc
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.junit.jupiter.api.Test
import org.springframework.hateoas.*
import org.springframework.hateoas.server.mvc.*
import org.springframework.http.HttpMethod

View File

@@ -16,7 +16,7 @@
package org.springframework.hateoas.mvc
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.junit.jupiter.api.Test
import org.springframework.hateoas.*
import org.springframework.hateoas.server.mvc.*
import org.springframework.http.ResponseEntity