Java Code Examples for org.mockito.MockSettings#defaultAnswer()
The following examples show how to use
org.mockito.MockSettings#defaultAnswer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockAnnotationProcessor.java From astor with GNU General Public License v2.0 | 6 votes |
public Object process(Mock annotation, Field field) { MockSettings mockSettings = Mockito.withSettings(); if (annotation.extraInterfaces().length > 0) { // never null mockSettings.extraInterfaces(annotation.extraInterfaces()); } if ("".equals(annotation.name())) { mockSettings.name(field.getName()); } else { mockSettings.name(annotation.name()); } if(annotation.serializable()){ mockSettings.serializable(); } // see @Mock answer default value mockSettings.defaultAnswer(annotation.answer().get()); return Mockito.mock(field.getType(), mockSettings); }
Example 2
Source File: MockParameterFactory.java From junit5-extensions with MIT License | 5 votes |
@Override public Object getParameterValue(Parameter parameter) { Mock annotation = parameter.getAnnotation(Mock.class); MockSettings settings = Mockito.withSettings(); if (annotation.extraInterfaces().length > 0) { settings.extraInterfaces(annotation.extraInterfaces()); } if (annotation.serializable()) { settings.serializable(); } settings.name(annotation.name().isEmpty() ? parameter.getName() : annotation.name()); settings.defaultAnswer(annotation.answer()); return Mockito.mock(parameter.getType(), settings); }
Example 3
Source File: DefaultAnnotationEngine.java From astor with GNU General Public License v2.0 | 5 votes |
private Object processAnnotationOn(Mock annotation, Field field) { MockSettings mockSettings = Mockito.withSettings(); if (annotation.extraInterfaces().length > 0) { // never null mockSettings.extraInterfaces(annotation.extraInterfaces()); } if ("".equals(annotation.name())) { mockSettings.name(field.getName()); } else { mockSettings.name(annotation.name()); } // see @Mock answer default value mockSettings.defaultAnswer(annotation.answer().get()); return Mockito.mock(field.getType(), mockSettings); }