@@ -190,11 +190,64 @@ void shouldCorrectInvalidValuesInForcedSurveyUnit() {
190190 // WHEN
191191 DataVerifier .verifySurveyUnits (surveyUnits , variablesMap );
192192
193- // FORCED values added
193+ // THEN FORCED values added
194194 SurveyUnitModel forcedUnit = surveyUnits .get (1 );
195195 Assertions .assertEquals (DataState .FORCED , forcedUnit .getState ());
196196 Assertions .assertEquals (1 , forcedUnit .getCollectedVariables ().size ());
197197 Assertions .assertEquals ("" , forcedUnit .getCollectedVariables ().getFirst ().value ()); // Corrected values
198198 }
199199
200+ @ Test
201+ void shouldCorrectInvalidIterationOnForcedSurveyUnit () {
202+ // GIVEN
203+ // ADD invalid values
204+ surveyUnits .clear ();
205+ VariableModel collectedVariable1 = VariableModel .builder ()
206+ .varId ("var1" )
207+ .value ("123" )
208+ .scope ("loop1" )
209+ .iteration (1 )
210+ .parentId ("parent1" )
211+ .build ();
212+ VariableModel collectedVariable2 = VariableModel .builder ()
213+ .varId ("var1" )
214+ .value ("invalid" )
215+ .scope ("loop1" )
216+ .iteration (2 )
217+ .parentId ("parent1" )
218+ .build ();
219+ VariableModel collectedVariable3 = VariableModel .builder ()
220+ .varId ("var2" )
221+ .value ("false" )
222+ .scope ("loop2" )
223+ .iteration (1 )
224+ .parentId ("parent2" )
225+ .build ();
226+ VariableModel collectedVariable4 = VariableModel .builder ()
227+ .varId ("var2" )
228+ .value ("Not a boolean" )
229+ .scope ("loop2" )
230+ .iteration (2 )
231+ .parentId ("parent2" )
232+ .build ();
233+ SurveyUnitModel surveyUnit = SurveyUnitModel .builder ()
234+ .interrogationId ("UE1100000001" )
235+ .questionnaireId ("Quest1" )
236+ .campaignId ("Camp1" )
237+ .state (DataState .COLLECTED )
238+ .collectedVariables (List .of (collectedVariable1 , collectedVariable2 , collectedVariable3 , collectedVariable4 ))
239+ .externalVariables (List .of ())
240+ .build ();
241+ surveyUnits .add (surveyUnit );
242+
243+ // WHEN
244+ DataVerifier .verifySurveyUnits (surveyUnits , variablesMap );
245+
246+ // THEN FORCED values added
247+ Assertions .assertTrue (surveyUnits .size () > 1 );
248+ SurveyUnitModel forcedUnit = surveyUnits .get (1 );
249+ Assertions .assertEquals (DataState .FORCED , forcedUnit .getState ());
250+ Assertions .assertEquals (1 , forcedUnit .getCollectedVariables ().size ());
251+ Assertions .assertEquals ("" , forcedUnit .getCollectedVariables ().getFirst ().value ()); // Corrected values
252+ }
200253}
0 commit comments