Skip to content

Commit 391e2b9

Browse files
authored
upgrade to assertj-core 3.17.2 (#101)
* upgrade to assertj-core 3.17.2 * add additional assertions: MapAssert_hasSizeGreaterThan_Test MapAssert_hasSizeLessThan_Test MapAssert_isEqualTo_Test MultimapAssert_hasSizeGreaterThan_Test MultimapAssert_hasSizeLessThan_Test MultiMapAssert_isEqualTo_Test
1 parent bffb48d commit 391e2b9

File tree

55 files changed

+669
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+669
-105
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<dependency>
9393
<groupId>org.assertj</groupId>
9494
<artifactId>assertj-core</artifactId>
95-
<version>3.11.1</version>
95+
<version>3.17.2</version>
9696
</dependency>
9797
<dependency>
9898
<groupId>io.vavr</groupId>

src/main/java/org/assertj/vavr/api/AbstractMapAssert.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
import static org.assertj.core.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty;
3232
import static org.assertj.core.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs;
3333
import static org.assertj.core.error.ShouldHaveSize.shouldHaveSize;
34+
import static org.assertj.core.error.ShouldHaveSizeBetween.shouldHaveSizeBetween;
35+
import static org.assertj.core.error.ShouldHaveSizeGreaterThan.shouldHaveSizeGreaterThan;
36+
import static org.assertj.core.error.ShouldHaveSizeGreaterThanOrEqualTo.shouldHaveSizeGreaterThanOrEqualTo;
37+
import static org.assertj.core.error.ShouldHaveSizeLessThan.shouldHaveSizeLessThan;
38+
import static org.assertj.core.error.ShouldHaveSizeLessThanOrEqualTo.shouldHaveSizeLessThanOrEqualTo;
3439
import static org.assertj.core.error.ShouldNotBeEmpty.shouldNotBeEmpty;
3540
import static org.assertj.core.util.Arrays.array;
3641
import static org.assertj.core.util.IterableUtil.sizeOf;
@@ -357,13 +362,54 @@ public SELF hasSize(int expectedSize) {
357362
return myself;
358363
}
359364

365+
@Override
366+
public SELF hasSizeGreaterThan(int boundary) {
367+
isNotNull();
368+
if (actual.size() <= boundary)
369+
throwAssertionError(shouldHaveSizeGreaterThan(actual, actual.size(), boundary));
370+
return myself;
371+
}
372+
373+
@Override
374+
public SELF hasSizeGreaterThanOrEqualTo(int boundary) {
375+
isNotNull();
376+
if (actual.size() < boundary)
377+
throwAssertionError(shouldHaveSizeGreaterThanOrEqualTo(actual, actual.size(), boundary));
378+
return myself;
379+
}
380+
381+
@Override
382+
public SELF hasSizeLessThan(int boundary) {
383+
isNotNull();
384+
if (actual.size() >= boundary)
385+
throwAssertionError(shouldHaveSizeLessThan(actual, actual.size(), boundary));
386+
return myself;
387+
}
388+
389+
@Override
390+
public SELF hasSizeLessThanOrEqualTo(int boundary) {
391+
isNotNull();
392+
if (actual.size() > boundary)
393+
throwAssertionError(shouldHaveSizeLessThanOrEqualTo(actual, actual.size(), boundary));
394+
return myself;
395+
}
396+
397+
@Override
398+
public SELF hasSizeBetween(int lowerBoundary, int higherBoundary) {
399+
isNotNull();
400+
if ((actual.size() > higherBoundary) || (actual.size() < lowerBoundary)) {
401+
throwAssertionError(shouldHaveSizeBetween(actual, actual.size(), lowerBoundary, higherBoundary));
402+
}
403+
return myself;
404+
}
405+
360406
@Override
361407
public SELF hasSameSizeAs(Iterable<?> other) {
362408
isNotNull();
363409
checkNotNull(other, "The other Iterable to compare actual size with should not be null");
364410
final long expectedSize = sizeOf(other);
365411
if (actual.size() != expectedSize)
366-
throwAssertionError(shouldHaveSameSizeAs(actual, actual.size(), expectedSize));
412+
throwAssertionError(shouldHaveSameSizeAs(actual, other, actual.size(), expectedSize));
367413
return myself;
368414
}
369415

@@ -384,4 +430,5 @@ public SELF usingDefaultElementComparator() {
384430
elementComparisonStrategy = StandardComparisonStrategy.instance();
385431
return myself;
386432
}
433+
387434
}

src/main/java/org/assertj/vavr/api/AbstractMultimapAssert.java

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
import static org.assertj.core.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty;
1919
import static org.assertj.core.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs;
2020
import static org.assertj.core.error.ShouldHaveSize.shouldHaveSize;
21+
import static org.assertj.core.error.ShouldHaveSizeBetween.shouldHaveSizeBetween;
22+
import static org.assertj.core.error.ShouldHaveSizeGreaterThan.shouldHaveSizeGreaterThan;
23+
import static org.assertj.core.error.ShouldHaveSizeGreaterThanOrEqualTo.shouldHaveSizeGreaterThanOrEqualTo;
24+
import static org.assertj.core.error.ShouldHaveSizeLessThan.shouldHaveSizeLessThan;
25+
import static org.assertj.core.error.ShouldHaveSizeLessThanOrEqualTo.shouldHaveSizeLessThanOrEqualTo;
2126
import static org.assertj.core.error.ShouldNotBeEmpty.shouldNotBeEmpty;
2227
import static org.assertj.core.util.Arrays.array;
2328
import static org.assertj.core.util.IterableUtil.sizeOf;
2429
import static org.assertj.core.util.Preconditions.checkNotNull;
2530

26-
class AbstractMultimapAssert<SELF extends AbstractMultimapAssert<SELF, ACTUAL, KEY, VALUE>, ACTUAL extends Multimap<KEY, VALUE>, KEY, VALUE>
31+
abstract class AbstractMultimapAssert<SELF extends AbstractMultimapAssert<SELF, ACTUAL, KEY, VALUE>, ACTUAL extends Multimap<KEY, VALUE>, KEY, VALUE>
2732
extends AbstractValueAssert<SELF, ACTUAL> implements EnumerableAssert<SELF, Tuple2<? extends KEY, ? extends VALUE>> {
2833

2934
private final Multimaps multimaps = Multimaps.instance();
@@ -338,13 +343,54 @@ public SELF hasSize(int expectedSize) {
338343
return myself;
339344
}
340345

346+
@Override
347+
public SELF hasSizeGreaterThan(int boundary) {
348+
isNotNull();
349+
if (actual.size() <= boundary)
350+
throwAssertionError(shouldHaveSizeGreaterThan(actual, actual.size(), boundary));
351+
return myself;
352+
}
353+
354+
@Override
355+
public SELF hasSizeGreaterThanOrEqualTo(int boundary) {
356+
isNotNull();
357+
if (actual.size() < boundary)
358+
throwAssertionError(shouldHaveSizeGreaterThanOrEqualTo(actual, actual.size(), boundary));
359+
return myself;
360+
}
361+
362+
@Override
363+
public SELF hasSizeLessThan(int boundary) {
364+
isNotNull();
365+
if (actual.size() >= boundary)
366+
throwAssertionError(shouldHaveSizeLessThan(actual, actual.size(), boundary));
367+
return myself;
368+
}
369+
370+
@Override
371+
public SELF hasSizeLessThanOrEqualTo(int boundary) {
372+
isNotNull();
373+
if (actual.size() > boundary)
374+
throwAssertionError(shouldHaveSizeLessThanOrEqualTo(actual, actual.size(), boundary));
375+
return myself;
376+
}
377+
378+
@Override
379+
public SELF hasSizeBetween(int lowerBoundary, int higherBoundary) {
380+
isNotNull();
381+
if ((actual.size() > higherBoundary) || (actual.size() < lowerBoundary)) {
382+
throwAssertionError(shouldHaveSizeBetween(actual, actual.size(), lowerBoundary, higherBoundary));
383+
}
384+
return myself;
385+
}
386+
341387
@Override
342388
public SELF hasSameSizeAs(Iterable<?> other) {
343389
isNotNull();
344390
checkNotNull(other, "The other Iterable to compare actual size with should not be null");
345391
final long expectedSize = sizeOf(other);
346392
if (actual.size() != expectedSize)
347-
throwAssertionError(shouldHaveSameSizeAs(actual, actual.size(), expectedSize));
393+
throwAssertionError(shouldHaveSameSizeAs(actual, other, actual.size(), expectedSize));
348394
return myself;
349395
}
350396

src/test/java/org/assertj/vavr/api/MapAssert_containsAllEntriesOf_Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ void should_fail_if_Map_does_not_contain_all_entries() {
8989
() -> assertThat(actual).containsAllEntriesOf(List.of(ENTRY1, ENTRY2))
9090
)
9191
.isInstanceOf(AssertionError.class)
92-
.hasMessage("\nExpecting:\n <HashMap((key1, value1), (key3, value3))>\nto contain:\n <[(key1, value1), (key2, value2)]>\nbut could not find:\n <HashSet((key2, value2))>\n");
92+
.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");
9393
}
9494
}

src/test/java/org/assertj/vavr/api/MapAssert_containsEntry_Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ void should_fail_if_Map_does_not_contain_the_given_entry() {
5050
() -> assertThat(actual).containsEntry("key2", "value2")
5151
)
5252
.isInstanceOf(AssertionError.class)
53-
.hasMessage("\nExpecting:\n <HashMap((key1, value1), (key3, value3))>\nto contain:\n <[(key2, value2)]>\nbut could not find:\n <HashSet((key2, value2))>\n");
53+
.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");
5454
}
5555
}

src/test/java/org/assertj/vavr/api/MapAssert_containsExactly_Test.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ void should_fail_if_Map_and_entries_have_different_sizes() {
7575
.hasMessage(
7676
"\nActual and expected should have same size but actual size is:\n" +
7777
" <0>\n" +
78-
"while expected is:\n" +
78+
"while expected size is:\n" +
7979
" <1>\n" +
8080
"Actual was:\n" +
81-
"<LinkedHashMap()>"
81+
" []\n" +
82+
"Expected was:\n" +
83+
" [(key1, value1)]"
8284
);
8385
}
8486

@@ -112,13 +114,13 @@ void should_fail_if_Map_does_not_contain_all_entries() {
112114
.isInstanceOf(AssertionError.class)
113115
.hasMessage(
114116
"\nExpecting:\n" +
115-
" <LinkedHashMap((key1, value1), (key3, value3))>\n" +
117+
" <[(key1, value1), (key3, value3)]>\n" +
116118
"to contain exactly (and in same order):\n" +
117-
" <List((key1, value1), (key2, value2))>\n" +
119+
" <[(key1, value1), (key2, value2)]>\n" +
118120
"but some elements were not found:\n" +
119-
" <LinkedHashMap((key2, value2))>\n" +
121+
" <[(key2, value2)]>\n" +
120122
"and others were not expected:\n" +
121-
" <LinkedHashMap((key3, value3))>\n"
123+
" <[(key3, value3)]>\n"
122124
);
123125
}
124126

src/test/java/org/assertj/vavr/api/MapAssert_containsKey_Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void should_fail_if_Map_does_not_contain_given_key() {
5050
.hasMessage(
5151
"\n" +
5252
"Expecting:\n" +
53-
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
53+
" <[(key-1, value-1), (key-2, value-2)]>\n" +
5454
"to contain key:\n" +
5555
" <\"key-3\">"
5656
);
@@ -67,7 +67,7 @@ void should_fail_if_Map_does_not_contain_key_as_null() {
6767
.hasMessage(
6868
"\n" +
6969
"Expecting:\n" +
70-
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
70+
" <[(key-1, value-1), (key-2, value-2)]>\n" +
7171
"to contain key:\n" +
7272
" <null>"
7373
);

src/test/java/org/assertj/vavr/api/MapAssert_containsKeys_Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void should_fail_if_Map_contains_different_keys() {
7272
.hasMessage(
7373
"\n" +
7474
"Expecting:\n" +
75-
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
75+
" <[(key-1, value-1), (key-2, value-2)]>\n" +
7676
"to contain key:\n" +
7777
" <\"key-3\">"
7878
);

src/test/java/org/assertj/vavr/api/MapAssert_containsOnlyKeys_Test.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ void should_fail_if_Map_contains_more_than_given_keys() {
7373
.hasMessage(
7474
"\n" +
7575
"Expecting:\n" +
76-
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
76+
" <[(key-1, value-1), (key-2, value-2)]>\n" +
7777
"to contain only following keys:\n" +
78-
" <HashSet(key-1)>\n" +
78+
" <[\"key-1\"]>\n" +
7979
"keys not found:\n" +
80-
" <HashSet()>\n" +
80+
" <[]>\n" +
8181
"and keys not expected:\n" +
82-
" <HashSet(key-2)>\n"
82+
" <[\"key-2\"]>\n"
8383
);
8484
}
8585

@@ -94,13 +94,13 @@ void should_fail_if_Map_has_same_size_but_contains_different_keys() {
9494
.hasMessage(
9595
"\n" +
9696
"Expecting:\n" +
97-
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
97+
" <[(key-1, value-1), (key-2, value-2)]>\n" +
9898
"to contain only following keys:\n" +
99-
" <HashSet(key-1, key-3)>\n" +
99+
" <[\"key-1\", \"key-3\"]>\n" +
100100
"keys not found:\n" +
101-
" <HashSet(key-3)>\n" +
101+
" <[\"key-3\"]>\n" +
102102
"and keys not expected:\n" +
103-
" <HashSet(key-2)>\n"
103+
" <[\"key-2\"]>\n"
104104
);
105105
}
106106
}

src/test/java/org/assertj/vavr/api/MapAssert_containsOnly_Test.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ void should_fail_if_Map_contains_more_than_given_entries() {
8585
.isInstanceOf(AssertionError.class)
8686
.hasMessage(
8787
"\n" +
88-
"Expecting:\n" +
89-
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
88+
"Expecting HashMap:\n" +
89+
" <[(key-1, value-1), (key-2, value-2)]>\n" +
9090
"to contain only:\n" +
91-
" <HashMap((key-1, value-1))>\n" +
92-
"but the following elements were unexpected:\n" +
93-
" <HashMap((key-2, value-2))>\n"
91+
" <[(key-1, value-1)]>\n" +
92+
"but the following element(s) were unexpected:\n" +
93+
" <[(key-2, value-2)]>\n"
9494
);
9595
}
9696

@@ -104,14 +104,14 @@ void should_fail_if_Map_has_same_size_but_contains_different_entries() {
104104
.isInstanceOf(AssertionError.class)
105105
.hasMessage(
106106
"\n" +
107-
"Expecting:\n" +
108-
" <HashMap((key-1, value-1), (key-2, value-2))>\n" +
107+
"Expecting HashMap:\n" +
108+
" <[(key-1, value-1), (key-2, value-2)]>\n" +
109109
"to contain only:\n" +
110-
" <HashMap((key-1, value-1), (key-3, value-3))>\n" +
111-
"elements not found:\n" +
112-
" <HashMap((key-3, value-3))>\n" +
113-
"and elements not expected:\n" +
114-
" <HashMap((key-2, value-2))>\n"
110+
" <[(key-1, value-1), (key-3, value-3)]>\n" +
111+
"element(s) not found:\n" +
112+
" <[(key-3, value-3)]>\n" +
113+
"and element(s) not expected:\n" +
114+
" <[(key-2, value-2)]>\n"
115115
);
116116
}
117117
}

0 commit comments

Comments
 (0)