Skip to content

Commit

Permalink
Merge pull request #386 from lukas-krecan/aj2
Browse files Browse the repository at this point in the history
#379 Make compatible with AssertJ 3.20.x
  • Loading branch information
lukas-krecan committed Jun 18, 2021
2 parents 363333b + e39c67e commit b13ab78
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public JsonMapAssert containsEntry(String key, Object value) {

@SafeVarargs
@Override
public final JsonMapAssert containsAnyOf(Entry<? extends String, ?>... entries) {
protected final JsonMapAssert containsAnyOfForProxy(Entry<? extends String, ?>... entries) {
boolean anyMatch = stream(entries).anyMatch(this::doesContainEntry);
if (!anyMatch) {
throwAssertionError(shouldContainAnyOf(actual, entries));
Expand All @@ -143,8 +143,8 @@ public JsonMapAssert containsAllEntriesOf(Map<? extends String, ?> other) {
@SafeVarargs
@Override
@Deprecated
public final JsonMapAssert containsExactly(Entry<? extends String, ?>... entries) {
return super.containsExactly(entries);
public final JsonMapAssert containsExactlyForProxy(Entry<? extends String, ?>... entries) {
return super.containsExactlyForProxy(entries);
}

/**
Expand All @@ -158,7 +158,7 @@ public JsonMapAssert containsExactlyEntriesOf(Map<? extends String, ?> map) {

@SafeVarargs
@Override
public final JsonMapAssert containsOnly(Entry<? extends String, ?>... expected) {
protected final JsonMapAssert containsOnlyForProxy(Entry<? extends String, ?>... expected) {
Map<? extends String, ?> expectedAsMap = stream(expected).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
return isEqualTo(wrapDeserializedObject(expectedAsMap));
}
Expand All @@ -170,7 +170,7 @@ public final JsonMapAssert containsOnly(Entry<? extends String, ?>... expected)

@Override
@SafeVarargs
public final JsonMapAssert contains(Entry<? extends String, ?>... expected) {
protected final JsonMapAssert containsForProxy(Entry<? extends String, ?>... expected) {
List<Entry<? extends String, ?>> notFound = entriesNotFoundInMap(expected);
if (!notFound.isEmpty()) {
throwAssertionError(shouldContain(actual, expected, notFound));
Expand All @@ -193,7 +193,7 @@ private boolean doesContainEntry(Entry<? extends String, ?> entry) {
}

@Override
public JsonMapAssert containsValues(Object... values) {
protected JsonMapAssert containsValuesForProxy(Object... values) {
stream(values).forEach(this::containsValue);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ internal class KotlinDslTest {
}
}.hasMessage("[Different value found in node \"result.string\"] \n" +
"expected: \"stringValue2\"\n" +
"but was : \"stringValue\"")
" but was: \"stringValue\"")
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ internal class KotlinWebTestClientTest {
}
}.hasMessage("[Different value found in node \"result.string\"] \n" +
"expected: \"stringValue2\"\n" +
"but was : \"stringValue\"")
" but was: \"stringValue\"")
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<geronimo.jsonp.version>1.5</geronimo.jsonp.version>
<jsonorg.version>20210307</jsonorg.version>
<slf4j.version>1.7.30</slf4j.version>
<assertj.version>3.19.0</assertj.version>
<assertj.version>3.20.1</assertj.version>
<target.java.version>1.8</target.java.version>
<junit-jupiter.version>5.7.2</junit-jupiter.version>
<json-path.version>2.6.0</json-path.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void containsAnyOfShouldFailWithMatcher() {
entry("b", json("\"${json-unit.any-string}\""))
)
).hasMessage("[Different value found in node \"\"] \n" +
"Expecting:\n" +
"Expecting actual:\n" +
" {\"a\":1,\"b\":2}\n" +
"to contain at least one of the following elements:\n" +
" [MapEntry[key=\"a\", value=\"${json-unit.any-string}\"],\n" +
Expand All @@ -210,7 +210,7 @@ void containsValuesShouldFail() {
assertThatThrownBy(() ->
assertThatJson(json).isObject().containsValues(valueOf(1), valueOf(2), json("\"${json-unit.any-string}\""))
).hasMessage("[Different value found in node \"\"] \n" +
"Expecting:\n" +
"Expecting actual:\n" +
" {\"a\":1,\"b\":2}\n" +
"to contain value:\n" +
" \"${json-unit.any-string}\"");
Expand Down Expand Up @@ -247,7 +247,7 @@ void objectShouldContainComplexValueError() {
.isObject()
.containsValue(json("{\"c\" :5}")))
.hasMessage("[Different value found in node \"root\"] \n" +
"Expecting:\n" +
"Expecting actual:\n" +
" {\"a\":1,\"b\":{\"c\":3}}\n" +
"to contain value:\n" +
" {\"c\":5}");
Expand All @@ -266,7 +266,7 @@ void objectDoesContainComplexValueError() {
.isObject()
.doesNotContainValue(json("{\"c\" :3}")))
.hasMessage("[Different value found in node \"root\"] \n" +
"Expecting:\n" +
"Expecting actual:\n" +
" {\"a\":1,\"b\":{\"c\":3}}\n" +
"not to contain value:\n" +
" {\"c\":3}");
Expand Down Expand Up @@ -295,7 +295,7 @@ void compareJsonInJsonPathShallowArrayString() {
.isArray()
.containsExactly(value("450")))
.hasMessage("[Different value found in node \"$.root\"] \n" +
"Expecting:\n" +
"Expecting actual:\n" +
" [450]\n" +
"to contain exactly (and in same order):\n" +
" [\"450\"]\n" +
Expand Down Expand Up @@ -433,7 +433,7 @@ void shouldAssertContainsOnlyKeys() {
void shouldAssertContainsOnlyKeysError() {
assertThatThrownBy(() -> assertThatJson("{\"a\":{\"b\": 1, \"c\": true}}").node("a").isObject().containsOnlyKeys("b", "c", "d"))
.hasMessage("[Different value found in node \"a\"] \n" +
"Expecting:\n" +
"Expecting actual:\n" +
" {\"b\":1,\"c\":true}\n" +
"to contain only following keys:\n" +
" [\"b\", \"c\", \"d\"]\n" +
Expand Down Expand Up @@ -479,7 +479,7 @@ void shouldAssertObjectIsNotEqualToJsonWithPlaceholder() {
void shouldAssertObjectIsNotEqualToJsonWithPlaceholderError() {
assertThatThrownBy(() -> assertThatJson("{\"a\":{\"b\": \"string\"}}").node("a").isObject().isNotEqualTo(json("{\"b\":\"${json-unit.any-string}\"}")))
.hasMessage("[Different value found in node \"a\"] \n" +
"Expecting:\n" +
"Expecting actual:\n" +
" {\"b\":\"string\"}\n" +
"not to be equal to:\n" +
" {\"b\":\"${json-unit.any-string}\"}\n" +
Expand All @@ -497,7 +497,7 @@ void shouldAssertObjectJsonWithPlaceholderFailure() {
void shouldAssertString() {
assertThatThrownBy(() -> assertThatJson("{\"a\":{\"b\": \"foo\"}}").node("a.b").isString().startsWith("bar"))
.hasMessage("[Different value found in node \"a.b\"] \n" +
"Expecting:\n" +
"Expecting actual:\n" +
" \"foo\"\n" +
"to start with:\n" +
" \"bar\"\n");
Expand All @@ -507,7 +507,7 @@ void shouldAssertString() {
void shouldAssertStringCustomDescription() {
assertThatThrownBy(() -> assertThatJson("{\"a\":{\"b\": \"foo\"}}").node("a.b").isString().as("Sad!").startsWith("bar"))
.hasMessage("[Sad!] \n" +
"Expecting:\n" +
"Expecting actual:\n" +
" \"foo\"\n" +
"to start with:\n" +
" \"bar\"\n");
Expand Down Expand Up @@ -636,7 +636,7 @@ void shouldAssertNotNullChaining() {
assertThatThrownBy(() -> assertThatJson("{\"a\":{\"b\": 1}}").node("a").isNotNull().node("b").isNumber().isEqualByComparingTo("2"))
.hasMessage("[Different value found in node \"a.b\"] \n" +
"expected: 2\n" +
"but was : 1");
" but was: 1");
}

@Test
Expand Down Expand Up @@ -783,7 +783,7 @@ void containsValue() {
assertThatThrownBy(() -> assertThatJson("{\"a\": 1}")
.isObject().containsKey("lastModified2"))
.hasMessage("[Different value found in node \"\"] \n" +
"Expecting:\n" +
"Expecting actual:\n" +
" {\"a\":1}\n" +
"to contain key:\n" +
" \"lastModified2\"");
Expand All @@ -805,7 +805,7 @@ void shouldAssertNumberFailure() {
assertThatThrownBy(() -> assertThatJson("{\"a\":1}").node("a").isNumber().isEqualByComparingTo("2"))
.hasMessage("[Different value found in node \"a\"] \n" +
"expected: 2\n" +
"but was : 1");
" but was: 1");
}


Expand Down Expand Up @@ -861,7 +861,7 @@ void testPresentWithDescription() {
protected void testNotEqualTo() {
assertThatThrownBy(() -> assertThatJson("{\"test\":1}").isNotEqualTo("{\"test\": \"${json-unit.any-number}\"}"))
.hasMessage("\n" +
"Expecting:\n" +
"Expecting actual:\n" +
" {\"test\":1}\n" +
"not to be equal to:\n" +
" \"{\"test\": \"${json-unit.any-number}\"}\"\n" +
Expand Down Expand Up @@ -1195,7 +1195,7 @@ void positiveArrayIndexOutOfBounds() {
void arrayThatContainsShouldFailOnMissingNode() {
assertThatThrownBy(() -> assertThatJson("{\"test\":[{\"id\":36},{\"id\":37},{\"id\":38}]}").node("test").isArray().contains("{\"id\":42}"))
.hasMessage("[Different value found in node \"test\"] \n" +
"Expecting ArrayList:\n" +
"Expecting JsonList:\n" +
" [{\"id\":36}, {\"id\":37}, {\"id\":38}]\n" +
"to contain:\n" +
" [\"{\"id\":42}\"]\n" +
Expand Down Expand Up @@ -1576,7 +1576,7 @@ protected void jsonPathShouldBeAbleToUseArrays() {
" }"
)))
.hasMessage("[Different value found in node \"$.store.book\"] \n" +
"Expecting ArrayList:\n" +
"Expecting JsonList:\n" +
" [{\"author\":\"Nigel Rees\",\"category\":\"reference\",\"price\":8.95,\"title\":\"Sayings of the Century\"},\n" +
" {\"author\":\"Evelyn Waugh\",\"category\":\"fiction\",\"price\":12.99,\"title\":\"Sword of Honour\"},\n" +
" {\"author\":\"Herman Melville\",\"category\":\"fiction\",\"isbn\":\"0-553-21311-3\",\"price\":8.99,\"title\":\"Moby Dick\"},\n" +
Expand Down

0 comments on commit b13ab78

Please sign in to comment.