Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


public class RotatingSiteStore implements ISiteStore, StoreReader<Collection<Site>> {
public static final String SITES_METADATA_PATH = "sites_metadata_path";
private final ScopedStoreReader<Map<Integer, Site>> reader;

public RotatingSiteStore(DownloadCloudStorage fileStreamProvider, StoreScope scope) {
Expand All @@ -36,7 +35,8 @@ public Collection<Site> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -97,4 +96,10 @@ public void loadContentMultipleSites() throws Exception {
assertTrue(siteStore.getAllSites().contains(s3));
assertTrue(siteStore.getAllSites().contains(s4));
}

@Test
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);
}
}