### Question:
Servant { public void giveCompliments(Royalty r) { r.receiveCompliments(); } Servant(String name); void feed(Royalty r); void giveWine(Royalty r); void giveCompliments(Royalty r); boolean checkIfYouWillBeHanged(List<Royalty> tableGuests); public String name; }### Answer:
@Test public void testGiveCompliments() { final Royalty royalty = mock(Royalty.class); final Servant servant = new Servant("test"); servant.giveCompliments(royalty); verify(royalty).receiveCompliments(); verifyNoMoreInteractions(royalty); }
@Test public void testGiveCompliments() { final var royalty = mock(Royalty.class); final var servant = new Servant("test"); servant.giveCompliments(royalty); verify(royalty).receiveCompliments(); verifyNoMoreInteractions(royalty); }
@Test public void testGiveCompliments() throws Exception { final Royalty royalty = mock(Royalty.class); final Servant servant = new Servant("test"); servant.giveCompliments(royalty); verify(royalty).receiveCompliments(); verifyNoMoreInteractions(royalty); }