public class NoDuplicateTest {
@Test
@PrepareForTest(FinalDemo.class)
public void assertThatPrepareForTestAnnotationAtMethodLevelButNotClassLevelWorks() throws Exception {
FinalDemo tested = createMock(FinalDemo.class);
String expected = "Hello altered World";
expect(tested.say("hello")).andReturn("Hello altered World");
replay(tested);
String actual = tested.say("hello");
verify(tested);
assertEquals("Expected and actual did not match", expected, actual);
// Should still be mocked by now.
try {
tested.say("world");
fail("Should throw AssertionError!");
} catch (AssertionError e) {
assertEquals("\n Unexpected method call FinalDemo.say(\"world\"):", e.getMessage());
}
}