@@ -108,26 +108,32 @@ class UTestInstToUtModelConverter(
108108            is  UTestSetFieldStatement  ->  {
109109                val  instanceExpr =  uTestInst.instance
110110
111-                 val  instanceModel =  processExpr(instanceExpr)
112-                 require(instanceModel is  UtAssembleModel )
113- 
114-                 val  fieldType =  uTestInst.field.enclosingClass.classId
115-                 val  fieldName =  uTestInst.field.name
116-                 val  setValueModel =  processExpr(uTestInst.value)
117- 
118-                 val  methodCall =  UtExecutableCallModel (
119-                     instance =  null ,
120-                     executable =  utilMethodProvider.setFieldMethodId,
121-                     params =  listOf (
122-                         instanceModel,
123-                         UtPrimitiveModel (fieldType.name),
124-                         UtPrimitiveModel (fieldName),
125-                         setValueModel,
126-                     ),
127-                 )
128- 
129-                 instanceModel?.let  {
130-                     (it.modificationsChain as  MutableList ).add(methodCall)
111+                 when  (val  instanceModel =  processExpr(instanceExpr)) {
112+                     is  UtAssembleModel  ->  {
113+                         val  fieldType =  uTestInst.field.enclosingClass.classId
114+                         val  fieldName =  uTestInst.field.name
115+                         val  setValueModel =  processExpr(uTestInst.value)
116+ 
117+                         val  methodCall =  UtExecutableCallModel (
118+                             instance =  null ,
119+                             executable =  utilMethodProvider.setFieldMethodId,
120+                             params =  listOf (
121+                                 instanceModel,
122+                                 UtPrimitiveModel (fieldType.name),
123+                                 UtPrimitiveModel (fieldName),
124+                                 setValueModel,
125+                             ),
126+                         )
127+ 
128+                         (instanceModel.modificationsChain as  MutableList ).add(methodCall)
129+                     }
130+                     is  UtCompositeModel  ->  {
131+                         instanceModel.fields[uTestInst.field.fieldId] =  processExpr(uTestInst.value)
132+                     }
133+                     else  ->  logger.warn {
134+                         " Field ${uTestInst.field}  can't be set for a model of type ${instanceModel::class } , " + 
135+                                 " when generating tests for ${uTest.callMethodExpression.method} " 
136+                     }
131137                }
132138            }
133139
0 commit comments