Skip to content

Commit

Permalink
upgrade to assertj-core 3.17.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis committed Sep 19, 2020
1 parent bffb48d commit 00a3c62
Show file tree
Hide file tree
Showing 47 changed files with 202 additions and 105 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.11.1</version>
<version>3.17.2</version>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
Expand Down
49 changes: 48 additions & 1 deletion src/main/java/org/assertj/vavr/api/AbstractMapAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
import static org.assertj.core.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty;
import static org.assertj.core.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs;
import static org.assertj.core.error.ShouldHaveSize.shouldHaveSize;
import static org.assertj.core.error.ShouldHaveSizeBetween.shouldHaveSizeBetween;
import static org.assertj.core.error.ShouldHaveSizeGreaterThan.shouldHaveSizeGreaterThan;
import static org.assertj.core.error.ShouldHaveSizeGreaterThanOrEqualTo.shouldHaveSizeGreaterThanOrEqualTo;
import static org.assertj.core.error.ShouldHaveSizeLessThan.shouldHaveSizeLessThan;
import static org.assertj.core.error.ShouldHaveSizeLessThanOrEqualTo.shouldHaveSizeLessThanOrEqualTo;
import static org.assertj.core.error.ShouldNotBeEmpty.shouldNotBeEmpty;
import static org.assertj.core.util.Arrays.array;
import static org.assertj.core.util.IterableUtil.sizeOf;
Expand Down Expand Up @@ -357,13 +362,54 @@ public SELF hasSize(int expectedSize) {
return myself;
}

@Override
public SELF hasSizeGreaterThan(int boundary) {
isNotNull();
if (actual.size() <= boundary)
throwAssertionError(shouldHaveSizeGreaterThan(actual, actual.size(), boundary));
return myself;
}

@Override
public SELF hasSizeGreaterThanOrEqualTo(int boundary) {
isNotNull();
if (actual.size() < boundary)
throwAssertionError(shouldHaveSizeGreaterThanOrEqualTo(actual, actual.size(), boundary));
return myself;
}

@Override
public SELF hasSizeLessThan(int boundary) {
isNotNull();
if (actual.size() >= boundary)
throwAssertionError(shouldHaveSizeLessThan(actual, actual.size(), boundary));
return myself;
}

@Override
public SELF hasSizeLessThanOrEqualTo(int boundary) {
isNotNull();
if (actual.size() > boundary)
throwAssertionError(shouldHaveSizeLessThanOrEqualTo(actual, actual.size(), boundary));
return myself;
}

@Override
public SELF hasSizeBetween(int lowerBoundary, int higherBoundary) {
isNotNull();
if ((actual.size() > higherBoundary) || (actual.size() < lowerBoundary)) {
throwAssertionError(shouldHaveSizeBetween(actual, actual.size(), lowerBoundary, higherBoundary));
}
return myself;
}

@Override
public SELF hasSameSizeAs(Iterable<?> other) {
isNotNull();
checkNotNull(other, "The other Iterable to compare actual size with should not be null");
final long expectedSize = sizeOf(other);
if (actual.size() != expectedSize)
throwAssertionError(shouldHaveSameSizeAs(actual, actual.size(), expectedSize));
throwAssertionError(shouldHaveSameSizeAs(actual, other, actual.size(), expectedSize));
return myself;
}

Expand All @@ -384,4 +430,5 @@ public SELF usingDefaultElementComparator() {
elementComparisonStrategy = StandardComparisonStrategy.instance();
return myself;
}

}
50 changes: 48 additions & 2 deletions src/main/java/org/assertj/vavr/api/AbstractMultimapAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
import static org.assertj.core.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty;
import static org.assertj.core.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs;
import static org.assertj.core.error.ShouldHaveSize.shouldHaveSize;
import static org.assertj.core.error.ShouldHaveSizeBetween.shouldHaveSizeBetween;
import static org.assertj.core.error.ShouldHaveSizeGreaterThan.shouldHaveSizeGreaterThan;
import static org.assertj.core.error.ShouldHaveSizeGreaterThanOrEqualTo.shouldHaveSizeGreaterThanOrEqualTo;
import static org.assertj.core.error.ShouldHaveSizeLessThan.shouldHaveSizeLessThan;
import static org.assertj.core.error.ShouldHaveSizeLessThanOrEqualTo.shouldHaveSizeLessThanOrEqualTo;
import static org.assertj.core.error.ShouldNotBeEmpty.shouldNotBeEmpty;
import static org.assertj.core.util.Arrays.array;
import static org.assertj.core.util.IterableUtil.sizeOf;
import static org.assertj.core.util.Preconditions.checkNotNull;

class AbstractMultimapAssert<SELF extends AbstractMultimapAssert<SELF, ACTUAL, KEY, VALUE>, ACTUAL extends Multimap<KEY, VALUE>, KEY, VALUE>
abstract class AbstractMultimapAssert<SELF extends AbstractMultimapAssert<SELF, ACTUAL, KEY, VALUE>, ACTUAL extends Multimap<KEY, VALUE>, KEY, VALUE>
extends AbstractValueAssert<SELF, ACTUAL> implements EnumerableAssert<SELF, Tuple2<? extends KEY, ? extends VALUE>> {

private final Multimaps multimaps = Multimaps.instance();
Expand Down Expand Up @@ -338,13 +343,54 @@ public SELF hasSize(int expectedSize) {
return myself;
}

@Override
public SELF hasSizeGreaterThan(int boundary) {
isNotNull();
if (actual.size() <= boundary)
throwAssertionError(shouldHaveSizeGreaterThan(actual, actual.size(), boundary));
return myself;
}

@Override
public SELF hasSizeGreaterThanOrEqualTo(int boundary) {
isNotNull();
if (actual.size() < boundary)
throwAssertionError(shouldHaveSizeGreaterThanOrEqualTo(actual, actual.size(), boundary));
return myself;
}

@Override
public SELF hasSizeLessThan(int boundary) {
isNotNull();
if (actual.size() >= boundary)
throwAssertionError(shouldHaveSizeLessThan(actual, actual.size(), boundary));
return myself;
}

@Override
public SELF hasSizeLessThanOrEqualTo(int boundary) {
isNotNull();
if (actual.size() > boundary)
throwAssertionError(shouldHaveSizeLessThanOrEqualTo(actual, actual.size(), boundary));
return myself;
}

@Override
public SELF hasSizeBetween(int lowerBoundary, int higherBoundary) {
isNotNull();
if ((actual.size() > higherBoundary) || (actual.size() < lowerBoundary)) {
throwAssertionError(shouldHaveSizeBetween(actual, actual.size(), lowerBoundary, higherBoundary));
}
return myself;
}

@Override
public SELF hasSameSizeAs(Iterable<?> other) {
isNotNull();
checkNotNull(other, "The other Iterable to compare actual size with should not be null");
final long expectedSize = sizeOf(other);
if (actual.size() != expectedSize)
throwAssertionError(shouldHaveSameSizeAs(actual, actual.size(), expectedSize));
throwAssertionError(shouldHaveSameSizeAs(actual, other, actual.size(), expectedSize));
return myself;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ void should_fail_if_Map_does_not_contain_all_entries() {
() -> assertThat(actual).containsAllEntriesOf(List.of(ENTRY1, ENTRY2))
)
.isInstanceOf(AssertionError.class)
.hasMessage("\nExpecting:\n <HashMap((key1, value1), (key3, value3))>\nto contain:\n <[(key1, value1), (key2, value2)]>\nbut could not find:\n <HashSet((key2, value2))>\n");
.hasMessage("\nExpecting HashMap:\n <[(key1, value1), (key3, value3)]>\nto contain:\n <[(key1, value1), (key2, value2)]>\nbut could not find the following element(s):\n <[(key2, value2)]>\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ void should_fail_if_Map_does_not_contain_the_given_entry() {
() -> assertThat(actual).containsEntry("key2", "value2")
)
.isInstanceOf(AssertionError.class)
.hasMessage("\nExpecting:\n <HashMap((key1, value1), (key3, value3))>\nto contain:\n <[(key2, value2)]>\nbut could not find:\n <HashSet((key2, value2))>\n");
.hasMessage("\nExpecting HashMap:\n <[(key1, value1), (key3, value3)]>\nto contain:\n <[(key2, value2)]>\nbut could not find the following element(s):\n <[(key2, value2)]>\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ void should_fail_if_Map_and_entries_have_different_sizes() {
.hasMessage(
"\nActual and expected should have same size but actual size is:\n" +
" <0>\n" +
"while expected is:\n" +
"while expected size is:\n" +
" <1>\n" +
"Actual was:\n" +
"<LinkedHashMap()>"
" []\n" +
"Expected was:\n" +
" [(key1, value1)]"
);
}

Expand Down Expand Up @@ -112,13 +114,13 @@ void should_fail_if_Map_does_not_contain_all_entries() {
.isInstanceOf(AssertionError.class)
.hasMessage(
"\nExpecting:\n" +
" <LinkedHashMap((key1, value1), (key3, value3))>\n" +
" <[(key1, value1), (key3, value3)]>\n" +
"to contain exactly (and in same order):\n" +
" <List((key1, value1), (key2, value2))>\n" +
" <[(key1, value1), (key2, value2)]>\n" +
"but some elements were not found:\n" +
" <LinkedHashMap((key2, value2))>\n" +
" <[(key2, value2)]>\n" +
"and others were not expected:\n" +
" <LinkedHashMap((key3, value3))>\n"
" <[(key3, value3)]>\n"
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void should_fail_if_Map_does_not_contain_given_key() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"to contain key:\n" +
" <\"key-3\">"
);
Expand All @@ -67,7 +67,7 @@ void should_fail_if_Map_does_not_contain_key_as_null() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"to contain key:\n" +
" <null>"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void should_fail_if_Map_contains_different_keys() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"to contain key:\n" +
" <\"key-3\">"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ void should_fail_if_Map_contains_more_than_given_keys() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"to contain only following keys:\n" +
" <HashSet(key-1)>\n" +
" <[\"key-1\"]>\n" +
"keys not found:\n" +
" <HashSet()>\n" +
" <[]>\n" +
"and keys not expected:\n" +
" <HashSet(key-2)>\n"
" <[\"key-2\"]>\n"
);
}

Expand All @@ -94,13 +94,13 @@ void should_fail_if_Map_has_same_size_but_contains_different_keys() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"to contain only following keys:\n" +
" <HashSet(key-1, key-3)>\n" +
" <[\"key-1\", \"key-3\"]>\n" +
"keys not found:\n" +
" <HashSet(key-3)>\n" +
" <[\"key-3\"]>\n" +
"and keys not expected:\n" +
" <HashSet(key-2)>\n"
" <[\"key-2\"]>\n"
);
}
}
24 changes: 12 additions & 12 deletions src/test/java/org/assertj/vavr/api/MapAssert_containsOnly_Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ void should_fail_if_Map_contains_more_than_given_entries() {
.isInstanceOf(AssertionError.class)
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
"Expecting HashMap:\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"to contain only:\n" +
" <HashMap((key-1, value-1))>\n" +
"but the following elements were unexpected:\n" +
" <HashMap((key-2, value-2))>\n"
" <[(key-1, value-1)]>\n" +
"but the following element(s) were unexpected:\n" +
" <[(key-2, value-2)]>\n"
);
}

Expand All @@ -104,14 +104,14 @@ void should_fail_if_Map_has_same_size_but_contains_different_entries() {
.isInstanceOf(AssertionError.class)
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
"Expecting HashMap:\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"to contain only:\n" +
" <HashMap((key-1, value-1), (key-3, value-3))>\n" +
"elements not found:\n" +
" <HashMap((key-3, value-3))>\n" +
"and elements not expected:\n" +
" <HashMap((key-2, value-2))>\n"
" <[(key-1, value-1), (key-3, value-3)]>\n" +
"element(s) not found:\n" +
" <[(key-3, value-3)]>\n" +
"and element(s) not expected:\n" +
" <[(key-2, value-2)]>\n"
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void should_fail_if_Map_does_not_contain_given_values() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"to contain value:\n" +
" <\"value-3\">"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void should_fail_if_Map_does_not_contain_all_given_values() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"to contain value:\n" +
" <\"value-3\">"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ void should_fail_if_Map_does_not_contain_any_of_entries() {
() -> assertThat(actual).containsAnyOf(ENTRY2)
)
.isInstanceOf(AssertionError.class)
.hasMessage("\nExpecting:\n <HashMap((key1, value1), (key3, value3))>\nto contain at least one of the following elements:\n <[(key2, value2)]>\nbut none were found ");
.hasMessage("\nExpecting:\n <[(key1, value1), (key3, value3)]>\nto contain at least one of the following elements:\n <[(key2, value2)]>\nbut none were found ");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ void should_fail_if_Map_does_not_contain_all_entries() {
() -> assertThat(actual).contains(ENTRY1, ENTRY2)
)
.isInstanceOf(AssertionError.class)
.hasMessage("\nExpecting:\n <HashMap((key1, value1), (key3, value3))>\nto contain:\n <[(key1, value1), (key2, value2)]>\nbut could not find:\n <HashSet((key2, value2))>\n");
.hasMessage("\nExpecting HashMap:\n <[(key1, value1), (key3, value3)]>\nto contain:\n <[(key1, value1), (key2, value2)]>\nbut could not find the following element(s):\n <[(key2, value2)]>\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ void should_fail_if_Map_contains_the_given_entry() {
() -> assertThat(actual).doesNotContainEntry("key1", "value1")
)
.isInstanceOf(AssertionError.class)
.hasMessage("\nExpecting\n <HashMap((key1, value1), (key3, value3))>\nnot to contain\n <[(key1, value1)]>\nbut found\n <HashSet((key1, value1))>\n");
.hasMessage("\nExpecting\n <[(key1, value1), (key3, value3)]>\nnot to contain\n <[(key1, value1)]>\nbut found\n <[(key1, value1)]>\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void should_fail_if_Map_contains_given_key() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"not to contain key:\n" +
" <\"key-1\">"
);
Expand All @@ -74,7 +74,7 @@ void should_fail_if_Map_contains_null_as_key() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((null, value-1), (key-2, value-2))>\n" +
" <[(null, value-1), (key-2, value-2)]>\n" +
"not to contain key:\n" +
" <null>"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void should_fail_if_Map_contains_different_keys() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"not to contain key:\n" +
" <\"key-1\">"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void should_fail_if_Map_contains_a_given_value() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"not to contain value:\n" +
" <\"value-1\">"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void should_fail_if_Map_contains_some_of_given_values() {
.hasMessage(
"\n" +
"Expecting:\n" +
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
" <[(key-1, value-1), (key-2, value-2)]>\n" +
"not to contain values:\n" +
" <[\"value-1\"]>"
);
Expand Down
Loading

0 comments on commit 00a3c62

Please sign in to comment.