Skip to content

Recursive collecting of Autowired models returned #2478

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 2 commits into from
Aug 4, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Add collecting modificationsChain fields for UtAssembleModels autow…
…ired from context
  • Loading branch information
tepa46 committed Aug 3, 2023
commit caeb7632a61670e89a196df569f0a7b6e7f65ff2
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import org.utbot.framework.plugin.api.UtNullModel
import org.utbot.framework.plugin.api.UtPrimitiveModel
import org.utbot.framework.plugin.api.UtVoidModel
import org.utbot.framework.plugin.api.isMockModel
import org.utbot.framework.plugin.api.UtStatementCallModel
import org.utbot.framework.plugin.api.UtDirectSetFieldModel
import org.utbot.framework.plugin.api.util.SpringModelUtils.isAutowiredFromContext
import org.utbot.framework.plugin.api.canBeSpied

Expand Down Expand Up @@ -131,6 +133,16 @@ class SpringTestClassModelBuilder(val context: CgContext) :
is UtAssembleModel -> {
model.instantiationCall.instance?.let { dependentModels.add(it.wrap()) }
model.instantiationCall.params.forEach { dependentModels.add(it.wrap()) }

if(model.isAutowiredFromContext()) {
model.modificationsChain.forEach { stmt ->
stmt.instance?.let { dependentModels.add(it.wrap()) }
when (stmt) {
is UtStatementCallModel -> stmt.params.forEach { dependentModels.add(it.wrap()) }
is UtDirectSetFieldModel -> dependentModels.add(stmt.fieldModel.wrap())
}
}
}
}
}

Expand Down