SemanticQuery implements Iterable<SemanticQueryTerm> { public static SemanticQuery fromJson(String json) { if (isBlank(json)) { return create(); } return create(ImmutableSet.copyOf(GSON.fromJson(json, AutoValue_SemanticQueryTerm[].class))); }  abstract ImmutableSet<SemanticQueryTerm> terms(); static SemanticQuery create(Collection<SemanticQueryTerm> queryTerms); static SemanticQuery create(); static SemanticQuery create(SemanticQueryTerm... queryTerms); static SemanticQuery create(String queryTermValue); Map<String, Set<String>> groupValuesByCategory(); @Override Iterator<SemanticQueryTerm> iterator(); boolean isEmpty(); boolean isNotEmpty(); int size(); String toJson(); String toUrlEncodedJson(); static SemanticQuery fromJson(String json); static SemanticQuery fromUrlEncodedJson(String json); String description();  }
@Test public void fromJson() throws UnsupportedEncodingException { assertThat(SemanticQuery.fromJson("")) .isEqualTo(SemanticQuery.fromUrlEncodedJson("")) .isEqualTo(SemanticQuery.create()); }
@Test public void fromJsonWithRepeats() { String geneQueryBrca2WithRepeats = "[" + "{\"value\":\"BRCA2\",\"category\":\"symbol\"}, " + "{\"value\":\"BRCA2\",\"category\":\"symbol\"}, " + "{\"value\":\"BRCA2B\",\"category\":\"synonym\"}, " + "{\"value\":\"BRCA2B\",\"category\":\"synonym\"}, " + "{\"value\":\"BRCA2 repeat\",\"category\":\"\"}, " + "{\"value\":\"BRCA2 repeat\",\"category\":\"\"}" + "]"; assertThat(SemanticQuery.fromJson(geneQueryBrca2WithRepeats)) .isEqualTo(subject); }