11package suite .optout ;
22
33import app .component .Operator ;
4+ import app .component .Optout ;
45import com .fasterxml .jackson .databind .JsonNode ;
56import com .fasterxml .jackson .databind .ObjectMapper ;
67import com .uid2 .client .IdentityTokens ;
910import org .junit .jupiter .params .ParameterizedTest ;
1011import org .junit .jupiter .params .provider .Arguments ;
1112import org .junit .jupiter .params .provider .MethodSource ;
13+ import org .slf4j .Logger ;
14+ import org .slf4j .LoggerFactory ;
1215
1316import java .time .Instant ;
1417import java .util .HashSet ;
2326@ SuppressWarnings ("unused" )
2427@ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
2528public class OptoutTest {
26- // TODO: Test failure case
29+ private static final Logger LOGGER = LoggerFactory . getLogger ( OptoutTest . class );
2730
2831 private static final ObjectMapper OBJECT_MAPPER = Mapper .getInstance ();
2932 private static final int OPTOUT_DELAY_MS = 1000 ;
3033 private static final int OPTOUT_WAIT_SECONDS = 300 ;
34+ private static final int DELTA_PRODUCE_WAIT_SECONDS = 120 ;
3135
3236 private static Set <Arguments > outputArgs ;
3337 private static Set <Arguments > outputAdvertisingIdArgs ;
38+ private static Optout optoutService ;
3439
3540 @ BeforeAll
3641 public static void setupAll () {
3742 outputArgs = new HashSet <>();
3843 outputAdvertisingIdArgs = new HashSet <>();
44+ // Initialize optout service component for delta production
45+ optoutService = new Optout ("optout" , 8081 , "Optout Service" );
3946 }
4047
4148 @ ParameterizedTest (name = "/v2/token/logout with /v2/token/generate - {0} - {2}" )
@@ -78,7 +85,30 @@ public void testV2LogoutWithV2IdentityMap(String label, Operator operator, Strin
7885 outputAdvertisingIdArgs .add (Arguments .of (label , operator , operatorName , rawUID , toOptOut , beforeOptOutTimestamp ));
7986 }
8087
88+ /**
89+ * Triggers delta production on the optout service after all logout requests.
90+ * This reads the opt-out requests from SQS and produces delta files that
91+ * the operator will sync to reflect the opt-outs.
92+ */
93+ @ Test
8194 @ Order (4 )
95+ public void triggerDeltaProduction () throws Exception {
96+ LOGGER .info ("Triggering delta production on optout service" );
97+
98+ // Trigger delta production
99+ JsonNode response = optoutService .triggerDeltaProduce ();
100+ LOGGER .info ("Delta production triggered: {}" , response );
101+
102+ // Wait for completion
103+ boolean success = optoutService .triggerDeltaProduceAndWait (DELTA_PRODUCE_WAIT_SECONDS );
104+ assertThat (success ).as ("Delta production should complete successfully" ).isTrue ();
105+
106+ // Get final status
107+ JsonNode status = optoutService .getDeltaProduceStatus ();
108+ LOGGER .info ("Delta production completed: {}" , status );
109+ }
110+
111+ @ Order (5 )
82112 @ ParameterizedTest (name = "/v2/token/refresh after {2} generate and {3} logout - {0} - {1}" )
83113 @ MethodSource ({
84114 "afterOptoutTokenArgs"
@@ -89,7 +119,7 @@ public void testV2TokenRefreshAfterOptOut(String label, Operator operator, Strin
89119 with ().pollInterval (5 , TimeUnit .SECONDS ).await ("Get V2 Token Response" ).atMost (OPTOUT_WAIT_SECONDS , TimeUnit .SECONDS ).until (() -> operator .v2TokenRefresh (refreshToken , refreshResponseKey ).equals (OBJECT_MAPPER .readTree ("{\" status\" :\" optout\" }" )));
90120 }
91121
92- @ Order (5 )
122+ @ Order (6 )
93123 @ ParameterizedTest (name = "/v2/optout/status after v2/identity/map and v2/token/logout - DII {0} - expecting {4} - {2}" )
94124 @ MethodSource ({"afterOptoutAdvertisingIdArgs" })
95125 public void testV2OptOutStatus (String label , Operator operator , String operatorName , String rawUID ,
0 commit comments