Skip to content

Commit 37638f0

Browse files
committed
Using human readable dates
1 parent 0c1a13f commit 37638f0

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
package com.uid2.admin.model;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.google.type.DateTime;
45
import com.uid2.shared.model.CloudEncryptionKey;
56

7+
import java.time.Instant;
8+
69
public record CloudEncryptionKeySummary(
7-
@JsonProperty int id,
8-
@JsonProperty int siteId,
9-
@JsonProperty long activates,
10-
@JsonProperty long created
10+
@JsonProperty int id,
11+
@JsonProperty int siteId,
12+
@JsonProperty String activates,
13+
@JsonProperty String created
1114
) {
1215
public static CloudEncryptionKeySummary fromFullKey(CloudEncryptionKey key) {
13-
return new CloudEncryptionKeySummary(key.getId(), key.getSiteId(), key.getActivates(), key.getCreated());
16+
return new CloudEncryptionKeySummary(
17+
key.getId(),
18+
key.getSiteId(),
19+
toIsoTimestamp(key.getActivates()),
20+
toIsoTimestamp(key.getCreated())
21+
);
22+
}
23+
24+
private static String toIsoTimestamp(Long epochSeconds) {
25+
return Instant.ofEpochSecond(epochSeconds).toString();
1426
}
1527
}

src/test/java/com/uid2/admin/vertx/CloudEncryptionKeyServiceTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,19 @@ public void testList_noAccess(Vertx vertx, VertxTestContext testContext) {
5353
public void testList_withKeys(Vertx vertx, VertxTestContext testContext) {
5454
fakeAuth(Role.MAINTAINER);
5555

56-
CloudEncryptionKey key1 = new CloudEncryptionKey(1, 2, 100, 100, "secret 1");
57-
CloudEncryptionKey key2 = new CloudEncryptionKey(2, 2, 200, 100, "secret 2");
56+
var date1EpochSeconds = 100;
57+
var date2EpochSeconds = 200;
58+
var date1Iso = "1970-01-01T00:01:40Z";
59+
var date2Iso = "1970-01-01T00:03:20Z";
60+
61+
CloudEncryptionKey key1 = new CloudEncryptionKey(1, 2, date1EpochSeconds, date1EpochSeconds, "secret 1");
62+
CloudEncryptionKey key2 = new CloudEncryptionKey(2, 2, date2EpochSeconds, date1EpochSeconds, "secret 2");
5863

5964
setCloudEncryptionKeys(key1, key2);
6065

6166
var expected = new CloudEncryptionKeyListResponse(List.of(
62-
new CloudEncryptionKeySummary(1, 2, 100, 100),
63-
new CloudEncryptionKeySummary(2, 2, 200, 100)
67+
new CloudEncryptionKeySummary(1, 2, date1Iso, date1Iso),
68+
new CloudEncryptionKeySummary(2, 2, date2Iso, date1Iso)
6469
));
6570

6671
get(vertx, testContext, Endpoints.CLOUD_ENCRYPTION_KEY_LIST, response -> {

0 commit comments

Comments
 (0)