### Question:
CardsGridComponent { public void setupCards(final List<CardComponent> cards) { setCardFrames(asFrames(cards)); getView().clearGrid(); asElements(getCardFrames()).forEach(getView()::appendCard); setupEmptyState(getCardFrames().isEmpty()); } @Inject  CardsGridComponent(final View view,
                              final ManagedInstance<CardFrameComponent> cardFrameInstances); void setupCards(final List<CardComponent> cards); void setEmptyState(final HTMLElement emptyStateElement); void enableReadOnlyModeForAllCards(); HTMLElement getElement();  }### Answer:
@Test public void testSetupCards() { final CardComponent card1 = mock(CardComponent.class); final CardComponent card2 = mock(CardComponent.class); final CardFrameComponent frame1 = mock(CardFrameComponent.class); final CardFrameComponent frame2 = mock(CardFrameComponent.class); final HTMLElement htmlElement1 = mock(HTMLElement.class); final HTMLElement htmlElement2 = mock(HTMLElement.class); final List<CardComponent> cards = asList(card1, card2); when(frames.get()).thenReturn(frame1, frame2); when(frame1.getElement()).thenReturn(htmlElement1); when(frame2.getElement()).thenReturn(htmlElement2); cardsGrid.setupCards(cards); verify(cardsGrid).setCardFrames(asList(frame1, frame2)); verify(frame1).initialize(cardsGrid, card1); verify(frame2).initialize(cardsGrid, card2); verify(view).clearGrid(); verify(view).appendCard(htmlElement1); verify(view).appendCard(htmlElement2); }
@Test public void testSetupCardsWhenCardsListIsEmptyAndEmptyStateElementIsNotPresent() { cardsGrid.setupCards(emptyList()); verify(view).clearGrid(); verifyNoMoreInteractions(view); }