SemanticQueryTerm { public String description() { return category() .map(category -> String.format("%s (%s)", value(), category)) .orElse(value()); }  abstract String value(); abstract Optional<String> category(); static SemanticQueryTerm create(String value); static SemanticQueryTerm create(String value, String category); boolean hasValue(); String description(); static SemanticQueryTerm.GsonTypeAdapter getGsonTypeAdapter();  }
@Test public void description() { String randomValue = random(128); String randomCategory = random(128); assertThat( SemanticQueryTerm.create( randomValue, randomCategory).description()) .isEqualTo(randomValue + " (" + randomCategory + ")"); assertThat(SemanticQueryTerm.create(randomValue, "").description()) .isEqualTo(SemanticQueryTerm.create(randomValue).description()) .isEqualTo(randomValue); }