Skip to content

Make TypeReplacementApproach be sealed class, so configFqn is stored #2032

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
merged 1 commit into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
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 @@ -737,12 +737,12 @@ enum class ProjectType {
JavaScript,
}

enum class TypeReplacementApproach {
sealed class TypeReplacementApproach {
/**
* Do not replace interfaces and abstract classes with concrete implementors.
* Use mocking instead of it.
*/
DO_NOT_REPLACE,
object DoNotReplace : TypeReplacementApproach()

/**
* Try to replace interfaces and abstract classes with concrete implementors
Expand All @@ -751,7 +751,7 @@ enum class TypeReplacementApproach {
*
* Currently used in Spring applications only.
*/
REPLACE_IF_POSSIBLE,
class ReplaceIfPossible(val configFqn: String) : TypeReplacementApproach()
}

abstract class DependencyInjectionFramework(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ object UtTestsDialogProcessor {
val applicationContext = when (model.projectType) {
Spring -> {
val shouldUseImplementors = when (model.typeReplacementApproach) {
TypeReplacementApproach.DO_NOT_REPLACE -> false
TypeReplacementApproach.REPLACE_IF_POSSIBLE -> true
TypeReplacementApproach.DoNotReplace -> false
is TypeReplacementApproach.ReplaceIfPossible -> true
}

SpringApplicationContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m

model.typeReplacementApproach =
when (springConfig.item) {
NO_SPRING_CONFIGURATION_OPTION -> TypeReplacementApproach.DO_NOT_REPLACE
else -> TypeReplacementApproach.REPLACE_IF_POSSIBLE
NO_SPRING_CONFIGURATION_OPTION -> TypeReplacementApproach.DoNotReplace
else -> TypeReplacementApproach.ReplaceIfPossible(springConfig.item)
}

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