@@ -167,7 +167,13 @@ func (suite *DoScreeningWorkerTestSuite) TestWork_ObjectUpdated_ScreeningResultU
167167 suite .usecase .On ("DoScreening" , suite .ctx , mock .Anything , ingestedObject , mapping , config ,
168168 "transactions" , "test-object-id" ).Return (screeningWithMatches , nil )
169169 suite .repository .On ("GetContinuousScreeningByObjectId" , suite .ctx , mock .Anything ,
170- suite .objectId , suite .objectType , suite .orgId ).Return (& existingContinuousScreening , nil )
170+ suite .objectId , suite .objectType , suite .orgId , mock .MatchedBy (func (status * models.ScreeningStatus ) bool {
171+ return status == nil
172+ }), false ).Return (& existingContinuousScreening , nil )
173+ suite .repository .On ("GetContinuousScreeningByObjectId" , suite .ctx , mock .Anything ,
174+ suite .objectId , suite .objectType , suite .orgId , mock .MatchedBy (func (status * models.ScreeningStatus ) bool {
175+ return status != nil && * status == models .ScreeningStatusInReview
176+ }), true ).Return (& existingContinuousScreening , nil )
171177 suite .repository .On ("InsertContinuousScreening" , suite .ctx , mock .Anything ,
172178 screeningWithMatches , config , suite .objectType , suite .objectId , ingestedObjectInternalId ,
173179 models .ContinuousScreeningTriggerTypeObjectUpdated ).Return (continuousScreeningWithMatches , nil )
@@ -281,7 +287,13 @@ func (suite *DoScreeningWorkerTestSuite) TestWork_ObjectUpdated_ScreeningResultC
281287 suite .usecase .On ("DoScreening" , suite .ctx , mock .Anything , ingestedObject , mapping , config ,
282288 "transactions" , "test-object-id" ).Return (screeningWithMatches , nil )
283289 suite .repository .On ("GetContinuousScreeningByObjectId" , suite .ctx , mock .Anything ,
284- suite .objectId , suite .objectType , suite .orgId ).Return (& existingContinuousScreening , nil )
290+ suite .objectId , suite .objectType , suite .orgId , mock .MatchedBy (func (status * models.ScreeningStatus ) bool {
291+ return status == nil
292+ }), false ).Return (& existingContinuousScreening , nil )
293+ suite .repository .On ("GetContinuousScreeningByObjectId" , suite .ctx , mock .Anything ,
294+ suite .objectId , suite .objectType , suite .orgId , mock .MatchedBy (func (status * models.ScreeningStatus ) bool {
295+ return status != nil && * status == models .ScreeningStatusInReview
296+ }), true ).Return ((* models .ContinuousScreeningWithMatches )(nil ), nil )
285297 suite .repository .On ("InsertContinuousScreening" , suite .ctx , mock .Anything ,
286298 screeningWithMatches , config , suite .objectType , suite .objectId , ingestedObjectInternalId ,
287299 models .ContinuousScreeningTriggerTypeObjectUpdated ).Return (continuousScreeningWithMatches , nil )
@@ -369,7 +381,9 @@ func (suite *DoScreeningWorkerTestSuite) TestWork_IngestedObjectBeforeLatestScre
369381 ingestedObject , ingestedObjectInternalId , nil )
370382 // Existing screening is more recent than ingested object
371383 suite .repository .On ("GetContinuousScreeningByObjectId" , suite .ctx , mock .Anything ,
372- suite .objectId , suite .objectType , suite .orgId ).Return (& existingContinuousScreening , nil )
384+ suite .objectId , suite .objectType , suite .orgId , mock .MatchedBy (func (status * models.ScreeningStatus ) bool {
385+ return status == nil
386+ }), false ).Return (& existingContinuousScreening , nil )
373387
374388 // Execute
375389 worker := suite .makeWorker ()
@@ -381,6 +395,8 @@ func (suite *DoScreeningWorkerTestSuite) TestWork_IngestedObjectBeforeLatestScre
381395 suite .usecase .AssertNotCalled (suite .T (), "DoScreening" )
382396 // Verify that InsertContinuousScreening is NOT called
383397 suite .repository .AssertNotCalled (suite .T (), "InsertContinuousScreening" )
398+ // Verify that GetContinuousScreeningByObjectId is NOT called a second time (with ScreeningStatusInReview filter)
399+ suite .usecase .AssertNotCalled (suite .T (), "HandleCaseCreation" )
384400 suite .AssertExpectations ()
385401}
386402
@@ -468,7 +484,9 @@ func (suite *DoScreeningWorkerTestSuite) TestWork_ObjectAdded_CallCaseCreation()
468484 ingestedObject , ingestedObjectInternalId , nil )
469485 // For ObjectAdded trigger, there should be no existing screening
470486 suite .repository .On ("GetContinuousScreeningByObjectId" , suite .ctx , mock .Anything ,
471- suite .objectId , suite .objectType , suite .orgId ).Return (
487+ suite .objectId , suite .objectType , suite .orgId , mock .MatchedBy (func (status * models.ScreeningStatus ) bool {
488+ return status == nil
489+ }), false ).Return (
472490 (* models .ContinuousScreeningWithMatches )(nil ), nil )
473491 suite .usecase .On ("DoScreening" , suite .ctx , mock .Anything , ingestedObject , mapping , config ,
474492 "transactions" , "test-object-id" ).Return (screeningWithMatches , nil )
@@ -484,7 +502,8 @@ func (suite *DoScreeningWorkerTestSuite) TestWork_ObjectAdded_CallCaseCreation()
484502
485503 // Assert
486504 suite .NoError (err )
487- suite .AssertExpectations ()
505+ // For ObjectAdded trigger, the second GetContinuousScreeningByObjectId call is NOT made
506+ suite .usecase .AssertExpectations (suite .T ())
488507}
489508
490509// Tests for CheckIfObjectsNeedScreeningWorker
0 commit comments