Skip to content

Commit

Permalink
Upgrade Fest Assert to AssertJ.
Browse files Browse the repository at this point in the history
Also re-ordered one `overridingErrorMessage` to be applied before the assert evaluation.

Same fixes as for java-json-tools/json-schema-core/issues/66.
  • Loading branch information
Capstan committed Nov 5, 2019
1 parent 3c67cf9 commit 7788ffe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ dependencies {
exclude(group: "org.yaml", module: "snakeyaml");
};
testCompile(group: "org.mockito", name: "mockito-core", version: "2.4.2");
testCompile(group: "org.easytesting", name: "fest-assert", version: "1.4");
// FIXME: update to 3.x once we're off of Java 7.
testCompile(group: "org.assertj", name: "assertj-core", version: "2.9.1");
}

javadoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.github.fge.jsonschema.matchers;

import org.assertj.core.api.AbstractAssert;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand All @@ -27,16 +28,15 @@
import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.tree.SchemaTree;
import com.github.fge.jsonschema.core.util.AsJson;
import org.fest.assertions.GenericAssert;

import java.util.Collection;
import java.util.Map;

import static org.fest.assertions.Assertions.*;
import static org.assertj.core.api.Assertions.*;
import static org.testng.Assert.*;

public final class ProcessingMessageAssert
extends GenericAssert<ProcessingMessageAssert, ProcessingMessage>
extends AbstractAssert<ProcessingMessageAssert, ProcessingMessage>
{
private final JsonNode msg;

Expand All @@ -48,7 +48,7 @@ public static ProcessingMessageAssert assertMessage(

private ProcessingMessageAssert(final ProcessingMessage actual)
{
super(ProcessingMessageAssert.class, actual);
super(actual, ProcessingMessageAssert.class);
msg = actual.asJson();
}

Expand Down Expand Up @@ -88,9 +88,10 @@ public <T> ProcessingMessageAssert hasField(final String name,
assertThat(msg.has(name)).isTrue();
final String input = msg.get(name).textValue();
final String expected = value.toString();
assertThat(input).isEqualTo(expected)
assertThat(input)
.overridingErrorMessage("Strings differ: wanted " + expected
+ " but got " + input);
+ " but got " + input)
.isEqualTo(expected);
return this;
}

Expand Down

0 comments on commit 7788ffe

Please sign in to comment.