use of samples.simplemix.SimpleMixConstruction in project powermock by powermock.
the class SimpleMixTest method staticPartialFinalMocking.
@PrepareForTest({ SimpleMixUtilities.class, SimpleMixCollaborator.class, SimpleMix.class })
@Test
public void staticPartialFinalMocking() throws Exception {
SimpleMix tested = spy(new SimpleMix());
when(tested, "getValue").thenReturn(0);
SimpleMixCollaborator simpleMixCollaboratorMock = mock(SimpleMixCollaborator.class);
mockStatic(SimpleMixUtilities.class);
SimpleMixConstruction simpleMixConstructionMock = mock(SimpleMixConstruction.class);
Whitebox.setInternalState(tested, simpleMixCollaboratorMock);
when(SimpleMixUtilities.getRandomInteger()).thenReturn(10);
when(simpleMixCollaboratorMock.getRandomInteger()).thenReturn(6);
whenNew(SimpleMixConstruction.class).withNoArguments().thenReturn(simpleMixConstructionMock);
when(simpleMixConstructionMock.getMyValue()).thenReturn(1);
assertEquals(4, tested.calculate());
verifyStatic(SimpleMixUtilities.class);
SimpleMixUtilities.getRandomInteger();
verifyNew(SimpleMixConstruction.class).withNoArguments();
verifyPrivate(tested).invoke(method(SimpleMix.class, "getValue")).withNoArguments();
}
Aggregations