Skip to content

Commit 87b61b2

Browse files
authored
Support subfolder XML search (#2102)
Add support for subfolder XML search
1 parent 3c5ecf2 commit 87b61b2

File tree

1 file changed

+3
-6
lines changed
  • utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/models

1 file changed

+3
-6
lines changed

utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/models/BaseTestModel.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.idea.core.getPackage
1515
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
1616
import org.jetbrains.kotlin.idea.util.rootManager
1717
import org.jetbrains.kotlin.idea.util.sourceRoot
18-
import org.jetbrains.kotlin.utils.addToStdlib.flatMapToNullable
1918
import org.utbot.common.PathUtil.fileExtension
2019
import org.utbot.framework.codegen.domain.ProjectType
2120
import org.utbot.framework.plugin.api.CodegenLanguage
@@ -25,10 +24,8 @@ import org.utbot.intellij.plugin.ui.utils.getSortedTestRoots
2524
import org.utbot.intellij.plugin.ui.utils.isBuildWithGradle
2625
import org.utbot.intellij.plugin.ui.utils.suitableTestSourceRoots
2726
import java.nio.file.Files
28-
import java.nio.file.Path
2927
import javax.xml.parsers.DocumentBuilderFactory
3028
import kotlin.streams.asSequence
31-
import kotlin.streams.toList
3229

3330
val PsiClass.packageName: String get() = this.containingFile.containingDirectory.getPackage()?.qualifiedName ?: ""
3431
const val HISTORY_LIMIT = 10
@@ -123,7 +120,7 @@ open class BaseTestsModel(
123120
val resourcesPaths =
124121
setOf(testModule, srcModule).flatMapTo(mutableSetOf()) { it.getResourcesPaths() }
125122
val xmlFilePaths = resourcesPaths.flatMapTo(mutableListOf()) { path ->
126-
Files.list(path)
123+
Files.walk(path)
127124
.asSequence()
128125
.filter { it.fileExtension == ".xml" }
129126
}
@@ -132,10 +129,10 @@ open class BaseTestsModel(
132129
return xmlFilePaths.mapNotNullTo(mutableSetOf()) { path ->
133130
val doc = builder.parse(path.toFile())
134131

135-
val isBeanTagName = doc.documentElement.tagName == "beans"
132+
val hasBeanTagName = doc.documentElement.tagName == "beans"
136133
val hasAttribute = doc.documentElement.getAttribute("xmlns") == "http://www.springframework.org/schema/beans"
137134
when {
138-
isBeanTagName && hasAttribute -> path.toString()
135+
hasBeanTagName && hasAttribute -> path.toString()
139136
else -> null
140137
}
141138
}

0 commit comments

Comments
 (0)