### Question:
Hayes extends Modem { @Override public void accept(ModemVisitor modemVisitor) { if (modemVisitor instanceof HayesVisitor) { ((HayesVisitor) modemVisitor).visit(this); } else { LOGGER.info("Only HayesVisitor is allowed to visit Hayes modem"); } }  @Override void accept(ModemVisitor modemVisitor); @Override String toString();  }### Answer:
@Test public void testAcceptForDos() { Hayes hayes = new Hayes(); ConfigureForDosVisitor mockVisitor = mock(ConfigureForDosVisitor.class); hayes.accept(mockVisitor); verify((HayesVisitor)mockVisitor).visit(eq(hayes)); }
@Test public void testAcceptForUnix() { Hayes hayes = new Hayes(); ConfigureForUnixVisitor mockVisitor = mock(ConfigureForUnixVisitor.class); hayes.accept(mockVisitor); verifyZeroInteractions(mockVisitor); }
@Test public void testAcceptForDos() { var hayes = new Hayes(); var mockVisitor = mock(ConfigureForDosVisitor.class); hayes.accept(mockVisitor); verify((HayesVisitor)mockVisitor).visit(eq(hayes)); }
@Test public void testAcceptForUnix() { var hayes = new Hayes(); var mockVisitor = mock(ConfigureForUnixVisitor.class); hayes.accept(mockVisitor); verifyZeroInteractions(mockVisitor); }