Package org.mockito

Examples of org.mockito.MockSettings


        return null;
    }
   
    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);
    }
View Full Code Here


/**
* Instantiates a mock on a field annotated by {@link Mock}
*/
public class MockAnnotationProcessor implements FieldAnnotationProcessor<Mock> {
    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());
        }

        // see @Mock answer default value
        mockSettings.defaultAnswer(annotation.answer().get());
        return Mockito.mock(field.getType(), mockSettings);
    }
View Full Code Here

                withSettingsUsing(returnTypeGenericMetadata, parentMockSettings)
        );
    }

    private MockSettings withSettingsUsing(GenericMetadataSupport returnTypeGenericMetadata, MockCreationSettings parentMockSettings) {
        MockSettings mockSettings = returnTypeGenericMetadata.hasRawExtraInterfaces() ?
                withSettings().extraInterfaces(returnTypeGenericMetadata.rawExtraInterfaces())
                : withSettings();

        return propagateSerializationSettings(mockSettings, parentMockSettings)
                .defaultAnswer(returnsDeepStubsAnswerUsing(returnTypeGenericMetadata));
View Full Code Here

/**
* Instantiates a mock on a field annotated by {@link Mock}
*/
public class MockAnnotationProcessor implements FieldAnnotationProcessor<Mock> {
    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);
    }
View Full Code Here

        return null;
    }
   
    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);
    }
View Full Code Here

                }
            }

            if (field.isAnnotationPresent(org.mockito.Mock.class)) {
                org.mockito.Mock mockAnnotation = field.getAnnotation(org.mockito.Mock.class);
                MockSettings mockSettings = withSettings();
                Answers answers = mockAnnotation.answer();
                if (answers != null) {
                    mockSettings.defaultAnswer(answers.get());
                }

                Class<?>[] extraInterfaces = mockAnnotation.extraInterfaces();
                if (extraInterfaces != null && extraInterfaces.length > 0) {
                    mockSettings.extraInterfaces(extraInterfaces);
                }

                String name = mockAnnotation.name();
                if (name != null && name.length() > 0) {
                    mockSettings.name(name);
                }

                field.set(testInstance, mock(type, mockSettings));
            } else {
                field.set(testInstance, mock(type));
View Full Code Here

* Overrides {@link MockAnnotationProcessor} to manage Overlay types mocking using {@link Mock} from
* Mockito.
*/
class MockitoMockAnnotationProcessor implements FieldAnnotationProcessor<Mock> {
   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());
      }

      // see @Mock answer default value
      mockSettings.defaultAnswer(annotation.answer().get());
      return Mockito.mock(MockAnnotationProcessorHelper.getTypeToMock(field), mockSettings);
   }
View Full Code Here

TOP

Related Classes of org.mockito.MockSettings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.