From 7abf369b68368022e42c43023c82e0ff4f7c1469 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Mon, 14 Nov 2022 11:50:39 +0300 Subject: [PATCH 1/2] Built the link to the nested class for the JavaDocs --- .../kotlin/org/utbot/engine/UtBotSymbolicEngine.kt | 2 ++ .../org/utbot/fuzzer/FuzzedMethodDescription.kt | 11 ++++++++++- ...mentWithCustomTagForTestProducedByFuzzerBuilder.kt | 7 ++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt b/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt index b4ea2a84a2..c2915e38ee 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt @@ -432,6 +432,8 @@ class UtBotSymbolicEngine( val methodUnderTestDescription = FuzzedMethodDescription(methodUnderTest, collectConstantsForFuzzer(graph)).apply { compilableName = if (!methodUnderTest.isConstructor) methodUnderTest.name else null className = classUnderTest.simpleName + canonicalName = classUnderTest.canonicalName + isNested = classUnderTest.isNested packageName = classUnderTest.packageName val names = graph.body.method.tags.filterIsInstance().firstOrNull()?.names parameterNameMap = { index -> names?.getOrNull(index) } diff --git a/utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/FuzzedMethodDescription.kt b/utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/FuzzedMethodDescription.kt index f81806a752..206c82961a 100644 --- a/utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/FuzzedMethodDescription.kt +++ b/utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/FuzzedMethodDescription.kt @@ -19,7 +19,6 @@ open class FuzzedMethodDescription( val parameters: List, val concreteValues: Collection = emptyList() ) { - /** * Name that can be used to generate test names */ @@ -35,6 +34,16 @@ open class FuzzedMethodDescription( */ var packageName: String? = null + /** + * Canonical name. + */ + var canonicalName: String? = null + + /** + * True, if class is nested. + */ + var isNested: Boolean = false + /** * Returns parameter name by its index in the signature */ diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt index a61247e247..bbb276e400 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt @@ -33,9 +33,14 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder( val packageName = methodDescription.packageName val className = methodDescription.className val methodName = methodDescription.compilableName + val canonicalName = methodDescription.canonicalName return if (packageName != null && className != null && methodName != null) { - val fullClassName = "$packageName.$className" + val fullClassName = if (methodDescription.isNested && canonicalName != null) { + canonicalName + } else { + "$packageName.$className" + } val methodReference = getMethodReferenceForFuzzingTest( fullClassName, From d41486b7270944251e26b8f95b53b9bf087127a8 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Wed, 7 Dec 2022 14:12:27 +0300 Subject: [PATCH 2/2] Merged with the existing master --- .../fuzzer/SimpleCommentForTestProducedByFuzzerBuilder.kt | 4 +++- .../utbot/summary/comment/customtags/CustomTagsUtil.kt | 8 ++++++-- .../CommentWithCustomTagForTestProducedByFuzzerBuilder.kt | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/fuzzer/SimpleCommentForTestProducedByFuzzerBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/fuzzer/SimpleCommentForTestProducedByFuzzerBuilder.kt index 11f6780246..ee272f2f3a 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/fuzzer/SimpleCommentForTestProducedByFuzzerBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/fuzzer/SimpleCommentForTestProducedByFuzzerBuilder.kt @@ -20,9 +20,11 @@ class SimpleCommentForTestProducedByFuzzerBuilder( val packageName = methodDescription.packageName val className = methodDescription.className val methodName = methodDescription.compilableName + val canonicalName = methodDescription.canonicalName + val isNested = methodDescription.isNested val result = if (packageName != null && className != null && methodName != null) { - val fullClassName = getFullClassName(packageName, className) + val fullClassName = getFullClassName(canonicalName, packageName, className, isNested) val methodReference = getMethodReferenceForFuzzingTest( fullClassName, diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/CustomTagsUtil.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/CustomTagsUtil.kt index fda4050170..5d503461f2 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/CustomTagsUtil.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/CustomTagsUtil.kt @@ -75,6 +75,10 @@ fun getClassReference(fullClassName: String): String { } /** Returns correct full class name. */ -fun getFullClassName(packageName: String, className: String): String { - return if (packageName.isEmpty()) className else "$packageName.$className" +fun getFullClassName(canonicalName: String?, packageName: String, className: String, isNested: Boolean): String { + return if (isNested && canonicalName != null) { + canonicalName + } else { + if (packageName.isEmpty()) className else "$packageName.$className" + } } \ No newline at end of file diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt index d621de6f83..ca65e00a8c 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt @@ -5,7 +5,6 @@ import org.utbot.framework.plugin.api.DocStatement import org.utbot.framework.plugin.api.UtExecutionResult import org.utbot.fuzzer.FuzzedMethodDescription import org.utbot.fuzzer.FuzzedValue -import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN import org.utbot.summary.comment.customtags.getClassReference import org.utbot.summary.comment.customtags.getFullClassName import org.utbot.summary.comment.customtags.getMethodReferenceForFuzzingTest @@ -35,9 +34,10 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder( val className = methodDescription.className val methodName = methodDescription.compilableName val canonicalName = methodDescription.canonicalName + val isNested = methodDescription.isNested return if (packageName != null && className != null && methodName != null) { - val fullClassName = getFullClassName(packageName, className) + val fullClassName = getFullClassName(canonicalName, packageName, className, isNested) val methodReference = getMethodReferenceForFuzzingTest( fullClassName,