DocumentToDirectCitationMetadataConverter implements Serializable { public DocumentMetadata convert(ExtractedDocumentMetadataMergedWithOriginal document) { Preconditions.checkNotNull(document); List<ReferenceMetadata> citationReferencesMetadata = convertReferences(document.getReferences()); return new DocumentMetadata(document.getId(), document.getExternalIdentifiers(), document.getPublicationTypeName(), citationReferencesMetadata); }  DocumentMetadata convert(ExtractedDocumentMetadataMergedWithOriginal document);  }
@Test(expected = NullPointerException.class) public void convert_NULL() { converter.convert(null); }
@Test public void convert() { ExtractedDocumentMetadataMergedWithOriginal docMetadata = baseDocMetadataBuilder.build(); DocumentMetadata retDocDirectCitationMetadata = converter.convert(docMetadata); DocumentMetadata expectedDocDirectCitationMetadata = baseDocDirectCitationMetadataBuilder.build(); assertEquals(expectedDocDirectCitationMetadata, retDocDirectCitationMetadata); }
@Test public void convert_NULL_EXTERNAL_IDENTIFIERS() { ExtractedDocumentMetadataMergedWithOriginal docMetadata = baseDocMetadataBuilder .clearExternalIdentifiers() .build(); DocumentMetadata retDocDirectCitationMetadata = converter.convert(docMetadata); DocumentMetadata expectedDocDirectCitationMetadata = baseDocDirectCitationMetadataBuilder .clearExternalIdentifiers() .build(); assertEquals(expectedDocDirectCitationMetadata, retDocDirectCitationMetadata); }
@Test public void convert_NULL_REFERENCES() { ExtractedDocumentMetadataMergedWithOriginal docMetadata = baseDocMetadataBuilder .clearReferences() .build(); DocumentMetadata retDocDirectCitationMetadata = converter.convert(docMetadata); DocumentMetadata expectedDocDirectCitationMetadata = baseDocDirectCitationMetadataBuilder .setReferences(Lists.newArrayList()) .build(); assertEquals(expectedDocDirectCitationMetadata, retDocDirectCitationMetadata); }
@Test public void convert_NULL_REFERENCES_EXTERNAL_IDS() { ExtractedDocumentMetadataMergedWithOriginal docMetadata = baseDocMetadataBuilder .setReferences(Lists.newArrayList(buildReferenceMetadata(24, null))) .build(); DocumentMetadata retDocDirectCitationMetadata = converter.convert(docMetadata); DocumentMetadata expectedDocDirectCitationMetadata = baseDocDirectCitationMetadataBuilder .setReferences(Lists.newArrayList()) .build(); assertEquals(expectedDocDirectCitationMetadata, retDocDirectCitationMetadata); }
@Test public void convert_EMPTY_REFERENCES_EXTERNAL_IDS() { ExtractedDocumentMetadataMergedWithOriginal docMetadata = baseDocMetadataBuilder .setReferences(Lists.newArrayList(buildReferenceMetadata(24, buildExternalIds()))) .build(); DocumentMetadata retDocDirectCitationMetadata = converter.convert(docMetadata); DocumentMetadata expectedDocDirectCitationMetadata = baseDocDirectCitationMetadataBuilder .setReferences(Lists.newArrayList()) .build(); assertEquals(expectedDocDirectCitationMetadata, retDocDirectCitationMetadata); }