#980 - Polishing.

Moved to latest JUnit version.
Limited assertions of exceptions to one method call.
This commit is contained in:
Jens Schauder
2019-04-15 10:30:36 +02:00
parent 3a8b37b42a
commit 13466eb1c7
5 changed files with 18 additions and 11 deletions

View File

@@ -78,7 +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>
<junit.version>5.4.1</junit.version>
<minidevjson.version>2.2.1</minidevjson.version>
<reactor-bom.version>Californium-SR4</reactor-bom.version>
<slf4j.version>1.7.25</slf4j.version>

View File

@@ -85,8 +85,9 @@ public class RepresentationModelUnitTest {
@Test
public void preventsNullLinkBeingAdded() {
RepresentationModel<?> support = new RepresentationModel<>();
assertThatIllegalArgumentException().isThrownBy(() -> {
RepresentationModel<?> support = new RepresentationModel<>();
support.add((Link) null);
});
}
@@ -94,8 +95,9 @@ public class RepresentationModelUnitTest {
@Test
public void preventsNullLinksBeingAdded() {
RepresentationModel<?> support = new RepresentationModel<>();
assertThatIllegalArgumentException().isThrownBy(() -> {
RepresentationModel<?> support = new RepresentationModel<>();
support.add((Iterable<Link>) null);
});
}

View File

@@ -150,8 +150,9 @@ public class UriTemplateUnitTest {
@Test
public void rejectsMissingRequiredPathVariable() {
UriTemplate template = UriTemplate.of("/foo/{bar}");
assertThatIllegalArgumentException().isThrownBy(() -> {
UriTemplate template = UriTemplate.of("/foo/{bar}");
template.expand(Collections.emptyMap());
});
}

View File

@@ -176,8 +176,10 @@ public class HalEmbeddedBuilderUnitTest {
@Test
public void rejectsInvalidEmbeddedWrapper() {
HalEmbeddedBuilder builder = new HalEmbeddedBuilder(provider, curieProvider, false);
assertThatIllegalStateException().isThrownBy(() -> {
new HalEmbeddedBuilder(provider, curieProvider, false).add(mock(EmbeddedWrapper.class));
builder.add(mock(EmbeddedWrapper.class));
});
}

View File

@@ -301,9 +301,10 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
@Test
public void rejectsMissingPathVariable() {
ControllerLinkBuilder builder = linkTo(methodOn(ControllerWithMethods.class).methodWithPathVariable(null));
assertThatIllegalArgumentException().isThrownBy(() -> {
linkTo(methodOn(ControllerWithMethods.class).methodWithPathVariable(null))//
.withSelfRel().expand();
builder.withSelfRel().expand();
});
}
@@ -313,10 +314,10 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
@Test
public void rejectsMissingRequiredRequestParam() {
assertThatIllegalArgumentException().isThrownBy(() -> {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithRequestParam(null)).withSelfRel();
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithRequestParam(null)).withSelfRel();
assertThat(link.getVariableNames()).containsExactly("id");
assertThat(link.getVariableNames()).containsExactly("id");
assertThatIllegalArgumentException().isThrownBy(() -> {
link.expand();
});
@@ -521,7 +522,8 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
Link link = linkTo(methodOn(ControllerWithMethods.class).methodForNextPage("1", null, 5)).withSelfRel();
assertThat(link.getVariables()).containsExactly(new TemplateVariable("offset", VariableType.REQUEST_PARAM_CONTINUED));
assertThat(link.getVariables())
.containsExactly(new TemplateVariable("offset", VariableType.REQUEST_PARAM_CONTINUED));
UriComponents components = toComponents(link);