Skip to content

Commit

Permalink
#980 - Polishing.
Browse files Browse the repository at this point in the history
Moved to latest JUnit version.
Limited assertions of exceptions to one method call.
  • Loading branch information
schauder committed Apr 15, 2019
1 parent 3a8b37b commit 13466eb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,19 @@ public void addsLinksCorrectly() {
@Test
public void preventsNullLinkBeingAdded() {

RepresentationModel<?> support = new RepresentationModel<>();

assertThatIllegalArgumentException().isThrownBy(() -> {
RepresentationModel<?> support = new RepresentationModel<>();
support.add((Link) null);
});
}

@Test
public void preventsNullLinksBeingAdded() {

RepresentationModel<?> support = new RepresentationModel<>();

assertThatIllegalArgumentException().isThrownBy(() -> {
RepresentationModel<?> support = new RepresentationModel<>();
support.add((Iterable<Link>) null);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ public void expandsMultipleRequestParameters() {
@Test
public void rejectsMissingRequiredPathVariable() {

UriTemplate template = UriTemplate.of("/foo/{bar}");

assertThatIllegalArgumentException().isThrownBy(() -> {
UriTemplate template = UriTemplate.of("/foo/{bar}");
template.expand(Collections.emptyMap());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ public void forcesCollectionRelToBeUsedIfConfiguredWithCurieProvider() {
@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));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,10 @@ public void appendsOptionalParameterVariableForUnsetParameter() {
@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();
});
}

Expand All @@ -313,10 +314,10 @@ public void rejectsMissingPathVariable() {
@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();
});
Expand Down Expand Up @@ -521,7 +522,8 @@ public void addsOptionalRequestParameterTemplateForMissingValue() {

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);

Expand Down

0 comments on commit 13466eb

Please sign in to comment.