Skip to content

Commit 7da33b4

Browse files
authored
Adds Multimap assertions and assumptions (#77)
Fixes #77
1 parent 04872fd commit 7da33b4

36 files changed

+3044
-104
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public SELF allSatisfy(BiConsumer<? super KEY, ? super VALUE> entryRequirements)
7878
* @return {@code this} assertion object.
7979
* @throws NullPointerException if the given values is {@code null}.
8080
* @throws AssertionError if the actual map is {@code null}.
81-
* @throws AssertionError if the actual map not contains the given {@code key}.
81+
* @throws AssertionError if the actual map does not contain the given {@code key}.
8282
* @throws AssertionError if the actual map contains the given key, but value does not match the given {@code valueCondition}.
8383
*/
8484
public SELF hasEntrySatisfying(KEY key, Condition<? super VALUE> valueCondition) {

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

Lines changed: 368 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.assertj.vavr.api;
2+
3+
import io.vavr.collection.Multimap;
4+
5+
/**
6+
* Assertions for {@link io.vavr.collection.Multimap}.
7+
*
8+
* @param <KEY> key type of the {@link Multimap}.
9+
* @param <VALUE> value type of the {@link Multimap}.
10+
* @author Michał Chmielarz
11+
*/
12+
public class MultimapAssert<KEY, VALUE> extends AbstractMultimapAssert<MultimapAssert<KEY, VALUE>, Multimap<KEY, VALUE>, KEY, VALUE> {
13+
14+
MultimapAssert(Multimap<KEY, VALUE> multimap) {
15+
super(multimap, MultimapAssert.class);
16+
}
17+
18+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.assertj.core.error.ErrorMessageFactory;
55

66
/**
7-
* Creates an error message indicating that an assertion that verifies a map does not contains values.
7+
* Creates an error message indicating that an assertion that verifies a map does not contain values.
88
*
99
* @author Michał Chmielarz
1010
*/

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io.vavr.Lazy;
1616
import io.vavr.collection.List;
1717
import io.vavr.collection.Map;
18+
import io.vavr.collection.Multimap;
1819
import io.vavr.collection.Seq;
1920
import io.vavr.control.Either;
2021
import io.vavr.control.Option;
@@ -35,7 +36,7 @@ private VavrAssertions() {
3536
}
3637

3738
/**
38-
* Create assertion for {@link io.vavr.control.Either}.
39+
* Creates assertion for {@link io.vavr.control.Either}.
3940
*
4041
* @param <LEFT> the type of a value contained on left by <code>actual {@link Either}</code>.
4142
* @param <RIGHT> the type of a value contained on right by <code>actual {@link Either}</code>.
@@ -48,7 +49,7 @@ public static <LEFT, RIGHT> EitherAssert<LEFT, RIGHT> assertThat(Either<LEFT, RI
4849
}
4950

5051
/**
51-
* Create assertion for {@link Lazy}.
52+
* Creates assertion for {@link Lazy}.
5253
*
5354
* @param <VALUE> the type of a value contained by <code>actual {@link Lazy}</code>.
5455
* @param actual the actual value.
@@ -60,7 +61,7 @@ public static <VALUE> LazyAssert<VALUE> assertThat(Lazy<VALUE> actual) {
6061
}
6162

6263
/**
63-
* Create assertion for {@link io.vavr.control.Option}.
64+
* Creates assertion for {@link io.vavr.control.Option}.
6465
*
6566
* @param <VALUE> the type of a value contained by <code>actual {@link Option}</code>.
6667
* @param actual the actual value.
@@ -72,7 +73,7 @@ public static <VALUE> OptionAssert<VALUE> assertThat(Option<VALUE> actual) {
7273
}
7374

7475
/**
75-
* Create assertion for {@link io.vavr.control.Try}.
76+
* Creates assertion for {@link io.vavr.control.Try}.
7677
*
7778
* @param <VALUE> the type of a value contained by <code>actual {@link Try}</code>.
7879
* @param actual the actual value.
@@ -84,7 +85,7 @@ public static <VALUE> TryAssert<VALUE> assertThat(Try<VALUE> actual) {
8485
}
8586

8687
/**
87-
* Create assertion for {@link io.vavr.collection.List}.
88+
* Creates assertion for {@link io.vavr.collection.List}.
8889
*
8990
* @param <VALUE> the type of elements contained by <code>actual {@link List}</code>.
9091
* @param actual the actual value.
@@ -96,7 +97,7 @@ public static <VALUE> SeqAssert<VALUE> assertThat(Seq<VALUE> actual) {
9697
}
9798

9899
/**
99-
* Create assertion for {@link io.vavr.control.Validation}.
100+
* Creates assertion for {@link io.vavr.control.Validation}.
100101
*
101102
* @param <INVALID> type of the value in the case of the invalid {@link Validation}.
102103
* @param <VALID> type of the value in the case of the valid {@link Validation}.
@@ -109,7 +110,7 @@ public static <INVALID, VALID> ValidationAssert<INVALID, VALID> assertThat(Valid
109110
}
110111

111112
/**
112-
* Create assertion for {@link io.vavr.collection.Map}.
113+
* Creates assertion for {@link io.vavr.collection.Map}.
113114
*
114115
* @param <KEY> key type of the {@link Map}.
115116
* @param <VALUE> value type of the {@link Map}.
@@ -121,4 +122,17 @@ public static <KEY, VALUE> MapAssert<KEY, VALUE> assertThat(Map<KEY, VALUE> actu
121122
return new MapAssert<>(actual);
122123
}
123124

125+
/**
126+
* Creates assertion for {@link io.vavr.collection.Multimap}.
127+
*
128+
* @param <KEY> key type of the {@link Multimap}.
129+
* @param <VALUE> value type of the {@link Multimap}.
130+
* @param actual the actual value.
131+
* @return the created assertion object.
132+
*/
133+
@CheckReturnValue
134+
public static <KEY, VALUE> MultimapAssert<KEY, VALUE> assertThat(Multimap<KEY, VALUE> actual) {
135+
return new MultimapAssert<>(actual);
136+
}
137+
124138
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.vavr.Lazy;
44
import io.vavr.collection.Map;
5+
import io.vavr.collection.Multimap;
56
import io.vavr.collection.Seq;
67
import io.vavr.control.Either;
78
import io.vavr.control.Option;
@@ -98,6 +99,20 @@ public static <VALUE> AbstractLazyAssert<?, VALUE> assumeThat(Lazy<VALUE> actual
9899
return asAssumption(MapAssert.class, Map.class, actual);
99100
}
100101

102+
/**
103+
* Creates a new instance of <code>{@link MultimapAssert}</code> assumption.
104+
*
105+
* @param <K> the type of keys in the multimap.
106+
* @param <V> the type of values in the multimap.
107+
* @param actual the actual value.
108+
* @return the created assumption for assertion object.
109+
*/
110+
@CheckReturnValue
111+
@SuppressWarnings("unchecked")
112+
public static <K, V> AbstractMultimapAssert<?, ?, K, V> assumeThat(Multimap<K, V> actual) {
113+
return asAssumption(MultimapAssert.class, Multimap.class, actual);
114+
}
115+
101116
/**
102117
* Creates a new instance of <code>{@link OptionAssert}</code> assumption.
103118
*

0 commit comments

Comments
 (0)