Class MockitoMockBuilder
java.lang.Object
com.weirddev.testme.intellij.template.context.MockitoMockBuilder
- All Implemented Interfaces:
MockBuilder
- Direct Known Subclasses:
PowerMockBuilder
Utilities for Building string constructs of Mockito mock expressions.
Date: 31/03/2017
- Author:
- Yaron Yamin
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMockitoMockBuilder
(boolean isMockitoMockMakerInlineOn, boolean stubMockMethodCallsReturnValues, TestSubjectInspector testSubjectInspector, @Nullable String mockitoCoreVersion, FileTemplateCustomization fileTemplateCustomization) -
Method Summary
Modifier and TypeMethodDescriptionbuildMockArgsMatchers
(List<Param> params, String language) constructs mocked arguments expressiongetImmockabiliyReason
(String prefix, Field field) constructs an error message explaining why field cannot be mocked@Nullable String
Mockito core version.boolean
hasMockable
(List<Field> fields, Type testedClass) true - if any given field can be mockedboolean
true - if method had any argument that can be mocked given the provided default typesboolean
boolean
isMockable
(Field field) Deprecated.boolean
isMockable
(Field field, Type testedClass) true - field can be mockedboolean
isMockable
(Param param, Map<String, String> defaultTypes) true - if argument can be mocked given the provided default typesboolean
isMockExpected
(Field field) boolean
isWrapperType
(Type type) true - if type is a wrapper for other type, such as a primitiveboolean
true - if tested method should be stubbedboolean
shouldStub
(Method testMethod, Type testedClass) true - if should stub tested methodboolean
shouldStub
(Method testMethod, List<Field> testedClassFields) Deprecated.boolean
shouldVerify
(Method testMethod, Type testedClass) true - if should verify tested methodboolean
shouldVerify
(Method testMethod, List<Field> testedClassFields) Deprecated.
-
Field Details
-
TYPE_TO_ARG_MATCHERS
-
LOGGER_PATTERN
-
WRAPPER_TYPES
-
-
Constructor Details
-
MockitoMockBuilder
public MockitoMockBuilder(boolean isMockitoMockMakerInlineOn, boolean stubMockMethodCallsReturnValues, TestSubjectInspector testSubjectInspector, @Nullable @Nullable String mockitoCoreVersion, FileTemplateCustomization fileTemplateCustomization)
-
-
Method Details
-
isMockable
Deprecated.true - field can be mocked -
isMockable
true - field can be mocked- Specified by:
isMockable
in interfaceMockBuilder
-
isMockable
true - if argument can be mocked given the provided default types -
hasMockable
true - if any given field can be mocked -
hasMocks
- Parameters:
testedClass
- the tested class- Returns:
- true - if the tested class has mockable field
-
hasMocks
true - if method had any argument that can be mocked given the provided default types -
getImmockabiliyReason
constructs an error message explaining why field cannot be mocked- Specified by:
getImmockabiliyReason
in interfaceMockBuilder
- Parameters:
prefix
- add prefix to messagefield
- reported field- Returns:
- an error message explaining why field cannot be mocked
-
buildMockArgsMatchers
constructs mocked arguments expression- Specified by:
buildMockArgsMatchers
in interfaceMockBuilder
- Parameters:
params
- method params being mockedlanguage
- String representation of test codeLanguage
- Returns:
- mocked arguments expression
- See Also:
-
shouldStub
Deprecated. -
shouldStub
true - if should stub tested method- Parameters:
testMethod
- method being testedtestedClass
- tested class
-
shouldVerify
Deprecated.true - if should verify tested method- Parameters:
testMethod
- method being testedtestedClassFields
- tested class fields
-
shouldVerify
true - if should verify tested method- Parameters:
testMethod
- method being testedtestedClass
- tested class
-
shouldStub
true - if tested method should be stubbed- Parameters:
testMethod
- - method being testedctor
- - constructor of method return typedefaultTypes
- - default type values
-
isMockExpected
- Specified by:
isMockExpected
in interfaceMockBuilder
- Returns:
- true - if Field should be mocked
-
isWrapperType
true - if type is a wrapper for other type, such as a primitive -
getMockitoCoreVersion
Mockito core version. in case mockito-core jar can be found on the target test module classpath. null otherwise -
getInitMocksMethod
- Returns:
- Mockito init mocks method name. typically "initMocks" or "openMocks" depending on Mockito version
-