### Question:
CategoricalAttribute extends Attribute { public List<String> getCategoricalInstances() { return ImmutableList.copyOf(categoricalInstances); } @JsonCreator  CategoricalAttribute(@NotBlank @JsonProperty("name") String name,
                                @JsonProperty("categoricalInstances") List<String> pcategoricalInstances); List<String> getCategoricalInstances(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test public void testCreateNominal() throws Exception { assertEquals("Nominal values were not set properly", nominal_values, field.getCategoricalInstances()); assertEquals("Instance name not set properly", name, field.getName()); int index = 0; for(String v : nominal_values) { assertEquals("Known value must be unchanged", index, (int) field.parseOrMissing(v)); index++; } }
@Test public void testJackson() throws Exception { List<Attribute> attributes = new ArrayList<>(); attributes.add(field); ObjectMapper mapper = new ObjectMapper(); TypeReference<List<Attribute>> typeReference = new TypeReference<List<Attribute>>() { }; String result = mapper.writerWithType(typeReference).writeValueAsString(attributes); List<Attribute> deserialized = mapper.readValue(result, typeReference); assertEquals(attributes.size(), deserialized.size()); CategoricalAttribute extracted = (CategoricalAttribute) deserialized.get(0); assertEquals(field.getName(), extracted.getName()); assertEquals(field.getCategoricalInstances(), extracted.getCategoricalInstances()); }