@@ -545,7 +545,7 @@ public void testPublisherAdvancedTokenRefreshResponse() {
545
545
546
546
@ Test
547
547
public void testImportStatements () {
548
- // Documentation sdk-ref-java.md Line 419-422 : Import statements verification for migration guide
548
+ // Documentation sdk-ref-java.md Line 437-442 : Import statements verification for migration guide
549
549
// Verify that all documented import classes are accessible and can be instantiated
550
550
551
551
// import com.uid2.client.IdentityMapV3Client;
@@ -584,19 +584,80 @@ public void testImportStatements() {
584
584
assertTrue (hasUnknown );
585
585
}
586
586
587
+ @ Test
588
+ public void testRecommendedChangesExamples () {
589
+ // Documentation sdk-ref-java.md Line 446-488: Recommended changes examples for v3 optional features
590
+
591
+ // Documentation sdk-ref-java.md Line 449-460: 1. Mix identity types in a single request
592
+ // Before - single identity type only
593
+ IdentityMapInput inputV2 =
IdentityMapInput .
fromEmails (
Arrays .
asList (
"[email protected] " ));
594
+
595
+ // After - can mix identity types (new v3 capability)
596
+ IdentityMapV3Input mixedInput = new IdentityMapV3Input ()
597
+
598
+ .withPhone ("+12345678901" )
599
+ .withHashedEmail ("preHashedEmail" )
600
+ .withHashedPhone ("preHashedPhone" );
601
+
602
+ IdentityMapV3Response mixedResponse = identityMapV3Client .generateIdentityMap (mixedInput );
603
+ assertNotNull (mixedResponse );
604
+
605
+ // Documentation sdk-ref-java.md Line 463-475: 2. Access previous UID2s
606
+ // Before - only current UID2 available
607
+ IdentityMapClient clientV2 = new IdentityMapClient (UID2_BASE_URL , UID2_API_KEY , UID2_SECRET_KEY );
608
+ IdentityMapResponse responseV2 = clientV2 .generateIdentityMap (inputV2 );
609
+ IdentityMapResponse .
MappedIdentity mappedV2 =
responseV2 .
getMappedIdentities ().
get (
"[email protected] " );
610
+ if (mappedV2 != null ) {
611
+ String uid = mappedV2 .getRawUid ();
612
+ assertNotNull (uid );
613
+ }
614
+
615
+ // After - access to both current and previous UID2s
616
+ IdentityMapV3Response responseV3 =
identityMapV3Client .
generateIdentityMap (
IdentityMapV3Input .
fromEmails (
Arrays .
asList (
"[email protected] " )));
617
+ IdentityMapV3Response .
MappedIdentity mappedV3 =
responseV3 .
getMappedIdentities ().
get (
"[email protected] " );
618
+ if (mappedV3 != null ) {
619
+ String currentUid = mappedV3 .getCurrentRawUid ();
620
+ String previousUid = mappedV3 .getPreviousRawUid (); // Available for 90 days after rotation
621
+ Instant refreshFrom = mappedV3 .getRefreshFrom ();
622
+
623
+ assertNotNull (currentUid );
624
+ assertNotNull (refreshFrom );
625
+ // previousUid may be null if no rotation occurred
626
+ }
627
+
628
+ // Documentation sdk-ref-java.md Line 478-488: 3. Use structured error reasons
629
+ // Before - string-based error reasons
630
+ IdentityMapResponse .
UnmappedIdentity unmappedV2 =
responseV2 .
getUnmappedIdentities ().
get (
"[email protected] " );
631
+ if (unmappedV2 != null ) {
632
+ String reason = unmappedV2 .getReason ();
633
+ assertNotNull (reason );
634
+ }
635
+
636
+ // After - structured enum-based error reasons
637
+ IdentityMapV3Response .
UnmappedIdentity unmappedV3 =
responseV3 .
getUnmappedIdentities ().
get (
"[email protected] " );
638
+ if (unmappedV3 != null ) {
639
+ UnmappedIdentityReason reason = unmappedV3 .getReason (); // Enum: OPTOUT, INVALID_IDENTIFIER, UNKNOWN
640
+ assertNotNull (reason );
641
+
642
+ // Or continue using string reasons if preferred
643
+ String rawReason = unmappedV3 .getRawReason ();
644
+ assertNotNull (rawReason );
645
+ }
646
+ }
647
+
587
648
// ========================================
588
649
// DSP USAGE TESTS
589
650
// ========================================
590
651
591
652
@ Test
592
653
public void testDspUsageExample () {
593
- // Documentation sdk-ref-java.md Line 514 : DSP Usage - BidstreamClient creation
654
+ // Documentation sdk-ref-java.md Line 528 : DSP Usage - BidstreamClient creation
594
655
BidstreamClient client = new BidstreamClient (UID2_BASE_URL , UID2_API_KEY , UID2_SECRET_KEY );
595
656
596
- // Documentation sdk-ref-java.md Line 520 : Refresh at startup and periodically
657
+ // Documentation sdk-ref-java.md Line 534 : Refresh at startup and periodically
597
658
client .refresh ();
598
659
599
- // Documentation sdk-ref-java.md Line 529 : Decrypt token into raw UID2 with domain/app name
660
+ // Documentation sdk-ref-java.md Line 543 : Decrypt token into raw UID2 with domain/app name
600
661
String mockUidToken = "mock-uid-token" ; // In real usage, this would be from bid request
601
662
String domainOrAppName = "example.com" ; // or app name, or null
602
663
@@ -624,13 +685,13 @@ public void testDspUsageExample() {
624
685
625
686
@ Test
626
687
public void testSharingClientUsageExample () {
627
- // Documentation sdk-ref-java.md Line 557 : UID2 Sharers Usage - SharingClient creation
688
+ // Documentation sdk-ref-java.md Line 571 : UID2 Sharers Usage - SharingClient creation
628
689
SharingClient client = new SharingClient (UID2_BASE_URL , UID2_API_KEY , UID2_SECRET_KEY );
629
690
630
- // Documentation sdk-ref-java.md Line 562 : Refresh at startup and periodically
691
+ // Documentation sdk-ref-java.md Line 576 : Refresh at startup and periodically
631
692
client .refresh ();
632
693
633
- // Documentation sdk-ref-java.md Line 567 : Encrypt raw UID as sender
694
+ // Documentation sdk-ref-java.md Line 581 : Encrypt raw UID as sender
634
695
String mockRawUid = "mock-raw-uid" ; // In real usage, this would be actual raw UID2
635
696
636
697
try {
@@ -650,7 +711,7 @@ public void testSharingClientUsageExample() {
650
711
assertTrue (true );
651
712
}
652
713
653
- // Documentation sdk-ref-java.md Line 581 : Decrypt token as receiver
714
+ // Documentation sdk-ref-java.md Line 595 : Decrypt token as receiver
654
715
String mockUidToken = "mock-uid-token" ; // In real usage, this would be from sender
655
716
656
717
try {
@@ -677,23 +738,23 @@ public void testSharingClientUsageExample() {
677
738
678
739
@ Test
679
740
public void testV2LegacyUsageExample () {
680
- // Documentation sdk-ref-java.md Line 480 : V2 Implementation - Legacy IdentityMapClient creation
741
+ // Documentation sdk-ref-java.md Line 494 : V2 Implementation - Legacy IdentityMapClient creation
681
742
IdentityMapClient identityMapClient = new IdentityMapClient (UID2_BASE_URL , UID2_API_KEY , UID2_SECRET_KEY );
682
743
683
- // Documentation sdk-ref-java.md Line 485 : V2 Input construction (single identity type only)
744
+ // Documentation sdk-ref-java.md Line 499 : V2 Input construction (single identity type only)
684
745
IdentityMapInput input =
IdentityMapInput .
fromEmails (
Arrays .
asList (
"[email protected] " ));
685
746
686
- // Documentation sdk-ref-java.md Line 485 : V2 API call
747
+ // Documentation sdk-ref-java.md Line 499 : V2 API call
687
748
IdentityMapResponse identityMapResponse = identityMapClient .generateIdentityMap (input );
688
749
689
- // Documentation sdk-ref-java.md Line 492-493 : V2 Response handling with proper types
750
+ // Documentation sdk-ref-java.md Line 506-507 : V2 Response handling with proper types
690
751
HashMap <String , IdentityMapResponse .MappedIdentity > mappedIdentities = identityMapResponse .getMappedIdentities ();
691
752
HashMap <String , IdentityMapResponse .UnmappedIdentity > unmappedIdentities = identityMapResponse .getUnmappedIdentities ();
692
753
693
754
assertNotNull (mappedIdentities );
694
755
assertNotNull (unmappedIdentities );
695
756
696
- // Documentation sdk-ref-java.md Line 498-501 : V2 Result processing with bucket ID
757
+ // Documentation sdk-ref-java.md Line 512-515 : V2 Result processing with bucket ID
697
758
IdentityMapResponse .
MappedIdentity mappedIdentity =
mappedIdentities .
get (
"[email protected] " );
698
759
if (mappedIdentity != null ) {
699
760
String rawUID = mappedIdentity .getRawUid ();
@@ -706,9 +767,9 @@ public void testV2LegacyUsageExample() {
706
767
707
768
@ Test
708
769
public void testV2ToV3MigrationExamples () {
709
- // Documentation sdk-ref-java.md Line 410-415 : Basic email mapping migration example
770
+ // Documentation sdk-ref-java.md Line 427-432 : Basic client class migration example
710
771
711
- // Documentation sdk-ref-java.md Line 411 : V2 approach (before migration)
772
+ // Documentation sdk-ref-java.md Line 430 : V2 approach (before migration)
712
773
IdentityMapClient clientV2 = new IdentityMapClient (UID2_BASE_URL , UID2_API_KEY , UID2_SECRET_KEY );
713
774
IdentityMapInput inputV2 =
IdentityMapInput .
fromEmails (
Arrays .
asList (
"[email protected] " ));
714
775
IdentityMapResponse responseV2 = clientV2 .generateIdentityMap (inputV2 );
@@ -717,7 +778,7 @@ public void testV2ToV3MigrationExamples() {
717
778
uidV2 = responseV2 .getMappedIdentities ().values ().iterator ().next ().getRawUid ();
718
779
}
719
780
720
- // Documentation sdk-ref-java.md Line 414 : V3 approach (after migration)
781
+ // Documentation sdk-ref-java.md Line 433 : V3 approach (after migration)
721
782
IdentityMapV3Client clientV3 = new IdentityMapV3Client (UID2_BASE_URL , UID2_API_KEY , UID2_SECRET_KEY );
722
783
IdentityMapV3Input inputV3 =
IdentityMapV3Input .
fromEmails (
Arrays .
asList (
"[email protected] " ));
723
784
IdentityMapV3Response responseV3 = clientV3 .generateIdentityMap (inputV3 );
@@ -730,7 +791,7 @@ public void testV2ToV3MigrationExamples() {
730
791
assertNotNull (responseV2 );
731
792
assertNotNull (responseV3 );
732
793
733
- // Documentation sdk-ref-java.md Line 517-527: Enhanced response processing with UID rotation support
794
+ // Enhanced response processing with UID rotation support from recommended changes section
734
795
IdentityMapV3Response .
MappedIdentity mapped =
responseV3 .
getMappedIdentities ().
get (
"[email protected] " );
735
796
if (mapped != null ) {
736
797
String currentUid = mapped .getCurrentRawUid ();
@@ -740,14 +801,14 @@ public void testV2ToV3MigrationExamples() {
740
801
assertNotNull (currentUid );
741
802
assertNotNull (refreshFrom );
742
803
743
- // Documentation sdk-ref-java.md Line 524-526: Check if refresh is needed
804
+ // Check if refresh is needed
744
805
if (Instant .now ().isAfter (refreshFrom )) {
745
806
// Refresh this identity
746
807
assertTrue (true ); // Placeholder for refresh logic
747
808
}
748
809
}
749
810
750
- // Documentation sdk-ref-java.md Line 535-549: Error handling migration with structured switch statement
811
+ // Error handling migration with structured switch statement from recommended changes section
751
812
IdentityMapV3Response .
UnmappedIdentity unmapped =
responseV3 .
getUnmappedIdentities ().
get (
"[email protected] " );
752
813
if (unmapped != null ) {
753
814
switch (unmapped .getReason ()) {
0 commit comments