Skip to content

Commit 4c38b02

Browse files
committed
Little style corrections
1 parent e5a874f commit 4c38b02

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/access/CgCallableAccessManager.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,22 @@ internal class CgCallableAccessManagerImpl(val context: CgContext) : CgCallableA
194194
// method of the current test class can be called on its 'this' instance
195195
currentTestClass == executable.classId && this isThisInstanceOf currentTestClass -> true
196196

197-
// method of a class can be called on an object of this class or any of its subtypes
197+
// method of the current test class can be called on an object of this class or any of its subtypes
198198
this.type isSubtypeOf executable.classId -> true
199199

200-
// We allow callers with [stubberClassId] classId to call any executable.
201-
// Example to see why: doNothing().when(entityManagerMock).persist(any()).
202-
// Here [persist()] cannot be called on [doNothing().when(entityManagerMock)],
203-
// because it requires [EntityManager] classId caller.
204-
this.type == stubberClassId -> true
200+
// method of the current test class can be called on builtin type
201+
this.type in builtinCallersWithoutReflection -> true
205202

206203
else -> false
207204
}
208205

206+
// Fore some builtin types do not having [ClassId] we need to clarify
207+
// that it is allowed to call their methods without reflection.
208+
//
209+
// This approach is used, for example, to render the constructions with stubs
210+
// like `doNothing().when(entityManagerMock).persist(any())`.
211+
private val builtinCallersWithoutReflection = setOf<ClassId>(stubberClassId)
212+
209213
/**
210214
* For Kotlin extension functions, real caller is one of the arguments in JVM method (and declaration class is omitted),
211215
* thus we should move it from arguments to caller

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/framework/MockFrameworkManager.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ private class MockitoMocker(context: CgContext) : ObjectMocker(context) {
202202
// We would like to mark that this field is used and must not be removed from test class.
203203
// Without `doNothing` call Intellij Idea suggests removing this field as unused.
204204
is MethodId -> {
205-
// We allow [stubberClassId] to be a receiver of [executable].
206-
// See [CgExpression.canBeReceiverOf]
207205
+mockitoClassId[doNothingMethodId]()[whenStubberMethodId](mockObject)[executable](*matchers)
208206
}
209207
else -> error("Only MethodId and ConstructorId was expected to appear in simple mocker but got $executable")

0 commit comments

Comments
 (0)