use of org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValues in project mockito by mockito.
the class InvocationContainerImplTest method should_tell_if_has_invocation_for_potential_stubbing.
@Test
public void should_tell_if_has_invocation_for_potential_stubbing() throws Exception {
container.setInvocationForPotentialStubbing(new InvocationBuilder().toInvocationMatcher());
assertTrue(container.hasInvocationForPotentialStubbing());
container.addAnswer(new ReturnsEmptyValues(), null);
assertFalse(container.hasInvocationForPotentialStubbing());
}
use of org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValues in project mockito by mockito.
the class InvocationContainerImplTest method should_tell_if_has_invocation_for_potential_stubbing_stub_only.
@Test
public void should_tell_if_has_invocation_for_potential_stubbing_stub_only() throws Exception {
containerStubOnly.setInvocationForPotentialStubbing(new InvocationBuilder().toInvocationMatcher());
assertTrue(containerStubOnly.hasInvocationForPotentialStubbing());
containerStubOnly.addAnswer(new ReturnsEmptyValues(), null);
assertFalse(containerStubOnly.hasInvocationForPotentialStubbing());
}
use of org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValues in project mockito by mockito.
the class ClonesArguments method answer.
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] arguments = invocation.getArguments();
for (int i = 0; i < arguments.length; i++) {
Object from = arguments[i];
if (from != null) {
if (from.getClass().isArray()) {
int len = Array.getLength(from);
Object newInstance = Array.newInstance(from.getClass().getComponentType(), len);
for (int j = 0; j < len; ++j) {
Array.set(newInstance, j, Array.get(from, j));
}
arguments[i] = newInstance;
} else {
Instantiator instantiator = Plugins.getInstantiatorProvider().getInstantiator(null);
Object newInstance = instantiator.newInstance(from.getClass());
new LenientCopyTool().copyToRealObject(from, newInstance);
arguments[i] = newInstance;
}
}
}
return new ReturnsEmptyValues().answer(invocation);
}
Aggregations