Skip to content

Commit

Permalink
Addressing feedback
Browse files Browse the repository at this point in the history
- Use ObjectMapper in the tests
- Fix domains JsonProperty
  • Loading branch information
alex-yau-ttd committed Nov 8, 2023
1 parent 0308700 commit 96f80b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/uid2/shared/model/Site.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Site(@JsonProperty("id") int id,
@JsonProperty("description") String description,
@JsonProperty("enabled") Boolean enabled,
@JsonProperty("clientTypes") Set<ClientType> types,
@JsonProperty("domains") Set<String> domains,
@JsonProperty("domain_names") Set<String> domains,
@JsonProperty("visible") Boolean visible,
@JsonProperty("created") long created) {
this.id = id;
Expand Down
22 changes: 7 additions & 15 deletions src/test/java/com/uid2/shared/store/RotatingSiteStoreTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.uid2.shared.store;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.uid2.shared.cloud.ICloudStorage;
import com.uid2.shared.model.Site;
import com.uid2.shared.store.reader.RotatingSiteStore;
import com.uid2.shared.store.scope.GlobalScope;
import com.uid2.shared.util.Mapper;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import org.junit.jupiter.api.AfterEach;
Expand All @@ -12,6 +15,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.io.IOException;
import java.time.Instant;
import java.util.HashSet;
import java.util.List;
Expand All @@ -22,6 +26,7 @@
import static org.mockito.Mockito.when;

public class RotatingSiteStoreTest {
private static final ObjectMapper OBJECT_MAPPER = Mapper.getInstance();
private AutoCloseable mocks;
@Mock
ICloudStorage cloudStorage;
Expand Down Expand Up @@ -49,22 +54,9 @@ private JsonObject makeMetadata(String location) {
private Site addSite(JsonArray content, int siteId, String name, String description, boolean enabled, boolean visible, long created, String... domains) {

Site s = new Site(siteId, name, description, enabled, new HashSet<>(), new HashSet<>(List.of(domains)), visible, created);
JsonNode jsonNode = OBJECT_MAPPER.convertValue(s, JsonNode.class);
content.add(jsonNode);

JsonArray ja = new JsonArray();
for (String domain : domains) {
ja.add(domain);
}

JsonObject site = new JsonObject();
site.put("id", siteId);
site.put("name", name);
site.put("description", description);
site.put("enabled", enabled);
site.put("domain_names", ja);
site.put("visible", visible);
site.put("created", created);

content.add(site);
return s;
}

Expand Down

0 comments on commit 96f80b9

Please sign in to comment.