• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DataBiosphere / consent / #6090

18 Jun 2025 02:14PM UTC coverage: 79.181% (+0.1%) from 79.084%
#6090

push

web-flow
[DT-1819] Require country of operation for PI, internal collaborators, lab staff (#2567)

31 of 35 new or added lines in 6 files covered. (88.57%)

10265 of 12964 relevant lines covered (79.18%)

0.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/src/main/java/org/broadinstitute/consent/http/util/CountryValidator.java
1
package org.broadinstitute.consent.http.util;
2

3
import com.google.gson.Gson;
4
import com.google.gson.reflect.TypeToken;
5
import com.google.gson.JsonParseException;
6
import java.io.IOException;
7
import java.io.InputStream;
8
import java.io.InputStreamReader;
9
import java.lang.reflect.Type;
10
import java.nio.charset.StandardCharsets;
11
import java.util.HashSet;
12
import java.util.Set;
13

14
public class CountryValidator {
15
  private static final String FILEPATH = "assets/ISO-3166-countries.json";
16
  private Set<String> countries;
17
  public CountryValidator() {
1✔
18
    try (InputStream is = getClass().getClassLoader().getResourceAsStream(FILEPATH)) {
1✔
19
      if (is != null) {
1✔
20
        Type type = new TypeToken<Set<String>>() {}.getType();
1✔
21
        countries = new Gson().fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), type);
1✔
22
      }
NEW
23
    } catch (JsonParseException | IOException e) {
×
NEW
24
      countries = new HashSet<>();
×
NEW
25
      throw new IllegalStateException(e);
×
26
    }
1✔
27
  }
1✔
28

29
  public boolean isInCountryList(String country) {
30
    return countries.contains(country);
1✔
31
  }
32

33
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc