### Question:
ExplicitField { public Predicate convertToPredicate() { Map<String, Long> valueTypes = new HashMap<>(); Map<String, Long> referenceTypes = new HashMap<>(); if (values != null) { for (String value : values) { valueTypes.put(value, 0L); } } if (references != null) { for (String reference : references) { referenceTypes.put(reference, 0L); } } Predicate convertedPredicate = new Predicate(uri, Direction.OUT); convertedPredicate.setIsExplicit(true); convertedPredicate.setIsList(isList); convertedPredicate.setValueTypes(valueTypes); convertedPredicate.setReferenceTypes(referenceTypes); return convertedPredicate; } @JsonCreator  ExplicitField(@JsonProperty("uri") String uri,
                       @JsonProperty("isList") boolean isList,
                       @JsonProperty("values") Set<String> values,
                       @JsonProperty("references") Set<String> references); Set<String> getValues(); void setValues(Set<String> values); Set<String> getReferences(); void setReferences(Set<String> references); String getUri(); Predicate convertToPredicate(); @JsonProperty("isList") boolean isList(); void setList(boolean list); ExplicitField mergeWith(ExplicitField explicitField);  }### Answer:
@Test public void convertToPredicateTransformsExplicitFieldValuesToPredicate() throws Exception { Set<String> values = new HashSet<>(); values.add("value1"); values.add("value2"); values.add("value3"); ExplicitField title = new ExplicitField("test:test", false, values, null); Predicate predicate = title.convertToPredicate(); assertThat(predicate.getName(), is("test:test")); assertThat(predicate.getValueTypes(), IsMapContaining.hasEntry("value1", 0L)); assertThat(predicate.getValueTypes(), IsMapContaining.hasEntry("value2", 0L)); assertThat(predicate.getValueTypes(), IsMapContaining.hasEntry("value3", 0L)); }
@Test public void convertToPredicateTransformsExplicitFieldReferencesToPredicate() throws Exception { Set<String> references = new HashSet<>(); references.add("reference1"); references.add("reference2"); references.add("reference3"); ExplicitField title = new ExplicitField("test:test", false, null, references); Predicate predicate = title.convertToPredicate(); assertThat(predicate.getName(), is("test:test")); assertThat(predicate.getReferenceTypes(), IsMapContaining.hasEntry("reference1", 0L)); assertThat(predicate.getReferenceTypes(), IsMapContaining.hasEntry("reference2", 0L)); assertThat(predicate.getReferenceTypes(), IsMapContaining.hasEntry("reference3", 0L)); }
@Test public void convertMakesAnExplicitPredicate() { ExplicitField field = new ExplicitField("test:test", false, null, null); Predicate predicate = field.convertToPredicate(); assertThat(predicate.isExplicit(), is(true)); }