use of samples.privatemocking.PrivateMethodDemo in project powermock by powermock.
the class PrivateMethodDemoTest method testExpectPrivateMethodWithoutSpecifyingMethodName.
@Test
public void testExpectPrivateMethodWithoutSpecifyingMethodName() throws Exception {
final String expected = "Hello world";
PrivateMethodDemo tested = createPartialMock(PrivateMethodDemo.class, "doSayYear");
expectPrivate(tested, 22, "name").andReturn(expected);
replay(tested);
assertEquals(expected, tested.sayYear("name", 22));
verify(tested);
}
use of samples.privatemocking.PrivateMethodDemo in project powermock by powermock.
the class PrivateMethodDemoTest method testExpectPrivateMethodWithoutSpecifyingMethodName_firstArgumentIsOfStringType.
@Test
public void testExpectPrivateMethodWithoutSpecifyingMethodName_firstArgumentIsOfStringType() throws Exception {
final String expected = "Hello world";
PrivateMethodDemo tested = createPartialMock(PrivateMethodDemo.class, "sayIt");
expectPrivate(tested, (String) null, "firstName", " ", "lastName").andReturn(expected);
replay(tested);
assertEquals(expected, tested.enhancedSay("firstName", "lastName"));
verify(tested);
}
use of samples.privatemocking.PrivateMethodDemo in project powermock by powermock.
the class PrivateMethodDemoTest method testExpectPrivateWithArrayMatcher.
@Test
public void testExpectPrivateWithArrayMatcher() throws Exception {
PrivateMethodDemo tested = createPartialMock(PrivateMethodDemo.class, "doArrayInternal");
expectPrivate(tested, "doArrayInternal", EasyMock.aryEq((Object[]) new String[] { "hello" }));
replay(tested);
tested.doArrayStuff("hello");
verify(tested);
}
use of samples.privatemocking.PrivateMethodDemo in project powermock by powermock.
the class PrivateMethodDemoTest method testExpectPrivateWithObjectMatcher.
@Test
public void testExpectPrivateWithObjectMatcher() throws Exception {
PrivateMethodDemo tested = createPartialMock(PrivateMethodDemo.class, "doObjectInternal");
expectPrivate(tested, "doObjectInternal", EasyMock.isA(CharSequence.class));
replay(tested);
tested.doObjectStuff("hello");
verify(tested);
}
use of samples.privatemocking.PrivateMethodDemo in project powermock by powermock.
the class PrivateMethodDemoTest method testExpectPrivateMethodWithVarArgsParameters.
@Test
public void testExpectPrivateMethodWithVarArgsParameters() throws Exception {
final String methodToExpect = "varArgsMethod";
final int expected = 7;
final int valueA = 2;
final int valueB = 3;
PrivateMethodDemo tested = createPartialMock(PrivateMethodDemo.class, methodToExpect);
expectPrivate(tested, methodToExpect, valueA, valueB).andReturn(expected);
replay(tested);
assertEquals(expected, tested.invokeVarArgsMethod(valueA, valueB));
verify(tested);
}
Aggregations