From a12e6aa1063b568793cefe5892ae9e92af9164fe Mon Sep 17 00:00:00 2001 From: jon8787 <112368577+jon8787@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:06:20 +1100 Subject: [PATCH 1/2] fix private operator throwing for V2 endpoints --- .../com/uid2/shared/store/reader/RotatingSiteStore.java | 4 ++-- .../com/uid2/shared/store/RotatingSiteStoreTest.java | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/uid2/shared/store/reader/RotatingSiteStore.java b/src/main/java/com/uid2/shared/store/reader/RotatingSiteStore.java index 124efa2a..0c523032 100644 --- a/src/main/java/com/uid2/shared/store/reader/RotatingSiteStore.java +++ b/src/main/java/com/uid2/shared/store/reader/RotatingSiteStore.java @@ -14,7 +14,6 @@ public class RotatingSiteStore implements ISiteStore, StoreReader> { - public static final String SITES_METADATA_PATH = "sites_metadata_path"; private final ScopedStoreReader> reader; public RotatingSiteStore(DownloadCloudStorage fileStreamProvider, StoreScope scope) { @@ -36,7 +35,8 @@ public Collection getAll() { @Override public Site getSite(int siteId) { - return reader.getSnapshot().get(siteId); + final var snapshot = reader.getSnapshot(); + return snapshot != null ? snapshot.get(siteId) : null; } public JsonObject getMetadata() throws Exception { diff --git a/src/test/java/com/uid2/shared/store/RotatingSiteStoreTest.java b/src/test/java/com/uid2/shared/store/RotatingSiteStoreTest.java index 90a7b709..566abad1 100644 --- a/src/test/java/com/uid2/shared/store/RotatingSiteStoreTest.java +++ b/src/test/java/com/uid2/shared/store/RotatingSiteStoreTest.java @@ -17,8 +17,7 @@ import java.util.List; import static com.uid2.shared.TestUtilites.makeInputStream; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.when; public class RotatingSiteStoreTest { @@ -97,4 +96,10 @@ public void loadContentMultipleSites() throws Exception { assertTrue(siteStore.getAllSites().contains(s3)); assertTrue(siteStore.getAllSites().contains(s4)); } + + @Test + public void getSiteReturnsNullBeforeLoadContentIsCalled() { + final var site = siteStore.getSite(1); + assertNull(site); + } } From a7aa4479bd88085e82d4a4386150bc0ca4ac688d Mon Sep 17 00:00:00 2001 From: jon8787 <112368577+jon8787@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:09:22 +1100 Subject: [PATCH 2/2] comment --- src/test/java/com/uid2/shared/store/RotatingSiteStoreTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/uid2/shared/store/RotatingSiteStoreTest.java b/src/test/java/com/uid2/shared/store/RotatingSiteStoreTest.java index 566abad1..54a554de 100644 --- a/src/test/java/com/uid2/shared/store/RotatingSiteStoreTest.java +++ b/src/test/java/com/uid2/shared/store/RotatingSiteStoreTest.java @@ -98,7 +98,7 @@ public void loadContentMultipleSites() throws Exception { } @Test - public void getSiteReturnsNullBeforeLoadContentIsCalled() { + public void getSiteReturnsNullBeforeLoadContentIsCalled() { //eg, loadContent() is never called for Private Operators as they don't currently require site data final var site = siteStore.getSite(1); assertNull(site); }