use of nl.knaw.huygens.timbuctoo.model.AltName in project timbuctoo by HuygensING.
the class JsonPropertyConverterTest method toConvertsTheListOfAltNamesToAnArrayNode.
@Test
public void toConvertsTheListOfAltNamesToAnArrayNode() throws Exception {
JsonPropertyConverter jsonPropertyConverter = new JsonPropertyConverter(null);
AltNames altNames = new AltNames();
altNames.list = Lists.newArrayList(new AltName("type1", "name1"), new AltName("type2", "name2"));
Tuple<String, JsonNode> valueTuple = jsonPropertyConverter.to(new AltNamesProperty("test", altNames));
JsonNode value = valueTuple.getRight();
assertThat(value.isArray(), is(true));
assertThat(Lists.newArrayList(value.iterator()), containsInAnyOrder(jsnO("nametype", jsn("type1"), "displayName", jsn("name1")), jsnO("nametype", jsn("type2"), "displayName", jsn("name2"))));
}
use of nl.knaw.huygens.timbuctoo.model.AltName in project timbuctoo by HuygensING.
the class AltNamesConverterTest method tinkerpopToJsonReadsTheListOfTheAltNamesValues.
@Test
public void tinkerpopToJsonReadsTheListOfTheAltNamesValues() throws Exception {
AltNames altNames = new AltNames();
altNames.list = Lists.newArrayList(ALT_NAME_1, ALT_NAME_2);
String dbValue = objectMapper.writeValueAsString(altNames);
JsonNode jsonNode = instance.tinkerpopToJson(dbValue);
List<AltName> altNameList = objectMapper.readValue(jsonNode.toString(), new TypeReference<List<AltName>>() {
});
assertThat(altNameList, containsInAnyOrder(ALT_NAME_1, ALT_NAME_2));
}
use of nl.knaw.huygens.timbuctoo.model.AltName in project timbuctoo by HuygensING.
the class AltNameFacetDescriptionTest method getValuesReturnsTheDisplayNamesOfAllTheAltNames.
@Test
public void getValuesReturnsTheDisplayNamesOfAllTheAltNames() throws Exception {
String displayName1 = "displayName1";
String displayName2 = "displayName2";
AltNames altNames = new AltNames();
altNames.list = Lists.newArrayList(new AltName("nameType", displayName1), new AltName("nameType", displayName2));
String altNamesPropValue = new ObjectMapper().writeValueAsString(altNames);
Vertex vertex = vertex().withProperty(PROPERTY_NAME, altNamesPropValue).build();
AltNameFacetDescription instance = new AltNameFacetDescription("facetName", PROPERTY_NAME);
List<String> values = instance.getValues(vertex);
assertThat(values, containsInAnyOrder(displayName1, displayName2));
}
Aggregations