@SuppressWarnings({"unchecked", "RedundantArrayCreation"}) @Test public void testCreateReference() { CSVRecordInfo<CoLReferenceCsvField> record = mock(CSVRecordInfo.class); when(record.get(CoLReferenceCsvField.taxonID)).thenReturn("6931870"); when(record.get(CoLReferenceCsvField.creator)).thenReturn("Pfeiffer, L."); when(record.get(CoLReferenceCsvField.date)).thenReturn("1846"); when(record.get(CoLReferenceCsvField.title)).thenReturn("Diagnosen einiger neuer Heliceen."); when(record.get(CoLReferenceCsvField.description)).thenReturn("Malakozoologische Blätter"); when(record.get(CoLReferenceCsvField.identifier)).thenReturn(""); when(record.get(CoLReferenceCsvField.type)).thenReturn("taxon"); Object returned = ReflectionUtil.callStatic(CoLReferenceBatchTransformer.class, "createReference", new Class[] {CSVRecordInfo.class}, new Object[] {record}); Reference actual = (Reference) returned; String authorName = "Pfeiffer, L."; String citationDetail = "Malakozoologische Blätter"; String titleCitation = "Diagnosen einiger neuer Heliceen."; String publicationDate = "1846-01-01T00:00Z"; assertNotNull("01",actual); assertEquals("02",authorName, actual.getAuthor().getFullName()); assertEquals("03",citationDetail, actual.getCitationDetail()); assertEquals("04",titleCitation, actual.getTitleCitation()); assertEquals("05",publicationDate, actual.getPublicationDate().toString()); }
private static Reference createReference(CSVRecordInfo<CoLReferenceCsvField> record) { Reference ref = new Reference(); ref.setTitleCitation(record.get(title)); ref.setCitationDetail(record.get(description)); String s; if ((s = record.get(date)) != null) { OffsetDateTime odt = new ESDateInput(s).parseAsYear(); if (odt == null) { logger.warn("Invalid date: {}", s); } else { ref.setPublicationDate(odt); } } if ((s = record.get(creator)) != null) { ref.setAuthor(new Person(s)); } return ref; }
CoLReferenceBatchTransformer { private static Reference createReference(CSVRecordInfo<CoLReferenceCsvField> record) { Reference ref = new Reference(); ref.setTitleCitation(record.get(title)); ref.setCitationDetail(record.get(description)); String s; if ((s = record.get(date)) != null) { OffsetDateTime odt = new ESDateInput(s).parseAsYear(); if (odt == null) { logger.warn("Invalid date: {}", s); } else { ref.setPublicationDate(odt); } } if ((s = record.get(creator)) != null) { ref.setAuthor(new Person(s)); } return ref; } }
CoLReferenceBatchTransformer { private static Reference createReference(CSVRecordInfo<CoLReferenceCsvField> record) { Reference ref = new Reference(); ref.setTitleCitation(record.get(title)); ref.setCitationDetail(record.get(description)); String s; if ((s = record.get(date)) != null) { OffsetDateTime odt = new ESDateInput(s).parseAsYear(); if (odt == null) { logger.warn("Invalid date: {}", s); } else { ref.setPublicationDate(odt); } } if ((s = record.get(creator)) != null) { ref.setAuthor(new Person(s)); } return ref; } CoLReferenceBatchTransformer(); }
CoLReferenceBatchTransformer { private static Reference createReference(CSVRecordInfo<CoLReferenceCsvField> record) { Reference ref = new Reference(); ref.setTitleCitation(record.get(title)); ref.setCitationDetail(record.get(description)); String s; if ((s = record.get(date)) != null) { OffsetDateTime odt = new ESDateInput(s).parseAsYear(); if (odt == null) { logger.warn("Invalid date: {}", s); } else { ref.setPublicationDate(odt); } } if ((s = record.get(creator)) != null) { ref.setAuthor(new Person(s)); } return ref; } CoLReferenceBatchTransformer();  }
CoLReferenceBatchTransformer { private static Reference createReference(CSVRecordInfo<CoLReferenceCsvField> record) { Reference ref = new Reference(); ref.setTitleCitation(record.get(title)); ref.setCitationDetail(record.get(description)); String s; if ((s = record.get(date)) != null) { OffsetDateTime odt = new ESDateInput(s).parseAsYear(); if (odt == null) { logger.warn("Invalid date: {}", s); } else { ref.setPublicationDate(odt); } } if ((s = record.get(creator)) != null) { ref.setAuthor(new Person(s)); } return ref; } CoLReferenceBatchTransformer();   }