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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMockitoMockBuilder(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 StringMockito core version.booleanhasMockable(List<Field> fields, Type testedClass) true - if any given field can be mockedbooleantrue - if method had any argument that can be mocked given the provided default typesbooleanbooleanisMockable(Field field) Deprecated.booleanisMockable(Field field, Type testedClass) true - field can be mockedbooleanisMockable(Param param, Map<String, String> defaultTypes) true - if argument can be mocked given the provided default typesbooleanisMockExpected(Field field) booleanisWrapperType(Type type) true - if type is a wrapper for other type, such as a primitivebooleantrue - if tested method should be stubbedbooleanshouldStub(Method testMethod, Type testedClass) true - if should stub tested methodbooleanshouldStub(Method testMethod, List<Field> testedClassFields) Deprecated.booleanshouldVerify(Method testMethod, Type testedClass) true - if should verify tested methodbooleanshouldVerify(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:
isMockablein 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:
getImmockabiliyReasonin 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:
buildMockArgsMatchersin 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:
isMockExpectedin 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
-