From 09de595921f428183e051c221963c2c0115e8ac1 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Thu, 20 Oct 2022 17:33:57 +0300 Subject: [PATCH 1/4] Added an initial solution --- ...leCommentForTestProducedByFuzzerBuilder.kt | 39 +++++++++++++++++-- .../fuzzer/names/ModelBasedNameSuggester.kt | 5 ++- 2 files changed, 38 insertions(+), 6 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 02f7736eff..93b100905b 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 @@ -1,18 +1,49 @@ package org.utbot.summary.comment.classic.fuzzer import org.utbot.framework.plugin.api.DocPreTagStatement +import org.utbot.framework.plugin.api.DocRegularStmt 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 +import org.utbot.summary.SummarySentenceConstants.NEW_LINE +import org.utbot.summary.comment.customtags.fuzzer.CommentWithCustomTagForTestProducedByFuzzer +import org.utbot.summary.comment.customtags.getClassReference +import org.utbot.summary.comment.customtags.getMethodReferenceForFuzzingTest // TODO: https://github.com/UnitTestBot/UTBotJava/issues/1127 class SimpleCommentForTestProducedByFuzzerBuilder( - description: FuzzedMethodDescription, - values: List, - result: UtExecutionResult? + val methodDescription: FuzzedMethodDescription, + val values: List, + val result: UtExecutionResult? ) { fun buildDocStatements(): List { - return listOf(DocPreTagStatement(emptyList())) + val packageName = methodDescription.packageName + val className = methodDescription.className + val methodName = methodDescription.compilableName + + val result = if (packageName != null && className != null && methodName != null) { + val fullClassName = "$packageName.$className" + + val methodReference = getMethodReferenceForFuzzingTest( + fullClassName, + methodName, + methodDescription.parameters, + false + ).replace(SummarySentenceConstants.CARRIAGE_RETURN, "") + + val classReference = getClassReference(fullClassName).replace(SummarySentenceConstants.CARRIAGE_RETURN, "") + + + val docStatements = mutableListOf() + docStatements.add(DocRegularStmt("Class under test: $classReference$NEW_LINE")) + docStatements.add(DocRegularStmt("Method under test: $methodReference$NEW_LINE")) + docStatements + } else { + emptyList() + } + + return listOf(DocPreTagStatement(result)) } } \ No newline at end of file diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/fuzzer/names/ModelBasedNameSuggester.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/fuzzer/names/ModelBasedNameSuggester.kt index 823717f604..51a079cda1 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/fuzzer/names/ModelBasedNameSuggester.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/fuzzer/names/ModelBasedNameSuggester.kt @@ -5,6 +5,7 @@ import org.utbot.framework.plugin.api.* import org.utbot.framework.plugin.api.util.voidClassId import org.utbot.fuzzer.FuzzedMethodDescription import org.utbot.fuzzer.FuzzedValue +import org.utbot.summary.UtSummarySettings import org.utbot.summary.comment.classic.fuzzer.SimpleCommentForTestProducedByFuzzerBuilder import org.utbot.summary.comment.customtags.fuzzer.CommentWithCustomTagForTestProducedByFuzzerBuilder import java.util.* @@ -32,9 +33,9 @@ class ModelBasedNameSuggester( return sequenceOf( TestSuggestedInfo( - testName = createTestName(description, values, result), + testName = createTestName(description, values, result), displayName = createDisplayName(description, values, result), - javaDoc = createJavaDoc(description, values, result) + javaDoc = if (UtSummarySettings.GENERATE_COMMENTS) createJavaDoc(description, values, result) else null ) ) } From 365e0e4fcd85022e5dfe58d643ab321e741900e9 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Thu, 20 Oct 2022 17:35:55 +0300 Subject: [PATCH 2/4] Added an initial solution --- .../fuzzer/SimpleCommentForTestProducedByFuzzerBuilder.kt | 1 - 1 file changed, 1 deletion(-) 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 93b100905b..9d77e8b2f8 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 @@ -12,7 +12,6 @@ import org.utbot.summary.comment.customtags.fuzzer.CommentWithCustomTagForTestPr import org.utbot.summary.comment.customtags.getClassReference import org.utbot.summary.comment.customtags.getMethodReferenceForFuzzingTest -// TODO: https://github.com/UnitTestBot/UTBotJava/issues/1127 class SimpleCommentForTestProducedByFuzzerBuilder( val methodDescription: FuzzedMethodDescription, val values: List, From 4600a4a10e2bfff08d3b4cf7497657e4f9a3bd5e Mon Sep 17 00:00:00 2001 From: amandelpie Date: Fri, 21 Oct 2022 11:57:08 +0300 Subject: [PATCH 3/4] Renaming and refactoring --- ...leCommentForTestProducedByFuzzerBuilder.kt | 5 +- .../classic/symbolic/SimpleCommentBuilder.kt | 6 +-- .../SymbolicExecutionClusterCommentBuilder.kt | 6 +-- .../comment/customtags/CustomTagsUtil.kt | 50 ++++++++++--------- ...CustomTagForTestProducedByFuzzerBuilder.kt | 4 +- .../symbolic/CustomJavaDocCommentBuilder.kt | 8 +-- .../comment/SimpleCommentBuilderTest.kt | 7 ++- 7 files changed, 43 insertions(+), 43 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 9d77e8b2f8..dcbf02cde6 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 @@ -30,10 +30,9 @@ class SimpleCommentForTestProducedByFuzzerBuilder( methodName, methodDescription.parameters, false - ).replace(SummarySentenceConstants.CARRIAGE_RETURN, "") - - val classReference = getClassReference(fullClassName).replace(SummarySentenceConstants.CARRIAGE_RETURN, "") + ) + val classReference = getClassReference(fullClassName) val docStatements = mutableListOf() docStatements.add(DocRegularStmt("Class under test: $classReference$NEW_LINE")) diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt index 781902a05b..78f745a925 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt @@ -16,7 +16,7 @@ import org.utbot.framework.plugin.api.exceptionOrNull import org.utbot.summary.AbstractTextBuilder import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN import org.utbot.summary.ast.JimpleToASTMap -import org.utbot.summary.comment.customtags.getMethodReference +import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest import org.utbot.summary.tag.BasicTypeTag import org.utbot.summary.tag.CallOrderTag import org.utbot.summary.tag.StatementTag @@ -196,7 +196,7 @@ open class SimpleCommentBuilder( if (!sentenceInvoke.isEmpty()) { sentenceBlock.invokeSentenceBlock = Pair( - getMethodReference(className, methodName, methodParameterTypes, invokeSootMethod.isPrivate), + getMethodReferenceForSymbolicTest(className, methodName, methodParameterTypes, invokeSootMethod.isPrivate), sentenceInvoke ) createNextBlock = true @@ -333,7 +333,7 @@ open class SimpleCommentBuilder( sentenceBlock.stmtTexts.add( StmtDescription( StmtType.Invoke, - getMethodReference(className, methodName, methodParameterTypes, isPrivate), + getMethodReferenceForSymbolicTest(className, methodName, methodParameterTypes, isPrivate), frequency ) ) diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt index ea09506ab3..1d34e70235 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt @@ -7,7 +7,7 @@ import org.utbot.framework.plugin.api.DocStatement import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN import org.utbot.summary.ast.JimpleToASTMap import org.utbot.summary.comment.* -import org.utbot.summary.comment.customtags.getMethodReference +import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest import org.utbot.summary.tag.BasicTypeTag import org.utbot.summary.tag.CallOrderTag import org.utbot.summary.tag.StatementTag @@ -42,7 +42,7 @@ class SymbolicExecutionClusterCommentBuilder( sentence = splitLongSentence(sentence) sentence = lastCommaToDot(sentence) - return "
\n$sentence
".replace(CARRIAGE_RETURN, "") + return "
\n$sentence
".replace(CARRIAGE_RETURN, EMPTY_STRING) } override fun buildDocStmts(currentMethod: SootMethod): List { @@ -98,7 +98,7 @@ class SymbolicExecutionClusterCommentBuilder( if (!sentenceInvoke.isEmpty()) { sentenceBlock.invokeSentenceBlock = Pair( - getMethodReference(className, methodName, methodParameterTypes, isPrivate), + getMethodReferenceForSymbolicTest(className, methodName, methodParameterTypes, isPrivate), sentenceInvoke ) createNextBlock = true 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 496f6d1ef6..1efa67f218 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 @@ -1,6 +1,8 @@ package org.utbot.summary.comment.customtags import org.utbot.framework.plugin.api.ClassId +import org.utbot.summary.SummarySentenceConstants +import org.utbot.summary.comment.EMPTY_STRING import soot.Type /** @@ -12,34 +14,15 @@ import soot.Type * In case when an enclosing class in nested, we need to replace '$' with '.' * to render the reference. */ -fun getMethodReference( +fun getMethodReferenceForSymbolicTest( className: String, methodName: String, methodParameterTypes: List, isPrivate: Boolean ): String { - val prettyClassName: String = className.replace("$", ".") - - val text = if (methodParameterTypes.isEmpty()) { - "$prettyClassName#$methodName()" - } else { - val methodParametersAsString = methodParameterTypes.joinToString(",") - "$prettyClassName#$methodName($methodParametersAsString)" - } - - return if (isPrivate) { - text - } else { - "{@link $text}" - } -} + val methodParametersAsString = if (methodParameterTypes.isNotEmpty()) methodParameterTypes.joinToString(",") else EMPTY_STRING -/** - * Returns a reference to the class. - * Replaces '$' with '.' in case a class is nested. - */ -fun getClassReference(fullClassName: String): String { - return "{@link ${fullClassName.replace("$", ".")}}" + return formMethodReferenceForJavaDoc(className, methodName, methodParametersAsString, isPrivate) } /** @@ -51,12 +34,23 @@ fun getClassReference(fullClassName: String): String { * to render the reference. */ fun getMethodReferenceForFuzzingTest(className: String, methodName: String, methodParameterTypes: List, isPrivate: Boolean): String { + val methodParametersAsString = if (methodParameterTypes.isNotEmpty()) methodParameterTypes.joinToString(",") { it.canonicalName } else EMPTY_STRING + + return formMethodReferenceForJavaDoc(className, methodName, methodParametersAsString, isPrivate).replace( + SummarySentenceConstants.CARRIAGE_RETURN, EMPTY_STRING) +} + +private fun formMethodReferenceForJavaDoc( + className: String, + methodName: String, + methodParametersAsString: String, + isPrivate: Boolean +): String { val prettyClassName: String = className.replace("$", ".") - val text = if (methodParameterTypes.isEmpty()) { + val text = if (methodParametersAsString == "") { "$prettyClassName#$methodName()" } else { - val methodParametersAsString = methodParameterTypes.joinToString(",") { it.canonicalName } "$prettyClassName#$methodName($methodParametersAsString)" } @@ -65,4 +59,12 @@ fun getMethodReferenceForFuzzingTest(className: String, methodName: String, meth } else { "{@link $text}" } +} + +/** + * Returns a reference to the class. + * Replaces '$' with '.' in case a class is nested. + */ +fun getClassReference(fullClassName: String): String { + return "{@link ${fullClassName.replace("$", ".")}}".replace(SummarySentenceConstants.CARRIAGE_RETURN, EMPTY_STRING) } \ 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 367eacc541..a61247e247 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 @@ -42,9 +42,9 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder( methodName, methodDescription.parameters, false - ).replace(CARRIAGE_RETURN, "") + ) - val classReference = getClassReference(fullClassName).replace(CARRIAGE_RETURN, "") + val classReference = getClassReference(fullClassName) CommentWithCustomTagForTestProducedByFuzzer( classUnderTest = classReference, diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt index 9c19b4e521..3ace8b94e0 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt @@ -7,7 +7,7 @@ import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN import org.utbot.summary.ast.JimpleToASTMap import org.utbot.summary.comment.* import org.utbot.summary.comment.customtags.getClassReference -import org.utbot.summary.comment.customtags.getMethodReference +import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest import org.utbot.summary.tag.TraceTagWithoutExecution import soot.SootMethod @@ -30,7 +30,7 @@ class CustomJavaDocCommentBuilder( } private fun buildCustomJavaDocComment(currentMethod: SootMethod): CustomJavaDocComment { - val methodReference = getMethodReference( + val methodReference = getMethodReferenceForSymbolicTest( currentMethod.declaringClass.name, currentMethod.name, currentMethod.parameterTypes, @@ -39,8 +39,8 @@ class CustomJavaDocCommentBuilder( val classReference = getClassReference(currentMethod.declaringClass.javaStyleName) val comment = CustomJavaDocComment( - classUnderTest = classReference.replace(CARRIAGE_RETURN, ""), - methodUnderTest = methodReference.replace(CARRIAGE_RETURN, ""), + classUnderTest = classReference, + methodUnderTest = methodReference, ) val rootSentenceBlock = SimpleSentenceBlock(stringTemplates = stringTemplates) diff --git a/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SimpleCommentBuilderTest.kt b/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SimpleCommentBuilderTest.kt index a18e630d27..cb81c5f3f7 100644 --- a/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SimpleCommentBuilderTest.kt +++ b/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SimpleCommentBuilderTest.kt @@ -9,7 +9,7 @@ import org.mockito.Mockito.`when` import org.utbot.framework.plugin.api.Step import org.utbot.framework.plugin.api.UtOverflowFailure import org.utbot.summary.ast.JimpleToASTMap -import org.utbot.summary.comment.customtags.getMethodReference +import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest import org.utbot.summary.tag.StatementTag import org.utbot.summary.tag.TraceTag import soot.SootMethod @@ -67,7 +67,7 @@ class SimpleCommentBuilderTest { @Test fun `builds inline link for method`() { - val methodReference = getMethodReference("org.utbot.ClassName", "methodName", listOf(), false) + val methodReference = getMethodReferenceForSymbolicTest("org.utbot.ClassName", "methodName", listOf(), false) val expectedMethodReference = "{@link org.utbot.ClassName#methodName()}" assertEquals(methodReference, expectedMethodReference) } @@ -75,9 +75,8 @@ class SimpleCommentBuilderTest { @Test fun `builds inline link for method in nested class`() { val methodReference = - getMethodReference("org.utbot.ClassName\$NestedClassName", "methodName", listOf(), false) + getMethodReferenceForSymbolicTest("org.utbot.ClassName\$NestedClassName", "methodName", listOf(), false) val expectedMethodReference = "{@link org.utbot.ClassName.NestedClassName#methodName()}" assertEquals(methodReference, expectedMethodReference) } - } \ No newline at end of file From ce4c627d4126cd16ad25ebd511e5e2275980315c Mon Sep 17 00:00:00 2001 From: amandelpie Date: Tue, 25 Oct 2022 11:16:41 +0300 Subject: [PATCH 4/4] Fix imports and constants --- .../org/utbot/summary/AbstractTextBuilder.kt | 8 ++++---- .../kotlin/org/utbot/summary/Summarization.kt | 2 +- .../kotlin/org/utbot/summary/UtSummarySettings.kt | 3 +++ .../org/utbot/summary/comment/SentenceUtil.kt | 2 ++ ...SimpleCommentForTestProducedByFuzzerBuilder.kt | 2 -- .../classic/symbolic/SimpleCommentBuilder.kt | 3 ++- .../classic/symbolic/SimpleSentenceBlock.kt | 3 ++- .../SymbolicExecutionClusterCommentBuilder.kt | 1 + .../summary/comment/customtags/CustomTagsUtil.kt | 15 +++++++++------ ...CommentWithCustomTagForTestProducedByFuzzer.kt | 2 +- .../customtags/symbolic/CustomJavaDocComment.kt | 2 +- .../symbolic/CustomJavaDocCommentBuilder.kt | 1 + .../summary/comment/SimpleCommentBuilderTest.kt | 1 + 13 files changed, 28 insertions(+), 17 deletions(-) diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/AbstractTextBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/AbstractTextBuilder.kt index f15ca4f9c2..8080f647c7 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/AbstractTextBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/AbstractTextBuilder.kt @@ -11,10 +11,10 @@ import com.github.javaparser.ast.stmt.SwitchStmt import com.github.javaparser.ast.stmt.WhileStmt import org.utbot.framework.plugin.api.Step import org.utbot.summary.ast.JimpleToASTMap -import org.utbot.summary.comment.IterationDescription -import org.utbot.summary.comment.SimpleSentenceBlock -import org.utbot.summary.comment.StmtDescription -import org.utbot.summary.comment.StmtType +import org.utbot.summary.comment.classic.symbolic.IterationDescription +import org.utbot.summary.comment.classic.symbolic.SimpleSentenceBlock +import org.utbot.summary.comment.classic.symbolic.StmtDescription +import org.utbot.summary.comment.classic.symbolic.StmtType import org.utbot.summary.comment.getTextIterationDescription import org.utbot.summary.comment.getTextTypeIterationDescription import org.utbot.summary.comment.numberWithSuffix diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt index 07aa300275..b67d08e4fd 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt @@ -17,7 +17,7 @@ import org.utbot.summary.analysis.ExecutionStructureAnalysis import org.utbot.summary.ast.JimpleToASTMap import org.utbot.summary.ast.SourceCodeParser import org.utbot.summary.comment.cluster.SymbolicExecutionClusterCommentBuilder -import org.utbot.summary.comment.SimpleCommentBuilder +import org.utbot.summary.comment.classic.symbolic.SimpleCommentBuilder import org.utbot.summary.name.SimpleNameBuilder import java.io.File import java.nio.file.Path diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/UtSummarySettings.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/UtSummarySettings.kt index 70f318ad39..3e36d3d72c 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/UtSummarySettings.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/UtSummarySettings.kt @@ -64,4 +64,7 @@ object SummarySentenceConstants { const val AT_CODE = "@code" const val OPEN_BRACKET = "{" const val CLOSE_BRACKET = "}" + + const val JAVA_CLASS_DELIMITER = "$" + const val JAVA_DOC_CLASS_DELIMITER = "." } \ No newline at end of file diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SentenceUtil.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SentenceUtil.kt index 8057a5e74c..6972aa0395 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SentenceUtil.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SentenceUtil.kt @@ -14,6 +14,8 @@ import org.utbot.summary.SummarySentenceConstants.COMMA_SYMBOL import org.utbot.summary.SummarySentenceConstants.DOT_SYMBOL import org.utbot.summary.SummarySentenceConstants.NEW_LINE import org.utbot.summary.SummarySentenceConstants.TAB +import org.utbot.summary.comment.classic.symbolic.SquashedStmtTexts +import org.utbot.summary.comment.classic.symbolic.StmtType fun numberWithSuffix(number: Int) = when (number % 10) { 1 -> "${number}st" 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 dcbf02cde6..feec3bf19f 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 @@ -6,9 +6,7 @@ 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 import org.utbot.summary.SummarySentenceConstants.NEW_LINE -import org.utbot.summary.comment.customtags.fuzzer.CommentWithCustomTagForTestProducedByFuzzer import org.utbot.summary.comment.customtags.getClassReference import org.utbot.summary.comment.customtags.getMethodReferenceForFuzzingTest diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt index 78f745a925..003d3c0116 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt @@ -1,4 +1,4 @@ -package org.utbot.summary.comment +package org.utbot.summary.comment.classic.symbolic import com.github.javaparser.ast.body.MethodDeclaration import com.github.javaparser.ast.stmt.CatchClause @@ -16,6 +16,7 @@ import org.utbot.framework.plugin.api.exceptionOrNull import org.utbot.summary.AbstractTextBuilder import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN import org.utbot.summary.ast.JimpleToASTMap +import org.utbot.summary.comment.* import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest import org.utbot.summary.tag.BasicTypeTag import org.utbot.summary.tag.CallOrderTag diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleSentenceBlock.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleSentenceBlock.kt index 0caa0eaf42..2b7783d8c0 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleSentenceBlock.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleSentenceBlock.kt @@ -1,4 +1,4 @@ -package org.utbot.summary.comment +package org.utbot.summary.comment.classic.symbolic import org.utbot.framework.plugin.api.DocCodeStmt import org.utbot.framework.plugin.api.DocRegularStmt @@ -12,6 +12,7 @@ import org.utbot.summary.SummarySentenceConstants.NEW_LINE import org.utbot.summary.SummarySentenceConstants.OPEN_BRACKET import org.utbot.summary.SummarySentenceConstants.SENTENCE_SEPARATION import org.utbot.summary.SummarySentenceConstants.TAB +import org.utbot.summary.comment.* class SimpleSentenceBlock(val stringTemplates: StringsTemplatesInterface) { val iterationSentenceBlocks = mutableListOf>>() diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt index 1d34e70235..6b4de29844 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt @@ -7,6 +7,7 @@ import org.utbot.framework.plugin.api.DocStatement import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN import org.utbot.summary.ast.JimpleToASTMap import org.utbot.summary.comment.* +import org.utbot.summary.comment.classic.symbolic.* import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest import org.utbot.summary.tag.BasicTypeTag import org.utbot.summary.tag.CallOrderTag 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 1efa67f218..46d7677d8a 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 @@ -1,8 +1,10 @@ package org.utbot.summary.comment.customtags import org.utbot.framework.plugin.api.ClassId -import org.utbot.summary.SummarySentenceConstants -import org.utbot.summary.comment.EMPTY_STRING +import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN +import org.utbot.summary.SummarySentenceConstants.JAVA_CLASS_DELIMITER +import org.utbot.summary.SummarySentenceConstants.JAVA_DOC_CLASS_DELIMITER +import org.utbot.summary.comment.classic.symbolic.EMPTY_STRING import soot.Type /** @@ -37,7 +39,8 @@ fun getMethodReferenceForFuzzingTest(className: String, methodName: String, meth val methodParametersAsString = if (methodParameterTypes.isNotEmpty()) methodParameterTypes.joinToString(",") { it.canonicalName } else EMPTY_STRING return formMethodReferenceForJavaDoc(className, methodName, methodParametersAsString, isPrivate).replace( - SummarySentenceConstants.CARRIAGE_RETURN, EMPTY_STRING) + CARRIAGE_RETURN, EMPTY_STRING + ) } private fun formMethodReferenceForJavaDoc( @@ -46,9 +49,9 @@ private fun formMethodReferenceForJavaDoc( methodParametersAsString: String, isPrivate: Boolean ): String { - val prettyClassName: String = className.replace("$", ".") + val prettyClassName: String = className.replace(JAVA_CLASS_DELIMITER, JAVA_DOC_CLASS_DELIMITER) - val text = if (methodParametersAsString == "") { + val text = if (methodParametersAsString == EMPTY_STRING) { "$prettyClassName#$methodName()" } else { "$prettyClassName#$methodName($methodParametersAsString)" @@ -66,5 +69,5 @@ private fun formMethodReferenceForJavaDoc( * Replaces '$' with '.' in case a class is nested. */ fun getClassReference(fullClassName: String): String { - return "{@link ${fullClassName.replace("$", ".")}}".replace(SummarySentenceConstants.CARRIAGE_RETURN, EMPTY_STRING) + return "{@link ${fullClassName.replace(JAVA_CLASS_DELIMITER, JAVA_DOC_CLASS_DELIMITER)}}".replace(CARRIAGE_RETURN, EMPTY_STRING) } \ No newline at end of file diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzer.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzer.kt index d3f99b66cc..6cefc2c888 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzer.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzer.kt @@ -1,6 +1,6 @@ package org.utbot.summary.comment.customtags.fuzzer -import org.utbot.summary.comment.EMPTY_STRING +import org.utbot.summary.comment.classic.symbolic.EMPTY_STRING /** * Represents a set of plugin's custom JavaDoc tags. diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocComment.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocComment.kt index e0043cd4ea..24f237318e 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocComment.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocComment.kt @@ -1,6 +1,6 @@ package org.utbot.summary.comment.customtags.symbolic -import org.utbot.summary.comment.EMPTY_STRING +import org.utbot.summary.comment.classic.symbolic.EMPTY_STRING /** * Represents a set of plugin's custom JavaDoc tags. diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt index 3ace8b94e0..1724357570 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt @@ -6,6 +6,7 @@ import org.utbot.framework.plugin.api.exceptionOrNull import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN import org.utbot.summary.ast.JimpleToASTMap import org.utbot.summary.comment.* +import org.utbot.summary.comment.classic.symbolic.* import org.utbot.summary.comment.customtags.getClassReference import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest import org.utbot.summary.tag.TraceTagWithoutExecution diff --git a/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SimpleCommentBuilderTest.kt b/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SimpleCommentBuilderTest.kt index cb81c5f3f7..17fa0d3d17 100644 --- a/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SimpleCommentBuilderTest.kt +++ b/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SimpleCommentBuilderTest.kt @@ -9,6 +9,7 @@ import org.mockito.Mockito.`when` import org.utbot.framework.plugin.api.Step import org.utbot.framework.plugin.api.UtOverflowFailure import org.utbot.summary.ast.JimpleToASTMap +import org.utbot.summary.comment.classic.symbolic.SimpleCommentBuilder import org.utbot.summary.comment.customtags.getMethodReferenceForSymbolicTest import org.utbot.summary.tag.StatementTag import org.utbot.summary.tag.TraceTag