Add map flatExtracting example
This commit is contained in:
parent
f0781d6f3d
commit
cda778cc17
|
@ -113,6 +113,7 @@ public abstract class AbstractAssertionsExamples {
|
|||
protected static BasketBallPlayer durant;
|
||||
protected static BasketBallPlayer noah;
|
||||
protected static BasketBallPlayer tonyParker;
|
||||
protected static BasketBallPlayer ginobili;
|
||||
protected static BasketBallPlayer dwayne;
|
||||
protected static List<BasketBallPlayer> basketBallPlayers;
|
||||
protected static PotentialMvpCondition potentialMvp;
|
||||
|
@ -128,11 +129,15 @@ public abstract class AbstractAssertionsExamples {
|
|||
tonyParker.setAssistsPerGame(9);
|
||||
tonyParker.setPointsPerGame(21);
|
||||
tonyParker.setReboundsPerGame(5);
|
||||
james = new BasketBallPlayer(new Name("Lebron", "James"), "Miami Heat");
|
||||
ginobili = new BasketBallPlayer(new Name("Manu", "Ginobili"), "Spurs");
|
||||
ginobili.setAssistsPerGame(6);
|
||||
ginobili.setPointsPerGame(11);
|
||||
ginobili.setReboundsPerGame(5);
|
||||
james = new BasketBallPlayer(new Name("Lebron", "James"), "Cleveland");
|
||||
james.setAssistsPerGame(6);
|
||||
james.setPointsPerGame(27);
|
||||
james.setReboundsPerGame(8);
|
||||
dwayne = new BasketBallPlayer(new Name("Dwayne", "Wade"), "Miami Heat");
|
||||
dwayne = new BasketBallPlayer(new Name("Dwayne", "Wade"), "Cleveland");
|
||||
dwayne.setAssistsPerGame(16);
|
||||
dwayne.setPointsPerGame(55);
|
||||
dwayne.setReboundsPerGame(16);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
package org.assertj.examples;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
import static org.assertj.examples.data.Race.MAN;
|
||||
|
@ -25,10 +26,12 @@ import static org.assertj.examples.data.Ring.vilya;
|
|||
import java.util.AbstractMap.SimpleImmutableEntry;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.assertj.core.api.Condition;
|
||||
import org.assertj.examples.data.BasketBallPlayer;
|
||||
import org.assertj.examples.data.Ring;
|
||||
import org.assertj.examples.data.TolkienCharacter;
|
||||
import org.junit.Test;
|
||||
|
@ -211,6 +214,16 @@ public class MapAssertionsExamples extends AbstractAssertionsExamples {
|
|||
assertThat(ringBearers).hasValueSatisfying(oneRingBearer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void map_flatExtracting_examples() {
|
||||
Map<String, List<BasketBallPlayer>> teams = new HashMap<>();
|
||||
teams.put("spurs", asList(tonyParker, ginobili));
|
||||
teams.put("cavs", asList(james, dwayne));
|
||||
|
||||
assertThat(teams).flatExtracting("spurs", "cavs")
|
||||
.containsExactly(tonyParker, ginobili, james, dwayne);
|
||||
}
|
||||
|
||||
private static <K, V> Map.Entry<K, V> javaMapEntry(K key, V value) {
|
||||
return new SimpleImmutableEntry<>(key, value);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue