@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())); }
@Override public String parse(String value) { if (value != null) { try { PersonNames personNames = readPersonNames(value); return personNames.defaultName().getFullName(); } catch (IOException e) { LOG.error("Cannot parse '{}' as PersonNames", value); LOG.error("Exception thrown", e); } } return null; }
PersonNamesDefaultNamePropertyParser implements PropertyParser { @Override public String parse(String value) { if (value != null) { try { PersonNames personNames = readPersonNames(value); return personNames.defaultName().getFullName(); } catch (IOException e) { LOG.error("Cannot parse '{}' as PersonNames", value); LOG.error("Exception thrown", e); } } return null; } }
PersonNamesDefaultNamePropertyParser implements PropertyParser { @Override public String parse(String value) { if (value != null) { try { PersonNames personNames = readPersonNames(value); return personNames.defaultName().getFullName(); } catch (IOException e) { LOG.error("Cannot parse '{}' as PersonNames", value); LOG.error("Exception thrown", e); } } return null; }  }
PersonNamesDefaultNamePropertyParser implements PropertyParser { @Override public String parse(String value) { if (value != null) { try { PersonNames personNames = readPersonNames(value); return personNames.defaultName().getFullName(); } catch (IOException e) { LOG.error("Cannot parse '{}' as PersonNames", value); LOG.error("Exception thrown", e); } } return null; }  @Override String parse(String value); @Override Comparable<?> parseForSort(String value); }
PersonNamesDefaultNamePropertyParser implements PropertyParser { @Override public String parse(String value) { if (value != null) { try { PersonNames personNames = readPersonNames(value); return personNames.defaultName().getFullName(); } catch (IOException e) { LOG.error("Cannot parse '{}' as PersonNames", value); LOG.error("Exception thrown", e); } } return null; }  @Override String parse(String value); @Override Comparable<?> parseForSort(String value);  }