Skip to content

Commit 115132a

Browse files
committed
Fixed a bug with unresolved links to methods
1 parent 58609af commit 115132a

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

utbot-sample/src/main/java/org/utbot/examples/unsafe/UnsafeWithField.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
public class UnsafeWithField {
66
Field field;
77

8-
Field setField(Field f) {
8+
public Field setField(Field f) {
99
field = f;
1010
return Field.INTEGER;
1111
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package examples.unsafe
2+
3+
import examples.CustomJavaDocTagsEnabler
4+
import examples.SummaryTestCaseGeneratorTest
5+
import org.junit.jupiter.api.Test
6+
import org.junit.jupiter.api.extension.ExtendWith
7+
import org.utbot.examples.unsafe.UnsafeWithField
8+
import org.utbot.framework.plugin.api.MockStrategyApi
9+
import org.utbot.tests.infrastructure.DoNotCalculate
10+
11+
@ExtendWith(CustomJavaDocTagsEnabler::class)
12+
class UnsafeWithFieldTest : SummaryTestCaseGeneratorTest(
13+
UnsafeWithField::class
14+
) {
15+
@Test
16+
fun testUnsafeWithField() {
17+
val summary1 = "@utbot.classUnderTest {@link UnsafeWithField}\n" +
18+
"@utbot.methodUnderTest {@link org.utbot.examples.unsafe.UnsafeWithField#setField(java.text.NumberFormat.Field)}\n" +
19+
"@utbot.returnsFrom {@code return Field.INTEGER;}"
20+
21+
val methodName1 = "testSetField_ReturnFieldINTEGER"
22+
23+
val displayName1 = "-> return Field.INTEGER"
24+
25+
val summaryKeys = listOf(
26+
summary1
27+
)
28+
29+
val displayNames = listOf(
30+
displayName1
31+
)
32+
33+
val methodNames = listOf(
34+
methodName1
35+
)
36+
37+
val method = UnsafeWithField::setField
38+
val mockStrategy = MockStrategyApi.NO_MOCKS
39+
val coverage = DoNotCalculate
40+
41+
summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
42+
}
43+
}

utbot-summary/src/main/kotlin/org/utbot/summary/comment/customtags/CustomTagsUtil.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ private fun formMethodReferenceForJavaDoc(
4949
methodParametersAsString: String,
5050
isPrivate: Boolean
5151
): String {
52-
val prettyClassName: String = className.replace(JAVA_CLASS_DELIMITER, JAVA_DOC_CLASS_DELIMITER)
52+
// to avoid $ in names for static inner classes
53+
val prettyClassName: String = className.replace("$", ".")
54+
val validMethodParameters = methodParametersAsString.replace("$", ".")
5355

54-
val text = if (methodParametersAsString == EMPTY_STRING) {
56+
val text = if (validMethodParameters == "") {
5557
"$prettyClassName#$methodName()"
5658
} else {
57-
"$prettyClassName#$methodName($methodParametersAsString)"
59+
"$prettyClassName#$methodName($validMethodParameters)"
5860
}
5961

6062
return if (isPrivate) {

0 commit comments

Comments
 (0)