use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class MemberModificationExampleTest method stubSingleMethodExample.
@Test
public void stubSingleMethodExample() throws Exception {
final String expectedReturnValue = "new";
stub(method(SuppressMethod.class, "getObject")).toReturn(expectedReturnValue);
final SuppressMethod tested = new SuppressMethod();
assertEquals(expectedReturnValue, tested.getObject());
assertEquals(expectedReturnValue, tested.getObject());
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class MemberModificationExampleTest method stubSingleMethodExample.
@Test
public void stubSingleMethodExample() throws Exception {
final String expectedReturnValue = "new";
stub(method(SuppressMethod.class, "getObject")).toReturn(expectedReturnValue);
final SuppressMethod tested = new SuppressMethod();
assertEquals(expectedReturnValue, tested.getObject());
assertEquals(expectedReturnValue, tested.getObject());
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class SuppressMethodTest method testGetDouble_parameter.
@Test
public void testGetDouble_parameter() throws Exception {
suppress(method(SuppressMethod.class, "getDouble", new Class<?>[] { double.class }));
SuppressMethod tested = new SuppressMethod();
assertEquals("A method returning a double should return 0.0d after suppressing method code.", 0.0d, tested.getDouble(8.7d), 0);
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class StubMethodTest method test.
@Test
public void test() throws Exception {
stubbing.enforceOn(stub(method(SuppressMethod.class, method.name())));
final SuppressMethod tested = new SuppressMethod();
Callable<?> methodInvocation = new Callable<Object>() {
@Override
public Object call() {
return method.invokeOn(tested);
}
};
stubbing.verify(methodInvocation);
stubbing.verify(methodInvocation);
stubbing.verify(methodInvocation);
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class MemberModificationExampleTest method changingReturnValueExample.
@Test
public void changingReturnValueExample() throws Exception {
replace(method(SuppressMethod.class, "getObjectWithArgument")).with(new ReturnValueChangingInvocationHandler());
final SuppressMethod tested = new SuppressMethod();
assertThat(tested.getObjectWithArgument("don't do anything"), is(instanceOf(Object.class)));
assertEquals("hello world", tested.getObjectWithArgument("make it a string"));
}
Aggregations