Skip to content

Commit 18cfc01

Browse files
committed
Addressing feedback
1 parent c3ef65d commit 18cfc01

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/main/java/com/uid2/client/IdentityMapV3Response.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.Gson;
44
import com.google.gson.annotations.SerializedName;
55

6+
import java.time.Instant;
67
import java.util.HashMap;
78
import java.util.List;
89
import java.util.Map;
@@ -70,30 +71,30 @@ static public class ApiIdentity {
7071
}
7172

7273
static public class MappedIdentity {
73-
public MappedIdentity(String currentUid, String previousUid, Long refreshFromSeconds) {
74+
public MappedIdentity(String currentUid, String previousUid, Instant refreshFrom) {
7475
this.currentUid = currentUid;
7576
this.previousUid = previousUid;
76-
this.refreshFromSeconds = refreshFromSeconds;
77+
this.refreshFrom = refreshFrom;
7778
}
7879

7980
public MappedIdentity(ApiIdentity apiIdentity) {
80-
this(apiIdentity.currentUid, apiIdentity.previousUid, apiIdentity.refreshFromSeconds);
81+
this(apiIdentity.currentUid, apiIdentity.previousUid, Instant.ofEpochSecond(apiIdentity.refreshFromSeconds));
8182
}
8283

8384
private final String currentUid;
8485
private final String previousUid;
85-
private final Long refreshFromSeconds;
86+
private final Instant refreshFrom;
8687

87-
public String getCurrentUid() {
88+
public String getCurrentRawUid() {
8889
return currentUid;
8990
}
9091

91-
public String getPreviousUid() {
92+
public String getPreviousRawUid() {
9293
return previousUid;
9394
}
9495

95-
public Long getRefreshFromSeconds() {
96-
return refreshFromSeconds;
96+
public Instant getRefreshFrom() {
97+
return refreshFrom;
9798
}
9899
}
99100

src/test/java/com/uid2/client/IdentityMapV3IntegrationTests.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ public void identityMapDuplicateEmails() {
111111
HashMap<String, IdentityMapV3Response.MappedIdentity> mappedIdentities = identityMapResponse.getMappedIdentities();
112112
assertEquals(4, mappedIdentities.size()); //it's not 5 because the last email is an exact match to the first email
113113

114-
String rawUid = mappedIdentities.get("[email protected]").getCurrentUid();
115-
assertEquals(rawUid, mappedIdentities.get("[email protected]").getCurrentUid());
116-
assertEquals(rawUid, mappedIdentities.get("[email protected]").getCurrentUid());
117-
assertEquals(rawUid, mappedIdentities.get("[email protected]").getCurrentUid());
114+
String rawUid = mappedIdentities.get("[email protected]").getCurrentRawUid();
115+
assertEquals(rawUid, mappedIdentities.get("[email protected]").getCurrentRawUid());
116+
assertEquals(rawUid, mappedIdentities.get("[email protected]").getCurrentRawUid());
117+
assertEquals(rawUid, mappedIdentities.get("[email protected]").getCurrentRawUid());
118118
}
119119

120120

@@ -211,8 +211,11 @@ class Response {
211211
void assertMapped(String dii) {
212212
IdentityMapV3Response.MappedIdentity mappedIdentity = identityMapResponse.getMappedIdentities().get(dii);
213213
assertNotNull(mappedIdentity);
214-
assertFalse(mappedIdentity.getCurrentUid().isEmpty());
215-
assertTrue(mappedIdentity.getRefreshFromSeconds() > Instant.now().minusSeconds(24 * 60 * 60).getEpochSecond());
214+
assertFalse(mappedIdentity.getCurrentRawUid().isEmpty());
215+
216+
// Refresh from should be now or in the future, allow some slack for time between request and this assertion
217+
Instant aMinuteAgo = Instant.now().minusSeconds(60);
218+
assertTrue(mappedIdentity.getRefreshFrom().isAfter(aMinuteAgo));
216219

217220
IdentityMapV3Response.UnmappedIdentity unmappedIdentity = identityMapResponse.getUnmappedIdentities().get(dii);
218221
assertNull(unmappedIdentity);
@@ -254,7 +257,7 @@ public void identityMapEmailsUseOwnHttp() {
254257
IdentityMapV3Response identityMapResponse = identityMapHelper.createIdentityMapResponse(responseString, envelopeV2, identityMapInput);
255258

256259
IdentityMapV3Response.MappedIdentity mappedIdentity = identityMapResponse.getMappedIdentities().get(mappedEmail);
257-
assertFalse(mappedIdentity.getCurrentUid().isEmpty());
260+
assertFalse(mappedIdentity.getCurrentRawUid().isEmpty());
258261
} catch (IOException e) {
259262
throw new Uid2Exception("error communicating with api endpoint", e);
260263
}

0 commit comments

Comments
 (0)