@Test public void shouldTruncateTitleWhenItIsNotNull() { DocumentMetadata source = createDocumentMetadata(); source.setTitle("title"); when(titleTruncator.apply("title")).thenReturn("truncated"); DocumentMetadata result = documentMetadataAvroTruncator.truncate(source); assertEquals("truncated", result.getTitle()); }
@Override public DocumentMetadata truncate(DocumentMetadata source) { if (Objects.nonNull(source.getAbstract$())) { source.setAbstract$(abstractTruncator.apply(source.getAbstract$())); } if (Objects.nonNull(source.getTitle())) { source.setTitle(titleTruncator.apply(source.getTitle())); } if (Objects.nonNull(source.getAuthors())) { source.setAuthors(authorsTruncator.apply(source.getAuthors())); } if (Objects.nonNull(source.getKeywords())) { source.setKeywords(keywordsTruncator.apply(source.getKeywords())); } return source; }
DocumentMetadataAvroTruncator implements AvroTruncator<DocumentMetadata> { @Override public DocumentMetadata truncate(DocumentMetadata source) { if (Objects.nonNull(source.getAbstract$())) { source.setAbstract$(abstractTruncator.apply(source.getAbstract$())); } if (Objects.nonNull(source.getTitle())) { source.setTitle(titleTruncator.apply(source.getTitle())); } if (Objects.nonNull(source.getAuthors())) { source.setAuthors(authorsTruncator.apply(source.getAuthors())); } if (Objects.nonNull(source.getKeywords())) { source.setKeywords(keywordsTruncator.apply(source.getKeywords())); } return source; } }
DocumentMetadataAvroTruncator implements AvroTruncator<DocumentMetadata> { @Override public DocumentMetadata truncate(DocumentMetadata source) { if (Objects.nonNull(source.getAbstract$())) { source.setAbstract$(abstractTruncator.apply(source.getAbstract$())); } if (Objects.nonNull(source.getTitle())) { source.setTitle(titleTruncator.apply(source.getTitle())); } if (Objects.nonNull(source.getAuthors())) { source.setAuthors(authorsTruncator.apply(source.getAuthors())); } if (Objects.nonNull(source.getKeywords())) { source.setKeywords(keywordsTruncator.apply(source.getKeywords())); } return source; } private  DocumentMetadataAvroTruncator(int maxAbstractLength,
                                          int maxTitleLength,
                                          int maxAuthorsSize,
                                          int maxAuthorFullnameLength,
                                          int maxKeywordsSize,
                                          int maxKeywordLength); }
DocumentMetadataAvroTruncator implements AvroTruncator<DocumentMetadata> { @Override public DocumentMetadata truncate(DocumentMetadata source) { if (Objects.nonNull(source.getAbstract$())) { source.setAbstract$(abstractTruncator.apply(source.getAbstract$())); } if (Objects.nonNull(source.getTitle())) { source.setTitle(titleTruncator.apply(source.getTitle())); } if (Objects.nonNull(source.getAuthors())) { source.setAuthors(authorsTruncator.apply(source.getAuthors())); } if (Objects.nonNull(source.getKeywords())) { source.setKeywords(keywordsTruncator.apply(source.getKeywords())); } return source; } private  DocumentMetadataAvroTruncator(int maxAbstractLength,
                                          int maxTitleLength,
                                          int maxAuthorsSize,
                                          int maxAuthorFullnameLength,
                                          int maxKeywordsSize,
                                          int maxKeywordLength); @Override DocumentMetadata truncate(DocumentMetadata source); static Builder newBuilder(); }
DocumentMetadataAvroTruncator implements AvroTruncator<DocumentMetadata> { @Override public DocumentMetadata truncate(DocumentMetadata source) { if (Objects.nonNull(source.getAbstract$())) { source.setAbstract$(abstractTruncator.apply(source.getAbstract$())); } if (Objects.nonNull(source.getTitle())) { source.setTitle(titleTruncator.apply(source.getTitle())); } if (Objects.nonNull(source.getAuthors())) { source.setAuthors(authorsTruncator.apply(source.getAuthors())); } if (Objects.nonNull(source.getKeywords())) { source.setKeywords(keywordsTruncator.apply(source.getKeywords())); } return source; } private  DocumentMetadataAvroTruncator(int maxAbstractLength,
                                          int maxTitleLength,
                                          int maxAuthorsSize,
                                          int maxAuthorFullnameLength,
                                          int maxKeywordsSize,
                                          int maxKeywordLength); @Override DocumentMetadata truncate(DocumentMetadata source); static Builder newBuilder();  }