1313import java .time .Duration ;
1414import java .time .Instant ;
1515import java .util .List ;
16- import java .util .Objects ;
1716
1817import static org .assertj .core .api .Assertions .assertThat ;
1918import static org .junit .jupiter .api .Assertions .*;
@@ -99,62 +98,75 @@ public void testV2TokenValidate(String label, Operator operator, String operator
9998
10099 @ ParameterizedTest (name = "/v2/identity/map - {0} - {2}" )
101100 @ MethodSource ({
102- "suite.operator.TestData#identityMapBatchEmailArgs" ,
103- "suite.operator.TestData#identityMapBatchPhoneArgs" ,
104101 "suite.operator.TestData#identityMapBatchBadEmailArgs" ,
105102 "suite.operator.TestData#identityMapBatchBadPhoneArgs"
106103 })
107- public void testV2IdentityMap (String label , Operator operator , String operatorName , String payload ) throws Exception {
104+ public void testV2IdentityMapUnmapped (String label , Operator operator , String operatorName , String payload ) throws Exception {
108105 JsonNode response = operator .v2IdentityMap (payload );
109106
110- // TODO: Assert the value
111107 assertThat (response .at ("/status" ).asText ()).isEqualTo ("success" );
108+ assertThat (response .at ("/body/unmapped/0/reason" ).asText ()).isEqualTo ("invalid identifier" );
112109 }
113110
114111 @ ParameterizedTest (name = "/v2/identity/map - {0} - {2}" )
115112 @ MethodSource ({
116- "suite.operator.TestData#identityMapBigBatchArgs"
113+ "suite.operator.TestData#identityMapBatchEmailArgs" ,
114+ "suite.operator.TestData#identityMapBatchPhoneArgs" ,
117115 })
118- public void testV2IdentityMapLargeBatch (String label , Operator operator , String operatorName , String payload , List <String > diis ) {
116+ public void testV2IdentityMapMapped (String label , Operator operator , String operatorName , String payload ) throws Exception {
117+ JsonNode response = operator .v2IdentityMap (payload );
118+
119+ // TODO: Assert the value
120+ assertThat (response .at ("/status" ).asText ()).isEqualTo ("success" );
121+ }
122+
123+ @ ParameterizedTest (name = "/v2/identity/map - {0} - {2}" )
124+ @ MethodSource ({"suite.operator.TestData#identityMapArgs" })
125+ public void testV2IdentityMap (
126+ String label ,
127+ Operator operator ,
128+ String operatorName ,
129+ IdentityMapInput input ,
130+ List <String > diis
131+ ) {
119132 assertTimeoutPreemptively (Duration .ofSeconds (5 ), () -> { // Validate we didn't make mapping too slow.
120- JsonNode response = operator .v2IdentityMap (payload );
133+ var response = operator .v2IdentityMap (input );
121134
122- assertThat (response .at ( "/status" ). asText ()). isEqualTo ( "success" );
135+ assertThat (response .isSuccess ()). isTrue ( );
123136
124- var mapped = response .at ("/body/mapped" );
125- assertThat (mapped .size ()).isEqualTo (10_000 );
137+ assertThat (response .getUnmappedIdentities ()).isEmpty ();
126138
127- for (int i = 0 ; i < 10_000 ; i ++) {
128- assertThat (mapped .get (i ).get ("identifier" ).asText ()).isEqualTo (diis .get (i ));
129- assertThat (mapped .get (i ).get ("advertising_id" ).asText ()).isNotNull ().isNotEmpty ();
130- assertThat (mapped .get (i ).get ("bucket_id" ).asText ()).isNotNull ().isNotEmpty ();
139+ var allMappedDiis = response .getMappedIdentities ();
140+ assertThat (allMappedDiis .size ()).isEqualTo (10_000 );
141+
142+ for (var dii : diis ) {
143+ var mappedDii = allMappedDiis .get (dii );
144+ assertThat (mappedDii ).isNotNull ();
145+ assertThat (mappedDii .getRawUid ().length ()).isEqualTo (RAW_UID_SIZE );
146+ assertThat (mappedDii .getBucketId ()).isNotBlank ();
131147 }
132148 });
133149 }
134150
135151 @ ParameterizedTest (name = "/v3/identity/map - {0} - {2}" )
136- @ MethodSource ({
137- "suite.operator.TestData#identityMapV3BigBatchArgs"
138- })
152+ @ MethodSource ({"suite.operator.TestData#identityMapV3Args" })
139153 public void testV3IdentityMapLargeBatch (
140154 String label ,
141155 Operator operator ,
142156 String operatorName ,
143- List <String > emails ,
144- List <String > phones ,
145- List <String > emailHashes ,
146- List <String > phoneHashes ,
157+ IdentityMapV3Input input ,
147158 List <String > diis
148159 ) {
149160 assertTimeoutPreemptively (Duration .ofSeconds (5 ), () -> { // Validate we didn't make mapping too slow.
150- var response = operator .v3IdentityMap (emails , phones , emailHashes , phoneHashes );
161+ var response = operator .v3IdentityMap (input );
151162
152163 assertThat (response .isSuccess ()).isTrue ();
153164
165+ assertThat (response .getUnmappedIdentities ()).isEmpty ();
166+
154167 var allMappedDiis = response .getMappedIdentities ();
155168 assertThat (allMappedDiis .size ()).isEqualTo (10_000 );
156169
157-
158170 for (var dii : diis ) {
159171 var mappedDii = allMappedDiis .get (dii );
160172 assertThat (mappedDii ).isNotNull ();
@@ -176,6 +188,18 @@ public void testV3IdentityMapLargeBatch(
176188 });
177189 }
178190
191+ @ ParameterizedTest (name = "/v3/identity/map - {0} - {2}" )
192+ @ MethodSource ({
193+ "suite.operator.TestData#identityMapV3BatchBadEmailArgs" ,
194+ "suite.operator.TestData#identityMapV3BatchBadPhoneArgs"
195+ })
196+ public void testV3IdentityMapUnmapped (String label , Operator operator , String operatorName , String payload , String section ) throws Exception {
197+ JsonNode response = operator .v3IdentityMap (payload );
198+
199+ assertThat (response .at ("/status" ).asText ()).isEqualTo ("success" );
200+ assertThat (response .at ("/body/" + section + "/0/e" ).asText ()).isEqualTo ("invalid identifier" );
201+ }
202+
179203
180204 @ ParameterizedTest (name = "/v2/identity/map - VALIDATE EMAIL - {0} - {2}" )
181205 @ MethodSource ({
0 commit comments