use of nl.knaw.huygens.timbuctoo.model.PersonNames in project timbuctoo by HuygensING.
the class TriplePropertyConverterTest method toAddsTheValueTypePersonNames.
@Test
public void toAddsTheValueTypePersonNames() throws Exception {
PersonNames value = new PersonNames();
value.list.add(PersonName.newInstance("forename", "surname"));
Tuple<String, List<Triple>> to = instance.to(new PersonNamesProperty(PROP_NAME, value));
assertThat(to.getRight(), contains(allOf(hasProperty("datatype", is("http://timbuctoo.huygens.knaw.nl/personnames")))));
}
use of nl.knaw.huygens.timbuctoo.model.PersonNames in project timbuctoo by HuygensING.
the class PersonNamesDefaultNamePropertyParserTest method parseReturnsTheShortNameOfTheFirstNameOfThePersonNames.
@Test
public void parseReturnsTheShortNameOfTheFirstNameOfThePersonNames() throws JsonProcessingException {
PersonNames names = new PersonNames();
PersonName name1 = PersonName.newInstance("forename", "surname");
names.list.add(name1);
names.list.add(PersonName.newInstance("forename2", "surname2"));
String input = new ObjectMapper().writeValueAsString(names);
String value = instance.parse(input);
assertThat(value, is(name1.getShortName()));
}
use of nl.knaw.huygens.timbuctoo.model.PersonNames in project timbuctoo by HuygensING.
the class PersonNamesDefaultNamePropertyParser method parseForSort.
@Override
public Comparable<?> parseForSort(String value) {
if (value != null) {
try {
PersonNames personNames = readPersonNames(value);
String defaultName = personNames.defaultName().getSortName();
if (StringUtils.isBlank(defaultName)) {
return null;
}
return defaultName;
} catch (IOException e) {
LOG.error("Cannot parse '{}' as PersonNames", value);
LOG.error("Exception thrown", e);
}
}
return null;
}
use of nl.knaw.huygens.timbuctoo.model.PersonNames in project timbuctoo by HuygensING.
the class TriplePropertyConverterTest method toCreatesATripleWithAJsonVersionOfPersonNames.
@Test
public void toCreatesATripleWithAJsonVersionOfPersonNames() throws Exception {
PersonNames value = new PersonNames();
value.list.add(PersonName.newInstance("forename", "surname"));
ObjectMapper objectMapper = new ObjectMapper();
String objectValue = objectMapper.writeValueAsString(value);
Tuple<String, List<Triple>> to = instance.to(new PersonNamesProperty(PROP_NAME, value));
LiteralTriple triple = (LiteralTriple) to.getRight().get(0);
assertThat(triple.getSubject(), is(SUBJECT_URI));
assertThat(triple.getPredicate(), endsWith(PROP_NAME));
assertThat(triple.getObject(), is(objectValue));
assertThat(triple.getDatatype(), is("http://timbuctoo.huygens.knaw.nl/personnames"));
}
use of nl.knaw.huygens.timbuctoo.model.PersonNames in project timbuctoo by HuygensING.
the class PersonNamesDefaultNamePropertyParserTest method parserToRawReturnsNullIfThePersonNamesIsEmpty.
@Test
public void parserToRawReturnsNullIfThePersonNamesIsEmpty() throws JsonProcessingException {
PersonNames names = new PersonNames();
String input = new ObjectMapper().writeValueAsString(names);
Object value = instance.parseForSort(input);
assertThat(value, is(nullValue()));
}
Aggregations