use of org.mockito.internal.debugging.LocationImpl in project mockito by mockito.
the class Reporter method noMoreInteractionsWanted.
public static MockitoAssertionError noMoreInteractionsWanted(Invocation undesired, List<VerificationAwareInvocation> invocations) {
ScenarioPrinter scenarioPrinter = new ScenarioPrinter();
String scenario = scenarioPrinter.print(invocations);
return new NoInteractionsWanted(join("No interactions wanted here:", new LocationImpl(), "But found this interaction on mock '" + safelyGetMockName(undesired.getMock()) + "':", undesired.getLocation(), scenario));
}
use of org.mockito.internal.debugging.LocationImpl in project mockito by mockito.
the class MockingProgressImpl method stubbingStarted.
public void stubbingStarted() {
validateState();
stubbingInProgress = new LocationImpl();
}
use of org.mockito.internal.debugging.LocationImpl in project mockito by mockito.
the class ReturnsSmartNulls method answer.
public Object answer(final InvocationOnMock invocation) throws Throwable {
Object defaultReturnValue = delegate.answer(invocation);
if (defaultReturnValue != null) {
return defaultReturnValue;
}
Class<?> type = invocation.getMethod().getReturnType();
if (!type.isPrimitive() && !Modifier.isFinal(type.getModifiers())) {
final Location location = new LocationImpl();
return Mockito.mock(type, new ThrowsSmartNullPointer(invocation, location));
}
return null;
}
use of org.mockito.internal.debugging.LocationImpl in project mockito by mockito.
the class LocationImplTest method shouldBeSafeInCaseForSomeReasonFilteredStackTraceIsEmpty.
@Test
public void shouldBeSafeInCaseForSomeReasonFilteredStackTraceIsEmpty() {
//given
StackTraceFilter filterReturningEmptyArray = new StackTraceFilter() {
@Override
public StackTraceElement[] filter(StackTraceElement[] target, boolean keepTop) {
return new StackTraceElement[0];
}
};
//when
String loc = new LocationImpl(filterReturningEmptyArray).toString();
//then
assertEquals("-> at <<unknown line>>", loc);
}
use of org.mockito.internal.debugging.LocationImpl in project powermock by powermock.
the class MethodInterceptorFilter method intercept.
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
if (isEqualsMethod(method)) {
return proxy == args[0];
} else if (isHashCodeMethod(method)) {
return hashCodeForMock(proxy);
} else if (acrossJVMSerializationFeature.isWriteReplace(method)) {
return acrossJVMSerializationFeature.writeReplace(proxy);
}
MockitoMethodProxy mockitoMethodProxy = createMockitoMethodProxy(methodProxy);
new CGLIBHacker().setMockitoNamingPolicy(methodProxy);
MockitoMethod mockitoMethod = createMockitoMethod(method);
CleanTraceRealMethod realMethod = new CleanTraceRealMethod(mockitoMethodProxy);
Invocation invocation = new InvocationImpl(proxy, mockitoMethod, args, SequenceNumber.next(), realMethod, new LocationImpl());
return handler.handle(invocation);
}
Aggregations