### Question:
JDKImperativeDeckOfCardsAsList { public Map<Suit, List<Card>> getCardsBySuit() { return this.cardsBySuit; } JDKImperativeDeckOfCardsAsList(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(Deque<Card> shuffled, int hands, int cardsPerHand); List<Card> diamonds(); List<Card> hearts(); List<Card> spades(); List<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); List<Card> getCards(); Map<Suit, List<Card>> getCardsBySuit();  }### Answer:
@Test public void cardsBySuit() { var jdkCardsBySuit = this.jdkDeck.getCardsBySuit(); Assert.assertEquals(4, jdkCardsBySuit.size()); Assert.assertEquals(13, jdkCardsBySuit.get(Suit.CLUBS).size()); Assert.assertEquals(13, jdkCardsBySuit.get(Suit.DIAMONDS).size()); Assert.assertEquals(13, jdkCardsBySuit.get(Suit.SPADES).size()); Assert.assertEquals(13, jdkCardsBySuit.get(Suit.HEARTS).size()); }
@Test public void cardsBySuitIsImmutable() { var jdkCardsBySuit = this.jdkDeck.getCardsBySuit(); Verify.assertThrows( UnsupportedOperationException.class, () -> jdkCardsBySuit.remove(Suit.CLUBS)); Verify.assertThrows( UnsupportedOperationException.class, jdkCardsBySuit::clear); Verify.assertThrows( UnsupportedOperationException.class, () -> jdkCardsBySuit.get(Suit.CLUBS).remove(0)); Verify.assertThrows( UnsupportedOperationException.class, () -> jdkCardsBySuit.get(Suit.CLUBS).add(null)); Verify.assertThrows( UnsupportedOperationException.class, jdkCardsBySuit.get(Suit.CLUBS)::clear); }