Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: UnitTestBot/UTBotJava
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1e760a7df3995c65ff23f7ce0f17c19b19b68505
Choose a base ref
..
head repository: UnitTestBot/UTBotJava
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bcc21257be54108c9a33c2ce3ae44c01de92befc
Choose a head ref
Original file line number Diff line number Diff line change
@@ -87,6 +87,6 @@ val mockitoPatterns = listOf(MOCKITO_JAR_PATTERN, MOCKITO_MVN_PATTERN)
val MOCKITO_BASIC_MODULE_PATTERN = Regex("mockito-core")
val mockitoModulePatterns = listOf(MOCKITO_BASIC_MODULE_PATTERN)

const val MOCKITO_EXTENSIONS_STORAGE = "mockito-extensions"
const val MOCKITO_EXTENSIONS_FOLDER = "mockito-extensions"
const val MOCKITO_MOCKMAKER_FILE_NAME = "org.mockito.plugins.MockMaker"
val MOCKITO_EXTENSIONS_FILE_CONTENT = listOf("mock-maker-inline")
val MOCKITO_EXTENSIONS_FILE_CONTENT = "mock-maker-inline"
Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ import org.utbot.framework.codegen.StaticsMocking
import org.utbot.framework.codegen.TestFramework
import org.utbot.framework.codegen.TestNg
import org.utbot.framework.codegen.model.util.MOCKITO_EXTENSIONS_FILE_CONTENT
import org.utbot.framework.codegen.model.util.MOCKITO_EXTENSIONS_STORAGE
import org.utbot.framework.codegen.model.util.MOCKITO_EXTENSIONS_FOLDER
import org.utbot.framework.codegen.model.util.MOCKITO_MOCKMAKER_FILE_NAME
import org.utbot.framework.plugin.api.CodeGenerationSettingItem
import org.utbot.framework.plugin.api.CodegenLanguage
@@ -762,15 +762,15 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
* for further details.
*/
private fun configureMockitoResources(testResourcesPath: Path) {
val mockitoExtensionsPath = "$testResourcesPath/$MOCKITO_EXTENSIONS_STORAGE".toPath()
val mockitoExtensionsPath = "$testResourcesPath/$MOCKITO_EXTENSIONS_FOLDER".toPath()
val mockitoMockMakerPath = "$mockitoExtensionsPath/$MOCKITO_MOCKMAKER_FILE_NAME".toPath()

if (!testResourcesPath.exists()) Files.createDirectory(testResourcesPath)
if (!mockitoExtensionsPath.exists()) Files.createDirectory(mockitoExtensionsPath)

if (!mockitoMockMakerPath.exists()) {
Files.createFile(mockitoMockMakerPath)
Files.write(mockitoMockMakerPath, MOCKITO_EXTENSIONS_FILE_CONTENT)
Files.write(mockitoMockMakerPath, listOf(MOCKITO_EXTENSIONS_FILE_CONTENT))
}
}

@@ -1027,14 +1027,20 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
.map { f -> Paths.get(urlToPath(f.url)) }
}

return entriesPaths.all { path ->
if (Files.exists(path)) {
val fileNames = Files.walk(path).map { it.fileName }.toList()
fileNames.any { it.toString() == MOCKITO_MOCKMAKER_FILE_NAME }
} else {
false
return entriesPaths.all { entryPath ->
if (!Files.exists(entryPath)) return false

val mockMakerPath = "$entryPath/$MOCKITO_EXTENSIONS_FOLDER/$MOCKITO_MOCKMAKER_FILE_NAME".toPath()
if (!Files.exists(mockMakerPath)) return false

try {
val fileLines = Files.readAllLines(mockMakerPath)
fileLines.singleOrNull() == MOCKITO_EXTENSIONS_FILE_CONTENT
} catch (e: java.io.IOException) {
return false
}

}
}
}
}