ContentWithAttachmentsHandler.java

1
package fr.sii.ogham.email.sendgrid.v2.sender.impl.sendgrid.handler;
2
3
import org.slf4j.Logger;
4
import org.slf4j.LoggerFactory;
5
6
import com.sendgrid.SendGrid;
7
8
import fr.sii.ogham.core.message.content.Content;
9
import fr.sii.ogham.email.attachment.Attachment;
10
import fr.sii.ogham.email.exception.handler.ContentHandlerException;
11
import fr.sii.ogham.email.message.Email;
12
import fr.sii.ogham.email.message.content.ContentWithAttachments;
13
14
/**
15
 * Content handler that extract {@link Attachment} that are associated to the
16
 * {@link ContentWithAttachments}.
17
 */
18
public final class ContentWithAttachmentsHandler implements SendGridContentHandler {
19
	private static final Logger LOG = LoggerFactory.getLogger(ContentWithAttachmentsHandler.class);
20
	private SendGridContentHandler delegate;
21
22
	/**
23
	 * Initialize with the {@link SendGridContentHandler} that is able to handle
24
	 * the underlying content.
25
	 * 
26
	 * @param delegate
27
	 *            the handler
28
	 */
29
	public ContentWithAttachmentsHandler(SendGridContentHandler delegate) {
30
		super();
31
		this.delegate = delegate;
32
	}
33
34
	@Override
35
	public void setContent(Email original, SendGrid.Email email, Content content) throws ContentHandlerException {
36
		ContentWithAttachments cwa = (ContentWithAttachments) content;
37
		for (Attachment attachment : cwa.getAttachments()) {
38
			LOG.debug("Attaching {} to email", attachment);
39
			original.attach(attachment);
40
		}
41 1 1. setContent : removed call to fr/sii/ogham/email/sendgrid/v2/sender/impl/sendgrid/handler/SendGridContentHandler::setContent → NO_COVERAGE
		delegate.setContent(original, email, cwa.getContent());
42
	}
43
44
}

Mutations

41

1.1
Location : setContent
Killed by : none
removed call to fr/sii/ogham/email/sendgrid/v2/sender/impl/sendgrid/handler/SendGridContentHandler::setContent → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM