public class PrivatePartialMockingExampleTest {
@Test
public void spyingOnPrivateMethodsWorks() throws Exception {
final String expected = "TEST VALUE";
PrivatePartialMockingExample underTest = spy(new PrivatePartialMockingExample());
final String nameOfMethodToMock = "methodToMock";
final String input = "input";
when(underTest, nameOfMethodToMock, input).thenReturn(expected);
assertEquals(expected, underTest.methodToTest());
verifyPrivate(underTest).invoke(nameOfMethodToMock, input);
}