Skip to content

Inconsistent DisplayName is generated for a Collection used as the only parameter #684 #840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.utbot.framework.plugin.api.exceptionOrNull
import org.utbot.framework.plugin.api.util.voidClassId
import org.utbot.fuzzer.FuzzedMethodDescription
import org.utbot.fuzzer.FuzzedValue
import java.util.*

class ModelBasedNameSuggester(
private val suggester: List<SingleModelNameSuggester> = listOf(
Expand Down Expand Up @@ -52,7 +53,8 @@ class ModelBasedNameSuggester(
is UtExecutionSuccess -> (result.model as? UtPrimitiveModel)?.value?.let { v ->
when (v) {
is Number -> prettifyNumber(v)
is Boolean -> v.toString().capitalize()
is Boolean -> v.toString()
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
else -> null
}?.let { "Returns$it" }
}
Expand All @@ -78,7 +80,8 @@ class ModelBasedNameSuggester(

return buildString {
append("test")
append(description.compilableName?.capitalize() ?: "Method")
append(description.compilableName?.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
?: "Method")
append(returnString)
if (parameters.isNotEmpty()) {
append("With", parameters)
Expand All @@ -101,7 +104,12 @@ class ModelBasedNameSuggester(
.filterNotNull()
.toList()

val parameters = summaries.joinToString(postfix = if (summaries.size < values.size) " and others" else "")
val postfix = when {
summaries.isEmpty() && values.isNotEmpty() -> "with generated values"
summaries.size < values.size -> " and others"
else -> ""
}
val parameters = summaries.joinToString(postfix = postfix)

val returnValue = when(result) {
is UtExecutionSuccess -> result.model.let { m ->
Expand Down