@@ -154,7 +154,7 @@ internal class SolutionServiceImpl(
154154 runTemplateId : String
155155 ) {
156156 val existingSolution = findSolutionById(organizationId, solutionId)
157- if (! ( existingSolution.runTemplates?.removeIf { it.id == runTemplateId } ? : true ) ) {
157+ if (existingSolution.runTemplates?.removeIf { it.id == runTemplateId } == false ) {
158158 throw CsmResourceNotFoundException (" Run Template '$runTemplateId ' *not* found" )
159159 }
160160 cosmosTemplate.upsert(" ${organizationId} _solutions" , existingSolution)
@@ -200,8 +200,7 @@ internal class SolutionServiceImpl(
200200 val existingSolution = findSolutionById(organizationId, solutionId)
201201 val runTemplates =
202202 existingSolution.runTemplates?.filter { it.id == runTemplateId }?.toMutableList()
203- ? : mutableListOf ()
204- if (runTemplates.isEmpty()) {
203+ if (runTemplates == null || runTemplates.isEmpty()) {
205204 throw CsmResourceNotFoundException (" Run Template '$runTemplateId ' *not* found" )
206205 }
207206 var hasChanged = false
@@ -263,20 +262,19 @@ internal class SolutionServiceImpl(
263262 " ${solutionId.sanitizeForAzureStorage()} /$runTemplateId /${handlerId.value} .zip" )
264263 .upload(body.inputStream, body.contentLength(), overwrite)
265264
266- val runTemplate = solution.runTemplates?.findLast { it.id == runTemplateId }
267- if (runTemplate == null ) {
268- throw CsmResourceNotFoundException (" Run Template '$runTemplateId ' *not* found" )
269- }
265+ val runTemplate =
266+ solution.runTemplates?.findLast { it.id == runTemplateId }
267+ ? : throw CsmResourceNotFoundException (" Run Template '$runTemplateId ' *not* found" )
270268 when (handlerId) {
271269 RunTemplateHandlerId .parameters_handler ->
272- runTemplate!! .parametersHandlerSource = RunTemplateStepSource .cloud
270+ runTemplate.parametersHandlerSource = RunTemplateStepSource .cloud
273271 RunTemplateHandlerId .validator ->
274- runTemplate!! .datasetValidatorSource = RunTemplateStepSource .cloud
275- RunTemplateHandlerId .prerun -> runTemplate!! .preRunSource = RunTemplateStepSource .cloud
276- RunTemplateHandlerId .engine -> runTemplate!! .runSource = RunTemplateStepSource .cloud
277- RunTemplateHandlerId .postrun -> runTemplate!! .postRunSource = RunTemplateStepSource .cloud
272+ runTemplate.datasetValidatorSource = RunTemplateStepSource .cloud
273+ RunTemplateHandlerId .prerun -> runTemplate.preRunSource = RunTemplateStepSource .cloud
274+ RunTemplateHandlerId .engine -> runTemplate.runSource = RunTemplateStepSource .cloud
275+ RunTemplateHandlerId .postrun -> runTemplate.postRunSource = RunTemplateStepSource .cloud
278276 RunTemplateHandlerId .scenariodata_transform ->
279- runTemplate!! .scenariodataTransformSource = RunTemplateStepSource .cloud
277+ runTemplate.scenariodataTransformSource = RunTemplateStepSource .cloud
280278 }.run {
281279 // This trick forces Kotlin to raise an error at compile time if the "when" statement is not
282280 // exhaustive
@@ -313,8 +311,8 @@ internal class SolutionServiceImpl(
313311 runTemplateId : String ,
314312 ): Solution {
315313 val solution = findSolutionById(organizationId, solutionId)
316- val validRunTemplateIds = solution.runTemplates?.map { it.id }?.toSet() ? : setOf ()
317- if (validRunTemplateIds.isEmpty()) {
314+ val validRunTemplateIds = solution.runTemplates?.map { it.id }?.toSet()
315+ if (validRunTemplateIds == null || validRunTemplateIds .isEmpty()) {
318316 throw IllegalArgumentException (
319317 " Solution $solutionId does not declare any run templates. " +
320318 " It is therefore not possible to upload run template handlers. " +
0 commit comments