use of samples.privatefield.MockSelfPrivateFieldServiceClass in project powermock by powermock.
the class MockSelfPrivateFieldServiceClassTest method testGetCompositeMessage.
@Test
public void testGetCompositeMessage() throws Exception {
MockSelfPrivateFieldServiceClass tested = createPartialMock(MockSelfPrivateFieldServiceClass.class, "getOwnMessage");
Service serviceMock = createMock(Service.class);
setInternalState(tested, "service", serviceMock, MockSelfPrivateFieldServiceClass.class);
final String expected = "Hello world";
expectPrivate(tested, "getOwnMessage").andReturn("Hello");
expect(serviceMock.getServiceMessage()).andReturn(" world");
replay(serviceMock);
replay(tested);
final String actual = tested.getCompositeMessage();
verify(serviceMock);
verify(tested);
assertEquals(expected, actual);
}
Aggregations