AbstractMessageService implements MessageService { @Override public final String generateMessage(String name) { return String.format(getTemplate(), getHelloText(), name); }  @Override final String generateMessage(String name);  }
@Test public void mockUnitTest() { MessageService messageService = mock(MessageService.class); when(messageService.generateMessage(anyString())).thenReturn("Foo!"); GreetingClient client = new GreetingClient(messageService); assertEquals("FOO!", client.greetUser("doesn't matter")); }