public Object answer(InvocationOnMock invocation) throws Throwable { return implementation.answer(invocation); } }
@Override public Object answer(final InvocationOnMock invocation) throws Throwable { TimeUnit.MILLISECONDS.sleep(sleepyTime); return answer.answer(invocation); }
public Object answer(InvocationOnMock invocation) throws Throwable { //see ThreadsShareGenerouslyStubbedMockTest Answer a; synchronized(answers) { a = answers.size() == 1 ? answers.peek() : answers.poll(); } return a.answer(invocation); }
public Object answer(InvocationOnMock invocation) throws Throwable { //see ThreadsShareGenerouslyStubbedMockTest Answer a; synchronized(answers) { a = answers.size() == 1 ? answers.peek() : answers.poll(); } return a.answer(invocation); }
public Object answer(InvocationOnMock invocation) throws Throwable { Object ret = delegate.answer(invocation); if (ret != null) { return ret; } return returnValueFor(invocation.getMethod().getReturnType()); }
public Object answer(InvocationOnMock invocation) throws Throwable { Object ret = delegate.answer(invocation); if (ret != null) { return ret; } Class<?> returnType = invocation.getMethod().getReturnType(); return returnValueFor(returnType); }
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; }
public Object answer(InvocationOnMock invocation) throws Throwable { Object ret = delegate.answer(invocation); if (ret != null) { return ret; } Class<?> returnType = invocation.getMethod().getReturnType(); return returnValueFor(returnType); }
public Object answer(InvocationOnMock invocation) throws Throwable { return new GlobalConfiguration().getDefaultAnswer().answer(invocation); } }
public Object answer(InvocationOnMock invocation) throws Throwable { Object ret = delegate.answer(invocation); if (ret != null) { return ret; } return returnValueFor(invocation.getMethod().getReturnType()); }
@Override public Object answer(InvocationOnMock invocation) throws Throwable { Object mock = invocation.getMock(); if (invocation.getMethod().getReturnType().isInstance(mock)) { return mock; } else { return RETURNS_DEFAULTS.answer(invocation); } } });
public Object answer(InvocationOnMock invocation) throws Throwable { return new GlobalConfiguration().getDefaultAnswer().answer(invocation); } }
public Object answer(final InvocationOnMock invocation) throws Throwable { Object defaultReturnValue = delegate.answer(invocation); if (defaultReturnValue != null) { return defaultReturnValue; } Class<?> type = invocation.getMethod().getReturnType(); final Type returnType = invocation.getMethod().getGenericReturnType(); if (returnType instanceof TypeVariable) { type = findTypeFromGeneric(invocation, (TypeVariable) returnType); if (type != null) { defaultReturnValue = delegateChains(type); } } if (defaultReturnValue != null) { return defaultReturnValue; } if (type != null && !type.isPrimitive() && !Modifier.isFinal(type.getModifiers())) { final Location location = new LocationImpl(); return Mockito.mock(type, new ThrowsSmartNullPointer(invocation, location)); } return null; }
public Object answer(InvocationOnMock invocation) throws Throwable { Class<?> clz = invocation.getMethod().getReturnType(); if (!new MockCreationValidator().isTypeMockable(clz)) { return delegate.answer(invocation); } return getMock(invocation); }
@Override public Object answer(InvocationOnMock invocation) throws Throwable { Object mock = invocation.getMock(); if (invocation.getMethod().getReturnType().isInstance(mock)) { return mock; } else { return RETURNS_DEFAULTS.answer(invocation); } } }
public Object answer(InvocationOnMock invocation) throws Throwable { Object mock = invocation.getMock(); if (invocation.getMethod().getReturnType().isInstance(mock)) { return mock; } else { return RETURNS_DEFAULTS.answer(invocation); } } }
return stubbedInvocation.answer(invocation); } else { Object ret = mockSettings.getDefaultAnswer().answer(invocation);
Object ret = mockSettings.getDefaultAnswer().answer(invocation); DefaultAnswerValidator.validateReturnValueFor(invocation, ret);
public static void stubRegistryKeys(MuleContext muleContext, final String... keys) { when(((MuleContextWithRegistry) muleContext).getRegistry().get(anyString())).thenAnswer(invocation -> { String name = (String) invocation.getArguments()[0]; if (name != null) { for (String key : keys) { if (name.contains(key)) { return null; } } } return RETURNS_DEEP_STUBS.get().answer(invocation); }); }
@Test public void testConstructor_avoidsEclipseWriterBug() throws IOException { // Due to a bug in Eclipse, we *must* call close on the object returned from openWriter(). // Eclipse proxies a Writer but does not implement the fluent API correctly. // Here, we implement the fluent Writer API with the same bug: Writer mockWriter = Mockito.mock(Writer.class, (Answer<?>) invocation -> { if (Writer.class.isAssignableFrom(invocation.getMethod().getReturnType())) { // Erroneously return the delegate writer (matching the Eclipse bug!) return source; } else { return Answers.RETURNS_SMART_NULLS.get().answer(invocation); } }); when(sourceFile.openWriter()).thenReturn(mockWriter); FilerUtils.writeCompilationUnit(filer, unit, originatingElement); verify(mockWriter).close(); }