Skip to content

Commit 5ab14c8

Browse files
authored
Make TypeReplacementApproach be sealed class, so configFqn is stored (#2032)
1 parent 868301b commit 5ab14c8

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/Domain.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,12 @@ enum class ProjectType {
737737
JavaScript,
738738
}
739739

740-
enum class TypeReplacementApproach {
740+
sealed class TypeReplacementApproach {
741741
/**
742742
* Do not replace interfaces and abstract classes with concrete implementors.
743743
* Use mocking instead of it.
744744
*/
745-
DO_NOT_REPLACE,
745+
object DoNotReplace : TypeReplacementApproach()
746746

747747
/**
748748
* Try to replace interfaces and abstract classes with concrete implementors
@@ -751,7 +751,7 @@ enum class TypeReplacementApproach {
751751
*
752752
* Currently used in Spring applications only.
753753
*/
754-
REPLACE_IF_POSSIBLE,
754+
class ReplaceIfPossible(val configFqn: String) : TypeReplacementApproach()
755755
}
756756

757757
abstract class DependencyInjectionFramework(

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ object UtTestsDialogProcessor {
180180
val applicationContext = when (model.projectType) {
181181
Spring -> {
182182
val shouldUseImplementors = when (model.typeReplacementApproach) {
183-
TypeReplacementApproach.DO_NOT_REPLACE -> false
184-
TypeReplacementApproach.REPLACE_IF_POSSIBLE -> true
183+
TypeReplacementApproach.DoNotReplace -> false
184+
is TypeReplacementApproach.ReplaceIfPossible -> true
185185
}
186186

187187
SpringApplicationContext(

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,8 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
546546

547547
model.typeReplacementApproach =
548548
when (springConfig.item) {
549-
NO_SPRING_CONFIGURATION_OPTION -> TypeReplacementApproach.DO_NOT_REPLACE
550-
else -> TypeReplacementApproach.REPLACE_IF_POSSIBLE
549+
NO_SPRING_CONFIGURATION_OPTION -> TypeReplacementApproach.DoNotReplace
550+
else -> TypeReplacementApproach.ReplaceIfPossible(springConfig.item)
551551
}
552552

553553
val settings = model.project.service<Settings>()

0 commit comments

Comments
 (0)