@Test public void shouldIgnoreWhenFormatIsNull() throws Exception { final LoggingProperties loggingProperties = new LoggingProperties(); loggingProperties.setStrategy(alwaysHideStrategy()); emailRendererConfiguration = createEmailRendererConfigurationWithStrategy(loggingProperties); Email emailFullContent = createEmailFullContent(); EmailRenderer emailRenderer = emailRendererConfiguration.emailRenderer(); assertions.assertThat(emailRenderer.render(emailFullContent)).isEqualTo("Email{}"); verify(customizableEmailRendererBuilder, never()).withFromFormat(any()); verify(customizableEmailRendererBuilder, never()).withReplyToFormat(any()); verify(customizableEmailRendererBuilder, never()).withToFormat(any()); verify(customizableEmailRendererBuilder, never()).withCcFormat(any()); verify(customizableEmailRendererBuilder, never()).withBccFormat(any()); verify(customizableEmailRendererBuilder, never()).withSubjectFormat(any()); verify(customizableEmailRendererBuilder, never()).withBodyFormat(any()); verify(customizableEmailRendererBuilder, never()).withAttachmentsFormat(any()); verify(customizableEmailRendererBuilder, never()).withEncodingFormat(any()); verify(customizableEmailRendererBuilder, never()).withLocaleFormat(any()); verify(customizableEmailRendererBuilder, never()).withSentAtFormat(any()); verify(customizableEmailRendererBuilder, never()).withReceiptToFormat(any()); verify(customizableEmailRendererBuilder, never()).withDepositionNotificationToFormat(any()); }
@Bean public EmailRenderer emailRenderer() { final CustomizableEmailRendererBuilder customizableEmailRendererBuilder = createCustomizableEmailRendererBuilder(); final LoggingProperties.Strategy loggingPropertiesStrategy = loggingProperties.getStrategy(); final Function<InternetAddress, String> fromFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getFrom()); if (nonNull(fromFormat)) customizableEmailRendererBuilder.withFromFormat(fromFormat); final Function<InternetAddress, String> replyToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getReplyTo()); if (nonNull(replyToFormat)) customizableEmailRendererBuilder.withReplyToFormat(replyToFormat); final Function<InternetAddress, String> toFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getTo()); if (nonNull(toFormat)) customizableEmailRendererBuilder.withToFormat(toFormat); final Function<InternetAddress, String> ccFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getCc()); if (nonNull(ccFormat)) customizableEmailRendererBuilder.withCcFormat(ccFormat); final Function<InternetAddress, String> bccFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getBcc()); if (nonNull(bccFormat)) customizableEmailRendererBuilder.withBccFormat(bccFormat); final UnaryOperator<String> subjectFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getSubject()); if (nonNull(subjectFormat)) customizableEmailRendererBuilder.withSubjectFormat(subjectFormat); final UnaryOperator<String> bodyFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getBody()); if (nonNull(bodyFormat)) customizableEmailRendererBuilder.withBodyFormat(bodyFormat); final UnaryOperator<String> attachmentsFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getAttachments()); if (nonNull(attachmentsFormat)) customizableEmailRendererBuilder.withAttachmentsFormat(attachmentsFormat); final UnaryOperator<String> encodingFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getEncoding()); if (nonNull(encodingFormat)) customizableEmailRendererBuilder.withEncodingFormat(encodingFormat); final Function<Locale, String> localeFormat = EmailFieldFormat.localeFormatterFrom(loggingPropertiesStrategy.getLocale()); if (nonNull(localeFormat)) customizableEmailRendererBuilder.withLocaleFormat(localeFormat); final Function<Date, String> sentAtFormat = EmailFieldFormat.dateFormatterFrom(loggingPropertiesStrategy.getSentAt()); if (nonNull(sentAtFormat)) customizableEmailRendererBuilder.withSentAtFormat(sentAtFormat); final Function<InternetAddress, String> receiptToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getReceiptTo()); if (nonNull(receiptToFormat)) customizableEmailRendererBuilder.withReceiptToFormat(receiptToFormat); final Function<InternetAddress, String> depositionNotificationToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getDepositionNotificationTo()); if (nonNull(depositionNotificationToFormat)) customizableEmailRendererBuilder.withDepositionNotificationToFormat(depositionNotificationToFormat); if (!loggingPropertiesStrategy.areCustomHeadersIgnored()) customizableEmailRendererBuilder.includeCustomHeaders(); if (!loggingPropertiesStrategy.areNullAndEmptyCollectionsIgnored()) customizableEmailRendererBuilder.includeNullAndEmptyCollections(); return customizableEmailRendererBuilder.build(); }
EmailRendererConfiguration { @Bean public EmailRenderer emailRenderer() { final CustomizableEmailRendererBuilder customizableEmailRendererBuilder = createCustomizableEmailRendererBuilder(); final LoggingProperties.Strategy loggingPropertiesStrategy = loggingProperties.getStrategy(); final Function<InternetAddress, String> fromFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getFrom()); if (nonNull(fromFormat)) customizableEmailRendererBuilder.withFromFormat(fromFormat); final Function<InternetAddress, String> replyToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getReplyTo()); if (nonNull(replyToFormat)) customizableEmailRendererBuilder.withReplyToFormat(replyToFormat); final Function<InternetAddress, String> toFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getTo()); if (nonNull(toFormat)) customizableEmailRendererBuilder.withToFormat(toFormat); final Function<InternetAddress, String> ccFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getCc()); if (nonNull(ccFormat)) customizableEmailRendererBuilder.withCcFormat(ccFormat); final Function<InternetAddress, String> bccFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getBcc()); if (nonNull(bccFormat)) customizableEmailRendererBuilder.withBccFormat(bccFormat); final UnaryOperator<String> subjectFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getSubject()); if (nonNull(subjectFormat)) customizableEmailRendererBuilder.withSubjectFormat(subjectFormat); final UnaryOperator<String> bodyFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getBody()); if (nonNull(bodyFormat)) customizableEmailRendererBuilder.withBodyFormat(bodyFormat); final UnaryOperator<String> attachmentsFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getAttachments()); if (nonNull(attachmentsFormat)) customizableEmailRendererBuilder.withAttachmentsFormat(attachmentsFormat); final UnaryOperator<String> encodingFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getEncoding()); if (nonNull(encodingFormat)) customizableEmailRendererBuilder.withEncodingFormat(encodingFormat); final Function<Locale, String> localeFormat = EmailFieldFormat.localeFormatterFrom(loggingPropertiesStrategy.getLocale()); if (nonNull(localeFormat)) customizableEmailRendererBuilder.withLocaleFormat(localeFormat); final Function<Date, String> sentAtFormat = EmailFieldFormat.dateFormatterFrom(loggingPropertiesStrategy.getSentAt()); if (nonNull(sentAtFormat)) customizableEmailRendererBuilder.withSentAtFormat(sentAtFormat); final Function<InternetAddress, String> receiptToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getReceiptTo()); if (nonNull(receiptToFormat)) customizableEmailRendererBuilder.withReceiptToFormat(receiptToFormat); final Function<InternetAddress, String> depositionNotificationToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getDepositionNotificationTo()); if (nonNull(depositionNotificationToFormat)) customizableEmailRendererBuilder.withDepositionNotificationToFormat(depositionNotificationToFormat); if (!loggingPropertiesStrategy.areCustomHeadersIgnored()) customizableEmailRendererBuilder.includeCustomHeaders(); if (!loggingPropertiesStrategy.areNullAndEmptyCollectionsIgnored()) customizableEmailRendererBuilder.includeNullAndEmptyCollections(); return customizableEmailRendererBuilder.build(); } }
EmailRendererConfiguration { @Bean public EmailRenderer emailRenderer() { final CustomizableEmailRendererBuilder customizableEmailRendererBuilder = createCustomizableEmailRendererBuilder(); final LoggingProperties.Strategy loggingPropertiesStrategy = loggingProperties.getStrategy(); final Function<InternetAddress, String> fromFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getFrom()); if (nonNull(fromFormat)) customizableEmailRendererBuilder.withFromFormat(fromFormat); final Function<InternetAddress, String> replyToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getReplyTo()); if (nonNull(replyToFormat)) customizableEmailRendererBuilder.withReplyToFormat(replyToFormat); final Function<InternetAddress, String> toFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getTo()); if (nonNull(toFormat)) customizableEmailRendererBuilder.withToFormat(toFormat); final Function<InternetAddress, String> ccFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getCc()); if (nonNull(ccFormat)) customizableEmailRendererBuilder.withCcFormat(ccFormat); final Function<InternetAddress, String> bccFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getBcc()); if (nonNull(bccFormat)) customizableEmailRendererBuilder.withBccFormat(bccFormat); final UnaryOperator<String> subjectFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getSubject()); if (nonNull(subjectFormat)) customizableEmailRendererBuilder.withSubjectFormat(subjectFormat); final UnaryOperator<String> bodyFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getBody()); if (nonNull(bodyFormat)) customizableEmailRendererBuilder.withBodyFormat(bodyFormat); final UnaryOperator<String> attachmentsFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getAttachments()); if (nonNull(attachmentsFormat)) customizableEmailRendererBuilder.withAttachmentsFormat(attachmentsFormat); final UnaryOperator<String> encodingFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getEncoding()); if (nonNull(encodingFormat)) customizableEmailRendererBuilder.withEncodingFormat(encodingFormat); final Function<Locale, String> localeFormat = EmailFieldFormat.localeFormatterFrom(loggingPropertiesStrategy.getLocale()); if (nonNull(localeFormat)) customizableEmailRendererBuilder.withLocaleFormat(localeFormat); final Function<Date, String> sentAtFormat = EmailFieldFormat.dateFormatterFrom(loggingPropertiesStrategy.getSentAt()); if (nonNull(sentAtFormat)) customizableEmailRendererBuilder.withSentAtFormat(sentAtFormat); final Function<InternetAddress, String> receiptToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getReceiptTo()); if (nonNull(receiptToFormat)) customizableEmailRendererBuilder.withReceiptToFormat(receiptToFormat); final Function<InternetAddress, String> depositionNotificationToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getDepositionNotificationTo()); if (nonNull(depositionNotificationToFormat)) customizableEmailRendererBuilder.withDepositionNotificationToFormat(depositionNotificationToFormat); if (!loggingPropertiesStrategy.areCustomHeadersIgnored()) customizableEmailRendererBuilder.includeCustomHeaders(); if (!loggingPropertiesStrategy.areNullAndEmptyCollectionsIgnored()) customizableEmailRendererBuilder.includeNullAndEmptyCollections(); return customizableEmailRendererBuilder.build(); } @Autowired  EmailRendererConfiguration(final LoggingProperties loggingProperties); }
EmailRendererConfiguration { @Bean public EmailRenderer emailRenderer() { final CustomizableEmailRendererBuilder customizableEmailRendererBuilder = createCustomizableEmailRendererBuilder(); final LoggingProperties.Strategy loggingPropertiesStrategy = loggingProperties.getStrategy(); final Function<InternetAddress, String> fromFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getFrom()); if (nonNull(fromFormat)) customizableEmailRendererBuilder.withFromFormat(fromFormat); final Function<InternetAddress, String> replyToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getReplyTo()); if (nonNull(replyToFormat)) customizableEmailRendererBuilder.withReplyToFormat(replyToFormat); final Function<InternetAddress, String> toFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getTo()); if (nonNull(toFormat)) customizableEmailRendererBuilder.withToFormat(toFormat); final Function<InternetAddress, String> ccFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getCc()); if (nonNull(ccFormat)) customizableEmailRendererBuilder.withCcFormat(ccFormat); final Function<InternetAddress, String> bccFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getBcc()); if (nonNull(bccFormat)) customizableEmailRendererBuilder.withBccFormat(bccFormat); final UnaryOperator<String> subjectFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getSubject()); if (nonNull(subjectFormat)) customizableEmailRendererBuilder.withSubjectFormat(subjectFormat); final UnaryOperator<String> bodyFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getBody()); if (nonNull(bodyFormat)) customizableEmailRendererBuilder.withBodyFormat(bodyFormat); final UnaryOperator<String> attachmentsFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getAttachments()); if (nonNull(attachmentsFormat)) customizableEmailRendererBuilder.withAttachmentsFormat(attachmentsFormat); final UnaryOperator<String> encodingFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getEncoding()); if (nonNull(encodingFormat)) customizableEmailRendererBuilder.withEncodingFormat(encodingFormat); final Function<Locale, String> localeFormat = EmailFieldFormat.localeFormatterFrom(loggingPropertiesStrategy.getLocale()); if (nonNull(localeFormat)) customizableEmailRendererBuilder.withLocaleFormat(localeFormat); final Function<Date, String> sentAtFormat = EmailFieldFormat.dateFormatterFrom(loggingPropertiesStrategy.getSentAt()); if (nonNull(sentAtFormat)) customizableEmailRendererBuilder.withSentAtFormat(sentAtFormat); final Function<InternetAddress, String> receiptToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getReceiptTo()); if (nonNull(receiptToFormat)) customizableEmailRendererBuilder.withReceiptToFormat(receiptToFormat); final Function<InternetAddress, String> depositionNotificationToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getDepositionNotificationTo()); if (nonNull(depositionNotificationToFormat)) customizableEmailRendererBuilder.withDepositionNotificationToFormat(depositionNotificationToFormat); if (!loggingPropertiesStrategy.areCustomHeadersIgnored()) customizableEmailRendererBuilder.includeCustomHeaders(); if (!loggingPropertiesStrategy.areNullAndEmptyCollectionsIgnored()) customizableEmailRendererBuilder.includeNullAndEmptyCollections(); return customizableEmailRendererBuilder.build(); } @Autowired  EmailRendererConfiguration(final LoggingProperties loggingProperties); @Bean EmailRenderer emailRenderer(); }
EmailRendererConfiguration { @Bean public EmailRenderer emailRenderer() { final CustomizableEmailRendererBuilder customizableEmailRendererBuilder = createCustomizableEmailRendererBuilder(); final LoggingProperties.Strategy loggingPropertiesStrategy = loggingProperties.getStrategy(); final Function<InternetAddress, String> fromFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getFrom()); if (nonNull(fromFormat)) customizableEmailRendererBuilder.withFromFormat(fromFormat); final Function<InternetAddress, String> replyToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getReplyTo()); if (nonNull(replyToFormat)) customizableEmailRendererBuilder.withReplyToFormat(replyToFormat); final Function<InternetAddress, String> toFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getTo()); if (nonNull(toFormat)) customizableEmailRendererBuilder.withToFormat(toFormat); final Function<InternetAddress, String> ccFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getCc()); if (nonNull(ccFormat)) customizableEmailRendererBuilder.withCcFormat(ccFormat); final Function<InternetAddress, String> bccFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getBcc()); if (nonNull(bccFormat)) customizableEmailRendererBuilder.withBccFormat(bccFormat); final UnaryOperator<String> subjectFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getSubject()); if (nonNull(subjectFormat)) customizableEmailRendererBuilder.withSubjectFormat(subjectFormat); final UnaryOperator<String> bodyFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getBody()); if (nonNull(bodyFormat)) customizableEmailRendererBuilder.withBodyFormat(bodyFormat); final UnaryOperator<String> attachmentsFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getAttachments()); if (nonNull(attachmentsFormat)) customizableEmailRendererBuilder.withAttachmentsFormat(attachmentsFormat); final UnaryOperator<String> encodingFormat = EmailFieldFormat.textFormatterFrom(loggingPropertiesStrategy.getEncoding()); if (nonNull(encodingFormat)) customizableEmailRendererBuilder.withEncodingFormat(encodingFormat); final Function<Locale, String> localeFormat = EmailFieldFormat.localeFormatterFrom(loggingPropertiesStrategy.getLocale()); if (nonNull(localeFormat)) customizableEmailRendererBuilder.withLocaleFormat(localeFormat); final Function<Date, String> sentAtFormat = EmailFieldFormat.dateFormatterFrom(loggingPropertiesStrategy.getSentAt()); if (nonNull(sentAtFormat)) customizableEmailRendererBuilder.withSentAtFormat(sentAtFormat); final Function<InternetAddress, String> receiptToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getReceiptTo()); if (nonNull(receiptToFormat)) customizableEmailRendererBuilder.withReceiptToFormat(receiptToFormat); final Function<InternetAddress, String> depositionNotificationToFormat = EmailFieldFormat.emailFormatterFrom(loggingPropertiesStrategy.getDepositionNotificationTo()); if (nonNull(depositionNotificationToFormat)) customizableEmailRendererBuilder.withDepositionNotificationToFormat(depositionNotificationToFormat); if (!loggingPropertiesStrategy.areCustomHeadersIgnored()) customizableEmailRendererBuilder.includeCustomHeaders(); if (!loggingPropertiesStrategy.areNullAndEmptyCollectionsIgnored()) customizableEmailRendererBuilder.includeNullAndEmptyCollections(); return customizableEmailRendererBuilder.build(); } @Autowired  EmailRendererConfiguration(final LoggingProperties loggingProperties); @Bean EmailRenderer emailRenderer();  }