From fe4c6d112817c1c4dcf8ebbbb4e44a3005ed9d80 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Tue, 4 Oct 2022 11:54:30 +0300 Subject: [PATCH 1/6] Added an initial solution --- .../javadoc/UtCustomJavaDocTagProvider.kt | 4 +- .../kotlin/org/utbot/summary/Summarization.kt | 5 +- .../comment/CustomJavaDocTagProvider.kt | 70 ------------ ...leCommentForTestProducedByFuzzerBuilder.kt | 24 ++++ .../symbolic}/SimpleCommentBuilder.kt | 0 .../symbolic}/SimpleSentenceBlock.kt | 0 .../SymbolicExecutionClusterCommentBuilder.kt | 4 +- ...entWithCustomTagForTestProducedByFuzzer.kt | 13 +++ ...CustomTagForTestProducedByFuzzerBuilder.kt | 44 ++++++++ .../symbolic}/CustomJavaDocComment.kt | 4 +- .../symbolic}/CustomJavaDocCommentBuilder.kt | 4 +- .../symbolic/CustomJavaDocTagProvider.kt | 106 ++++++++++++++++++ .../fuzzer/names/ModelBasedNameSuggester.kt | 28 +++-- .../summary/fuzzer/names/TestSuggestedInfo.kt | 7 +- ...bolicExecutionClusterCommentBuilderTest.kt | 1 + 15 files changed, 224 insertions(+), 90 deletions(-) delete mode 100644 utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocTagProvider.kt create mode 100644 utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/fuzzer/SimpleCommentForTestProducedByFuzzerBuilder.kt rename utbot-summary/src/main/kotlin/org/utbot/summary/comment/{ => classic/symbolic}/SimpleCommentBuilder.kt (100%) rename utbot-summary/src/main/kotlin/org/utbot/summary/comment/{ => classic/symbolic}/SimpleSentenceBlock.kt (100%) rename utbot-summary/src/main/kotlin/org/utbot/summary/comment/{ => cluster}/SymbolicExecutionClusterCommentBuilder.kt (98%) create mode 100644 utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzer.kt create mode 100644 utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt rename utbot-summary/src/main/kotlin/org/utbot/summary/comment/{ => customtags/symbolic}/CustomJavaDocComment.kt (87%) rename utbot-summary/src/main/kotlin/org/utbot/summary/comment/{ => customtags/symbolic}/CustomJavaDocCommentBuilder.kt (97%) create mode 100644 utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocTagProvider.kt diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/javadoc/UtCustomJavaDocTagProvider.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/javadoc/UtCustomJavaDocTagProvider.kt index c82e37b027..cd3dd4566c 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/javadoc/UtCustomJavaDocTagProvider.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/javadoc/UtCustomJavaDocTagProvider.kt @@ -6,8 +6,8 @@ import com.intellij.psi.PsiReference import com.intellij.psi.javadoc.CustomJavadocTagProvider import com.intellij.psi.javadoc.JavadocTagInfo import com.intellij.psi.javadoc.PsiDocTagValue -import org.utbot.summary.comment.CustomJavaDocTag -import org.utbot.summary.comment.CustomJavaDocTagProvider +import org.utbot.summary.comment.customtags.symbolic.CustomJavaDocTag +import org.utbot.summary.comment.customtags.symbolic.CustomJavaDocTagProvider /** * Provides plugin's custom JavaDoc tags to make test summaries structured. 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 40922e2845..7c71f4a3f4 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt @@ -16,7 +16,7 @@ import org.utbot.summary.UtSummarySettings.GENERATE_NAMES import org.utbot.summary.analysis.ExecutionStructureAnalysis import org.utbot.summary.ast.JimpleToASTMap import org.utbot.summary.ast.SourceCodeParser -import org.utbot.summary.comment.SymbolicExecutionClusterCommentBuilder +import org.utbot.summary.comment.cluster.SymbolicExecutionClusterCommentBuilder import org.utbot.summary.comment.SimpleCommentBuilder import org.utbot.summary.name.SimpleNameBuilder import java.io.File @@ -37,7 +37,7 @@ import org.utbot.fuzzer.FuzzedValue import org.utbot.fuzzer.UtFuzzedExecution import org.utbot.summary.fuzzer.names.MethodBasedNameSuggester import org.utbot.summary.fuzzer.names.ModelBasedNameSuggester -import org.utbot.summary.comment.CustomJavaDocCommentBuilder +import org.utbot.summary.comment.customtags.symbolic.CustomJavaDocCommentBuilder import soot.SootMethod private val logger = KotlinLogging.logger {} @@ -241,6 +241,7 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List unsuccessfulFuzzerExecutions.add(utExecution) diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocTagProvider.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocTagProvider.kt deleted file mode 100644 index 4c98d8a379..0000000000 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocTagProvider.kt +++ /dev/null @@ -1,70 +0,0 @@ -package org.utbot.summary.comment - -import org.utbot.framework.plugin.api.DocRegularStmt - -/** - * Provides a list of supported custom JavaDoc tags. - */ -class CustomJavaDocTagProvider { - // The tags' order is important because plugin builds final JavaDoc comment according to it. - fun getPluginCustomTags(): List = - listOf( - CustomJavaDocTag.ClassUnderTest, - CustomJavaDocTag.MethodUnderTest, - CustomJavaDocTag.ExpectedResult, - CustomJavaDocTag.ActualResult, - CustomJavaDocTag.Executes, - CustomJavaDocTag.Invokes, - CustomJavaDocTag.Iterates, - CustomJavaDocTag.SwitchCase, - CustomJavaDocTag.Recursion, - CustomJavaDocTag.ReturnsFrom, - CustomJavaDocTag.CaughtException, - CustomJavaDocTag.ThrowsException, - ) -} - -sealed class CustomJavaDocTag( - val name: String, - val message: String, - private val valueRetriever: (CustomJavaDocComment) -> Any -) { - object ClassUnderTest : - CustomJavaDocTag("utbot.classUnderTest", "Class under test", CustomJavaDocComment::classUnderTest) - - object MethodUnderTest : - CustomJavaDocTag("utbot.methodUnderTest", "Method under test", CustomJavaDocComment::methodUnderTest) - - object ExpectedResult : - CustomJavaDocTag("utbot.expectedResult", "Expected result", CustomJavaDocComment::expectedResult) - - object ActualResult : CustomJavaDocTag("utbot.actualResult", "Actual result", CustomJavaDocComment::actualResult) - object Executes : - CustomJavaDocTag("utbot.executesCondition", "Executes condition", CustomJavaDocComment::executesCondition) - - object Invokes : CustomJavaDocTag("utbot.invokes", "Invokes", CustomJavaDocComment::invokes) - object Iterates : CustomJavaDocTag("utbot.iterates", "Iterates", CustomJavaDocComment::iterates) - object SwitchCase : CustomJavaDocTag("utbot.activatesSwitch", "Activates switch", CustomJavaDocComment::switchCase) - object Recursion : - CustomJavaDocTag("utbot.triggersRecursion", "Triggers recursion ", CustomJavaDocComment::recursion) - - object ReturnsFrom : CustomJavaDocTag("utbot.returnsFrom", "Returns from", CustomJavaDocComment::returnsFrom) - object CaughtException : - CustomJavaDocTag("utbot.caughtException", "Caught exception", CustomJavaDocComment::caughtException) - - object ThrowsException : - CustomJavaDocTag("utbot.throwsException", "Throws exception", CustomJavaDocComment::throwsException) - - fun generateDocStatement(comment: CustomJavaDocComment): DocRegularStmt? = - when (val value = valueRetriever.invoke(comment)) { - is String -> value.takeIf { it.isNotEmpty() }?.let { - DocRegularStmt("@$name $value\n") - } - is List<*> -> value.takeIf { it.isNotEmpty() }?.let { - val valueToString = value.joinToString(separator = "\n", postfix = "\n") {"@$name $it"} - - DocRegularStmt(valueToString) - } - else -> null - } -} \ No newline at end of file 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 new file mode 100644 index 0000000000..6668d95df0 --- /dev/null +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/fuzzer/SimpleCommentForTestProducedByFuzzerBuilder.kt @@ -0,0 +1,24 @@ +package org.utbot.summary.comment.classic.fuzzer + +import org.utbot.framework.plugin.api.DocPreTagStatement +import org.utbot.framework.plugin.api.DocStatement +import org.utbot.framework.plugin.api.UtExecutionResult +import org.utbot.fuzzer.FuzzedMethodDescription +import org.utbot.fuzzer.FuzzedValue + +class SimpleCommentForTestProducedByFuzzerBuilder( + description: FuzzedMethodDescription, + values: List, + result: UtExecutionResult? +) { + fun buildDocStatements(): List { + //val sentenceBlock = buildSentenceBlock(currentMethod) + //val docStmts = toDocStmts(sentenceBlock) + + /* if (docStmts.isEmpty()) { + return emptyList() + }*/ + + return listOf(DocPreTagStatement(emptyList())) + } +} \ No newline at end of file diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt similarity index 100% rename from utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleCommentBuilder.kt rename to utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleCommentBuilder.kt diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleSentenceBlock.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleSentenceBlock.kt similarity index 100% rename from utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleSentenceBlock.kt rename to utbot-summary/src/main/kotlin/org/utbot/summary/comment/classic/symbolic/SimpleSentenceBlock.kt diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SymbolicExecutionClusterCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt similarity index 98% rename from utbot-summary/src/main/kotlin/org/utbot/summary/comment/SymbolicExecutionClusterCommentBuilder.kt rename to utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt index 97663ff8b3..730352b230 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SymbolicExecutionClusterCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/cluster/SymbolicExecutionClusterCommentBuilder.kt @@ -1,12 +1,12 @@ -package org.utbot.summary.comment +package org.utbot.summary.comment.cluster import com.github.javaparser.ast.stmt.CatchClause import com.github.javaparser.ast.stmt.ForStmt import org.utbot.framework.plugin.api.DocPreTagStatement -import org.utbot.framework.plugin.api.DocRegularStmt 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.tag.BasicTypeTag import org.utbot.summary.tag.CallOrderTag import org.utbot.summary.tag.StatementTag 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 new file mode 100644 index 0000000000..1833220be3 --- /dev/null +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzer.kt @@ -0,0 +1,13 @@ +package org.utbot.summary.comment.customtags.fuzzer + +/** + * Represents a set of plugin's custom JavaDoc tags. + */ +data class CommentWithCustomTagForTestProducedByFuzzer( + val classUnderTest: String = "", + val methodUnderTest: String = "", + val expectedResult: String = "", + val actualResult: String = "", + var returnsFrom: String = "", + var throwsException: 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 new file mode 100644 index 0000000000..f0947798b8 --- /dev/null +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/fuzzer/CommentWithCustomTagForTestProducedByFuzzerBuilder.kt @@ -0,0 +1,44 @@ +package org.utbot.summary.comment.customtags.fuzzer + +import org.utbot.framework.plugin.api.DocCustomTagStatement +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.comment.customtags.symbolic.CustomJavaDocTagProvider + +/** + * Builds JavaDoc comments for generated tests using plugin's custom JavaDoc tags. + */ +class CommentWithCustomTagForTestProducedByFuzzerBuilder( + val methodDescription: FuzzedMethodDescription, + val values: List, + val result: UtExecutionResult? +) { + /** + * Collects statements for final JavaDoc comment. + */ + fun buildDocStatements(): List { + val comment = buildCustomJavaDocComment() + val docStatementList = + CustomJavaDocTagProvider().getPluginCustomTags().mapNotNull { it.generateDocStatementForTestProducedByFuzzer(comment) } + return listOf(DocCustomTagStatement(docStatementList)) + } + + private fun buildCustomJavaDocComment(): CommentWithCustomTagForTestProducedByFuzzer { + /*val methodReference = getMethodReference( + currentMethod.declaringClass.name, + currentMethod.name, + currentMethod.parameterTypes + ) + val classReference = getClassReference(currentMethod.declaringClass.javaStyleName)*/ + + val javaDocComment = CommentWithCustomTagForTestProducedByFuzzer( + classUnderTest = methodDescription.className!!, + methodUnderTest = methodDescription.name, + ) + + + return javaDocComment + } +} \ No newline at end of file diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocComment.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocComment.kt similarity index 87% rename from utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocComment.kt rename to utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocComment.kt index fffe9cbf8b..e0043cd4ea 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocComment.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocComment.kt @@ -1,4 +1,6 @@ -package org.utbot.summary.comment +package org.utbot.summary.comment.customtags.symbolic + +import org.utbot.summary.comment.EMPTY_STRING /** * Represents a set of plugin's custom JavaDoc tags. diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt similarity index 97% rename from utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt rename to utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt index 62eb0e1d29..0b8a930da1 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocCommentBuilder.kt @@ -1,11 +1,11 @@ -package org.utbot.summary.comment +package org.utbot.summary.comment.customtags.symbolic import org.utbot.framework.plugin.api.DocCustomTagStatement import org.utbot.framework.plugin.api.DocStatement import org.utbot.framework.plugin.api.exceptionOrNull -import org.utbot.summary.SummarySentenceConstants import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN import org.utbot.summary.ast.JimpleToASTMap +import org.utbot.summary.comment.* import org.utbot.summary.tag.TraceTagWithoutExecution import soot.SootMethod diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocTagProvider.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocTagProvider.kt new file mode 100644 index 0000000000..3c2ed9bd6d --- /dev/null +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocTagProvider.kt @@ -0,0 +1,106 @@ +package org.utbot.summary.comment.customtags.symbolic + +import org.utbot.framework.plugin.api.DocRegularStmt +import org.utbot.summary.comment.customtags.fuzzer.CommentWithCustomTagForTestProducedByFuzzer + +/** + * Provides a list of supported custom JavaDoc tags. + */ +class CustomJavaDocTagProvider { + // The tags' order is important because plugin builds final JavaDoc comment according to it. + fun getPluginCustomTags(): List = + listOf( + CustomJavaDocTag.ClassUnderTest, + CustomJavaDocTag.MethodUnderTest, + CustomJavaDocTag.ExpectedResult, + CustomJavaDocTag.ActualResult, + CustomJavaDocTag.Executes, + CustomJavaDocTag.Invokes, + CustomJavaDocTag.Iterates, + CustomJavaDocTag.SwitchCase, + CustomJavaDocTag.Recursion, + CustomJavaDocTag.ReturnsFrom, + CustomJavaDocTag.CaughtException, + CustomJavaDocTag.ThrowsException, + ) +} + +sealed class CustomJavaDocTag( + val name: String, + val message: String, + private val valueRetriever: (CustomJavaDocComment) -> Any, + private val valueRetrieverFuzzer: ((CommentWithCustomTagForTestProducedByFuzzer) -> Any)? // TODO: remove after refactoring +) { + object ClassUnderTest : + CustomJavaDocTag( + "utbot.classUnderTest", + "Class under test", + CustomJavaDocComment::classUnderTest, + CommentWithCustomTagForTestProducedByFuzzer::classUnderTest + ) + + object MethodUnderTest : + CustomJavaDocTag( + "utbot.methodUnderTest", + "Method under test", + CustomJavaDocComment::methodUnderTest, + CommentWithCustomTagForTestProducedByFuzzer::methodUnderTest + ) + + object ExpectedResult : + CustomJavaDocTag("utbot.expectedResult", "Expected result", CustomJavaDocComment::expectedResult, null) + + object ActualResult : + CustomJavaDocTag("utbot.actualResult", "Actual result", CustomJavaDocComment::actualResult, null) + + object Executes : + CustomJavaDocTag("utbot.executesCondition", "Executes condition", CustomJavaDocComment::executesCondition, null) + + object Invokes : CustomJavaDocTag("utbot.invokes", "Invokes", CustomJavaDocComment::invokes, null) + object Iterates : CustomJavaDocTag("utbot.iterates", "Iterates", CustomJavaDocComment::iterates, null) + object SwitchCase : + CustomJavaDocTag("utbot.activatesSwitch", "Activates switch", CustomJavaDocComment::switchCase, null) + + object Recursion : + CustomJavaDocTag("utbot.triggersRecursion", "Triggers recursion ", CustomJavaDocComment::recursion, null) + + object ReturnsFrom : CustomJavaDocTag("utbot.returnsFrom", "Returns from", CustomJavaDocComment::returnsFrom, null) + object CaughtException : + CustomJavaDocTag("utbot.caughtException", "Caught exception", CustomJavaDocComment::caughtException, null) + + object ThrowsException : + CustomJavaDocTag("utbot.throwsException", "Throws exception", CustomJavaDocComment::throwsException, null) + + fun generateDocStatement(comment: CustomJavaDocComment): DocRegularStmt? = + when (val value = valueRetriever.invoke(comment)) { + is String -> value.takeIf { it.isNotEmpty() }?.let { + DocRegularStmt("@$name $value\n") + } + is List<*> -> value.takeIf { it.isNotEmpty() }?.let { + val valueToString = value.joinToString(separator = "\n", postfix = "\n") { "@$name $it" } + + DocRegularStmt(valueToString) + } + else -> null + } + + // TODO: could be universal with the function above after creation of hierarchy data classes related to the comments + fun generateDocStatementForTestProducedByFuzzer(comment: CommentWithCustomTagForTestProducedByFuzzer): DocRegularStmt? { + if (valueRetrieverFuzzer != null) { //TODO: it required only when we have two different retrievers + return when (val value = valueRetrieverFuzzer!!.invoke(comment)) { // TODO: unsafe !! - resolve + is String -> value.takeIf { it.isNotEmpty() }?.let { + DocRegularStmt("@$name $value\n") + } + + is List<*> -> value.takeIf { it.isNotEmpty() }?.let { + val valueToString = value.joinToString(separator = ",\n", postfix = "\n") + + DocRegularStmt("@$name $valueToString") + } + + else -> null + } + } + return null + } +} \ 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 38160e4ddd..823717f604 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 @@ -1,16 +1,12 @@ package org.utbot.summary.fuzzer.names -import org.utbot.framework.plugin.api.UtExecutionFailure -import org.utbot.framework.plugin.api.UtExecutionResult -import org.utbot.framework.plugin.api.UtExecutionSuccess -import org.utbot.framework.plugin.api.UtExplicitlyThrownException -import org.utbot.framework.plugin.api.UtImplicitlyThrownException -import org.utbot.framework.plugin.api.UtNullModel -import org.utbot.framework.plugin.api.UtPrimitiveModel -import org.utbot.framework.plugin.api.exceptionOrNull +import org.utbot.framework.UtSettings +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.comment.classic.fuzzer.SimpleCommentForTestProducedByFuzzerBuilder +import org.utbot.summary.comment.customtags.fuzzer.CommentWithCustomTagForTestProducedByFuzzerBuilder import java.util.* class ModelBasedNameSuggester( @@ -37,7 +33,8 @@ class ModelBasedNameSuggester( return sequenceOf( TestSuggestedInfo( testName = createTestName(description, values, result), - displayName = createDisplayName(description, values, result) + displayName = createDisplayName(description, values, result), + javaDoc = createJavaDoc(description, values, result) ) ) } @@ -142,6 +139,19 @@ class ModelBasedNameSuggester( return listOfNotNull(parameters, returnValue).joinToString(separator = " ") } + /** + * Builds the JavaDoc. + */ + private fun createJavaDoc( + description: FuzzedMethodDescription, + values: List, + result: UtExecutionResult? + ): List { + return if (UtSettings.useCustomJavaDocTags) { + CommentWithCustomTagForTestProducedByFuzzerBuilder(description, values, result).buildDocStatements() + } else SimpleCommentForTestProducedByFuzzerBuilder(description, values, result).buildDocStatements() + } + companion object { private fun prettifyNumber(value: T): String? { return when { diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/fuzzer/names/TestSuggestedInfo.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/fuzzer/names/TestSuggestedInfo.kt index e7b47c7ed1..ba36379bcf 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/fuzzer/names/TestSuggestedInfo.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/fuzzer/names/TestSuggestedInfo.kt @@ -1,9 +1,12 @@ package org.utbot.summary.fuzzer.names +import org.utbot.framework.plugin.api.DocStatement + /** - * Information that can be used to generate test names. + * Information that can be used to generate test meta-information, including name, display name and JavaDoc. */ class TestSuggestedInfo( val testName: String, - val displayName: String? = null + val displayName: String? = null, + val javaDoc: List? = null ) \ No newline at end of file diff --git a/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SymbolicExecutionClusterCommentBuilderTest.kt b/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SymbolicExecutionClusterCommentBuilderTest.kt index ab4c93c06e..5a3b7fe255 100644 --- a/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SymbolicExecutionClusterCommentBuilderTest.kt +++ b/utbot-summary/src/test/kotlin/org/utbot/summary/comment/SymbolicExecutionClusterCommentBuilderTest.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.cluster.SymbolicExecutionClusterCommentBuilder import org.utbot.summary.tag.StatementTag import org.utbot.summary.tag.TraceTag import soot.SootMethod From 6ada057c721b362e10b2eb1ac923f5d74a7e2e29 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Wed, 5 Oct 2022 19:49:46 +0300 Subject: [PATCH 2/6] Added a method and class references --- ...CustomTagForTestProducedByFuzzerBuilder.kt | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) 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 f0947798b8..9b0cd60134 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 @@ -1,10 +1,13 @@ package org.utbot.summary.comment.customtags.fuzzer +import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.DocCustomTagStatement 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.CARRIAGE_RETURN import org.utbot.summary.comment.customtags.symbolic.CustomJavaDocTagProvider /** @@ -26,19 +29,45 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder( } private fun buildCustomJavaDocComment(): CommentWithCustomTagForTestProducedByFuzzer { - /*val methodReference = getMethodReference( - currentMethod.declaringClass.name, - currentMethod.name, - currentMethod.parameterTypes + val methodReference = getMethodReference( + methodDescription.packageName!! + "." + methodDescription.className!!, + methodDescription.compilableName!!, + methodDescription.parameters ) - val classReference = getClassReference(currentMethod.declaringClass.javaStyleName)*/ + val classReference = getClassReference(methodDescription.packageName!! + "." +methodDescription.className!!) val javaDocComment = CommentWithCustomTagForTestProducedByFuzzer( - classUnderTest = methodDescription.className!!, - methodUnderTest = methodDescription.name, + classUnderTest = classReference.replace(CARRIAGE_RETURN, ""), + methodUnderTest = methodReference.replace(CARRIAGE_RETURN, ""), ) - return javaDocComment } + + /** + * Returns a reference to the invoked method. + * + * It looks like {@link packageName.className#methodName(type1, type2)}. + * + * In case when an enclosing class in nested, we need to replace '$' with '.' + * to render the reference. + */ + private fun getMethodReference(className: String, methodName: String, methodParameterTypes: List): String { + val prettyClassName: String = className.replace("$", ".") + + return if (methodParameterTypes.isEmpty()) { + "{@link $prettyClassName#$methodName()}" + } else { + val methodParametersAsString = methodParameterTypes.joinToString(",") { it.canonicalName } + "{@link $prettyClassName#$methodName($methodParametersAsString)}" + } + } + + /** + * Returns a reference to the class. + * Replaces '$' with '.' in case a class is nested. + */ + private fun getClassReference(fullClassName: String): String { + return "{@link ${fullClassName.replace("$", ".")}}" + } } \ No newline at end of file From a5ca42bd193040a5147b596d0449dc3efa3a7341 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Thu, 6 Oct 2022 18:42:06 +0300 Subject: [PATCH 3/6] Refactor to avoid bugs with private methods --- .../classic/symbolic/SimpleCommentBuilder.kt | 40 +---------- .../SymbolicExecutionClusterCommentBuilder.kt | 1 + .../comment/customtags/CustomTagsUtil.kt | 68 +++++++++++++++++++ ...CustomTagForTestProducedByFuzzerBuilder.kt | 36 ++-------- .../symbolic/CustomJavaDocCommentBuilder.kt | 2 + 5 files changed, 77 insertions(+), 70 deletions(-) create mode 100644 utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/CustomTagsUtil.kt 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 8d86ea777e..781902a05b 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,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.customtags.getMethodReference import org.utbot.summary.tag.BasicTypeTag import org.utbot.summary.tag.CallOrderTag import org.utbot.summary.tag.StatementTag @@ -356,45 +357,6 @@ open class SimpleCommentBuilder( ) } - /** - * Returns a reference to the invoked method. IDE can't resolve references to private methods in comments, - * so we add @link tag only if the invoked method is not private. - * - * It looks like {@link packageName.className#methodName(type1, type2)}. - * - * In case when an enclosing class in nested, we need to replace '$' with '.' - * to render the reference. - */ - fun getMethodReference( - 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}" - } - } - - /** - * Returns a reference to the class. - * Replaces '$' with '.' in case a class is nested. - */ - fun getClassReference(fullClasName: String): String { - return "{@link ${fullClasName.replace("$", ".")}}" - } - protected fun buildIterationsBlock( iterations: List, activatedStep: Step, 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 cb73554eef..ea09506ab3 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.customtags.getMethodReference import org.utbot.summary.tag.BasicTypeTag import org.utbot.summary.tag.CallOrderTag import org.utbot.summary.tag.StatementTag 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 new file mode 100644 index 0000000000..496f6d1ef6 --- /dev/null +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/CustomTagsUtil.kt @@ -0,0 +1,68 @@ +package org.utbot.summary.comment.customtags + +import org.utbot.framework.plugin.api.ClassId +import soot.Type + +/** + * Returns a reference to the invoked method. IDE can't resolve references to private methods in comments, + * so we add @link tag only if the invoked method is not private. + * + * It looks like {@link packageName.className#methodName(type1, type2)}. + * + * In case when an enclosing class in nested, we need to replace '$' with '.' + * to render the reference. + */ +fun getMethodReference( + 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}" + } +} + +/** + * Returns a reference to the class. + * Replaces '$' with '.' in case a class is nested. + */ +fun getClassReference(fullClassName: String): String { + return "{@link ${fullClassName.replace("$", ".")}}" +} + +/** + * Returns a reference to the invoked method. + * + * It looks like {@link packageName.className#methodName(type1, type2)}. + * + * In case when an enclosing class in nested, we need to replace '$' with '.' + * to render the reference. + */ +fun getMethodReferenceForFuzzingTest(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(",") { it.canonicalName } + "$prettyClassName#$methodName($methodParametersAsString)" + } + + return if (isPrivate) { + text + } else { + "{@link $text}" + } +} \ 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 9b0cd60134..584120b97c 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 @@ -1,13 +1,13 @@ package org.utbot.summary.comment.customtags.fuzzer -import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.DocCustomTagStatement 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.CARRIAGE_RETURN +import org.utbot.summary.comment.customtags.getClassReference +import org.utbot.summary.comment.customtags.getMethodReferenceForFuzzingTest import org.utbot.summary.comment.customtags.symbolic.CustomJavaDocTagProvider /** @@ -29,10 +29,11 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder( } private fun buildCustomJavaDocComment(): CommentWithCustomTagForTestProducedByFuzzer { - val methodReference = getMethodReference( + val methodReference = getMethodReferenceForFuzzingTest( methodDescription.packageName!! + "." + methodDescription.className!!, methodDescription.compilableName!!, - methodDescription.parameters + methodDescription.parameters, + false ) val classReference = getClassReference(methodDescription.packageName!! + "." +methodDescription.className!!) @@ -43,31 +44,4 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder( return javaDocComment } - - /** - * Returns a reference to the invoked method. - * - * It looks like {@link packageName.className#methodName(type1, type2)}. - * - * In case when an enclosing class in nested, we need to replace '$' with '.' - * to render the reference. - */ - private fun getMethodReference(className: String, methodName: String, methodParameterTypes: List): String { - val prettyClassName: String = className.replace("$", ".") - - return if (methodParameterTypes.isEmpty()) { - "{@link $prettyClassName#$methodName()}" - } else { - val methodParametersAsString = methodParameterTypes.joinToString(",") { it.canonicalName } - "{@link $prettyClassName#$methodName($methodParametersAsString)}" - } - } - - /** - * Returns a reference to the class. - * Replaces '$' with '.' in case a class is nested. - */ - private fun getClassReference(fullClassName: String): String { - return "{@link ${fullClassName.replace("$", ".")}}" - } } \ No newline at end of file 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 a018ac69bc..9c19b4e521 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,8 @@ 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.customtags.getClassReference +import org.utbot.summary.comment.customtags.getMethodReference import org.utbot.summary.tag.TraceTagWithoutExecution import soot.SootMethod From f94554a52cc165b3a6f3e02e6beaf6bb79b0aad5 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Mon, 10 Oct 2022 17:01:27 +0300 Subject: [PATCH 4/6] Handled empty values --- ...CustomTagForTestProducedByFuzzerBuilder.kt | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) 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 584120b97c..d97f12da7c 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 @@ -29,19 +29,28 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder( } private fun buildCustomJavaDocComment(): CommentWithCustomTagForTestProducedByFuzzer { - val methodReference = getMethodReferenceForFuzzingTest( - methodDescription.packageName!! + "." + methodDescription.className!!, - methodDescription.compilableName!!, - methodDescription.parameters, - false - ) - val classReference = getClassReference(methodDescription.packageName!! + "." +methodDescription.className!!) + val packageName = methodDescription.packageName + val className = methodDescription.className + val methodName = methodDescription.compilableName - val javaDocComment = CommentWithCustomTagForTestProducedByFuzzer( - classUnderTest = classReference.replace(CARRIAGE_RETURN, ""), - methodUnderTest = methodReference.replace(CARRIAGE_RETURN, ""), - ) + return if(packageName!=null && className!=null && methodName!=null) { + val fullClassName = "$packageName.$className" - return javaDocComment + val methodReference = getMethodReferenceForFuzzingTest( + fullClassName, + methodName, + methodDescription.parameters, + false + ).replace(CARRIAGE_RETURN, "") + + val classReference = getClassReference(fullClassName).replace(CARRIAGE_RETURN, "") + + CommentWithCustomTagForTestProducedByFuzzer( + classUnderTest = classReference, + methodUnderTest = methodReference, + ) + } else { + CommentWithCustomTagForTestProducedByFuzzer() + } } -} \ No newline at end of file +} From 51ca8de9c73b2349f5b83ba2127d9a124ead88f3 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Mon, 10 Oct 2022 17:14:18 +0300 Subject: [PATCH 5/6] Fixed tests and add a TODO ticket --- .../fuzzer/SimpleCommentForTestProducedByFuzzerBuilder.kt | 8 +------- .../org/utbot/summary/comment/SimpleCommentBuilderTest.kt | 7 +++---- 2 files changed, 4 insertions(+), 11 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 6668d95df0..02f7736eff 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,19 +6,13 @@ import org.utbot.framework.plugin.api.UtExecutionResult import org.utbot.fuzzer.FuzzedMethodDescription import org.utbot.fuzzer.FuzzedValue +// TODO: https://github.com/UnitTestBot/UTBotJava/issues/1127 class SimpleCommentForTestProducedByFuzzerBuilder( description: FuzzedMethodDescription, values: List, result: UtExecutionResult? ) { fun buildDocStatements(): List { - //val sentenceBlock = buildSentenceBlock(currentMethod) - //val docStmts = toDocStmts(sentenceBlock) - - /* if (docStmts.isEmpty()) { - return emptyList() - }*/ - return listOf(DocPreTagStatement(emptyList())) } } \ No newline at end of file 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 738adb39be..a18e630d27 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.customtags.getMethodReference import org.utbot.summary.tag.StatementTag import org.utbot.summary.tag.TraceTag import soot.SootMethod @@ -66,17 +67,15 @@ class SimpleCommentBuilderTest { @Test fun `builds inline link for method`() { - val commentBuilder = SimpleCommentBuilder(traceTag, sootToAst) - val methodReference = commentBuilder.getMethodReference("org.utbot.ClassName", "methodName", listOf(), false) + val methodReference = getMethodReference("org.utbot.ClassName", "methodName", listOf(), false) val expectedMethodReference = "{@link org.utbot.ClassName#methodName()}" assertEquals(methodReference, expectedMethodReference) } @Test fun `builds inline link for method in nested class`() { - val commentBuilder = SimpleCommentBuilder(traceTag, sootToAst) val methodReference = - commentBuilder.getMethodReference("org.utbot.ClassName\$NestedClassName", "methodName", listOf(), false) + getMethodReference("org.utbot.ClassName\$NestedClassName", "methodName", listOf(), false) val expectedMethodReference = "{@link org.utbot.ClassName.NestedClassName#methodName()}" assertEquals(methodReference, expectedMethodReference) } From 0a95f295f03f41ccde58d90942f894c2d6f2b134 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Wed, 12 Oct 2022 12:50:44 +0300 Subject: [PATCH 6/6] Fixed review comments --- .../{symbolic => }/CustomJavaDocTagProvider.kt | 0 .../CommentWithCustomTagForTestProducedByFuzzer.kt | 14 ++++++++------ ...tWithCustomTagForTestProducedByFuzzerBuilder.kt | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) rename utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/{symbolic => }/CustomJavaDocTagProvider.kt (100%) diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocTagProvider.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/CustomJavaDocTagProvider.kt similarity index 100% rename from utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/symbolic/CustomJavaDocTagProvider.kt rename to utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/CustomJavaDocTagProvider.kt 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 1833220be3..d3f99b66cc 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,13 +1,15 @@ package org.utbot.summary.comment.customtags.fuzzer +import org.utbot.summary.comment.EMPTY_STRING + /** * Represents a set of plugin's custom JavaDoc tags. */ data class CommentWithCustomTagForTestProducedByFuzzer( - val classUnderTest: String = "", - val methodUnderTest: String = "", - val expectedResult: String = "", - val actualResult: String = "", - var returnsFrom: String = "", - var throwsException: String = "" + val classUnderTest: String = EMPTY_STRING, + val methodUnderTest: String = EMPTY_STRING, + val expectedResult: String = EMPTY_STRING, + val actualResult: String = EMPTY_STRING, + var returnsFrom: String = EMPTY_STRING, + var throwsException: String = 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 d97f12da7c..367eacc541 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 @@ -24,7 +24,8 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder( fun buildDocStatements(): List { val comment = buildCustomJavaDocComment() val docStatementList = - CustomJavaDocTagProvider().getPluginCustomTags().mapNotNull { it.generateDocStatementForTestProducedByFuzzer(comment) } + CustomJavaDocTagProvider().getPluginCustomTags() + .mapNotNull { it.generateDocStatementForTestProducedByFuzzer(comment) } return listOf(DocCustomTagStatement(docStatementList)) } @@ -33,7 +34,7 @@ class CommentWithCustomTagForTestProducedByFuzzerBuilder( val className = methodDescription.className val methodName = methodDescription.compilableName - return if(packageName!=null && className!=null && methodName!=null) { + return if (packageName != null && className != null && methodName != null) { val fullClassName = "$packageName.$className" val methodReference = getMethodReferenceForFuzzingTest(