CorrectPackageNameMailCompat.java

1
package fr.sii.ogham.email.sendgrid.v4.sender.impl.sendgrid.compat;
2
3
import static java.util.stream.Collectors.toList;
4
5
import java.io.IOException;
6
import java.util.List;
7
8
import com.sendgrid.helpers.mail.Mail;
9
import com.sendgrid.helpers.mail.objects.Content;
10
import com.sendgrid.helpers.mail.objects.Email;
11
import com.sendgrid.helpers.mail.objects.Personalization;
12
13
14
/**
15
 * Compatibility wrapper that wraps {@link Mail} instance and delegates
16
 * operations to it.
17
 * 
18
 * @author Aurélien Baudet
19
 * @see CompatUtil
20
 * @see CompatFactory
21
 */
22
public class CorrectPackageNameMailCompat implements MailCompat {
23
	private final Mail delegate;
24
25
	public CorrectPackageNameMailCompat() {
26
		this(new Mail());
27
	}
28
29
	public CorrectPackageNameMailCompat(Mail delegate) {
30
		super();
31
		this.delegate = delegate;
32
	}
33
34
	@Override
35
	public EmailCompat getFrom() {
36
		Email from = delegate.getFrom();
37 1 1. getFrom : negated conditional → RUN_ERROR
		if (from == null) {
38
			return null;
39
		}
40 1 1. getFrom : replaced return value with null for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::getFrom → RUN_ERROR
		return new CorrectPackageNameEmailCompat(from);
41
	}
42
43
	@Override
44
	public String getSubject() {
45 1 1. getSubject : replaced return value with "" for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::getSubject → RUN_ERROR
		return delegate.getSubject();
46
	}
47
48
	@Override
49
	public List<PersonalizationCompat> getPersonalization() {
50
		List<Personalization> personalization = delegate.getPersonalization();
51 1 1. getPersonalization : negated conditional → RUN_ERROR
		if (personalization == null) {
52 1 1. getPersonalization : replaced return value with Collections.emptyList for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::getPersonalization → RUN_ERROR
			return null;
53
		}
54 1 1. getPersonalization : replaced return value with Collections.emptyList for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::getPersonalization → RUN_ERROR
		return personalization.stream()
55
				.map(CorrectPackageNamePersonalizationCompat::new)
56
				.collect(toList());
57
	}
58
59
	@Override
60
	public void setSubject(String subject) {
61 1 1. setSubject : removed call to com/sendgrid/helpers/mail/Mail::setSubject → RUN_ERROR
		delegate.setSubject(subject);
62
	}
63
64
	@Override
65
	public void setFrom(String address, String personal) {
66 1 1. setFrom : removed call to com/sendgrid/helpers/mail/Mail::setFrom → RUN_ERROR
		delegate.setFrom(new Email(address, personal));
67
	}
68
69
	@Override
70
	public void addContent(String mime, String contentStr) {
71 1 1. addContent : removed call to com/sendgrid/helpers/mail/Mail::addContent → RUN_ERROR
		delegate.addContent(new Content(mime, contentStr));
72
	}
73
74
	@Override
75
	public void addPersonalization(PersonalizationCompat personalization) {
76 1 1. addPersonalization : removed call to com/sendgrid/helpers/mail/Mail::addPersonalization → RUN_ERROR
		delegate.addPersonalization(((CorrectPackageNamePersonalizationCompat) personalization).getDelegate());
77
	}
78
79
	@Override
80
	public void addAttachments(AttachmentsCompat attachment) {
81 1 1. addAttachments : removed call to com/sendgrid/helpers/mail/Mail::addAttachments → RUN_ERROR
		delegate.addAttachments(((CorrectPackageNameAttachmentsCompat) attachment).getDelegate());
82
	}
83
84
	@Override
85
	public String build() throws IOException {
86 1 1. build : replaced return value with "" for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::build → RUN_ERROR
		return delegate.build();
87
	}
88
89
	@SuppressWarnings("unchecked")
90
	@Override
91
	public <M> M getDelegate() {
92 1 1. getDelegate : replaced return value with null for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::getDelegate → RUN_ERROR
		return (M) delegate;
93
	}
94
}

Mutations

37

1.1
Location : getFrom
Killed by :
negated conditional → RUN_ERROR

40

1.1
Location : getFrom
Killed by :
replaced return value with null for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::getFrom → RUN_ERROR

45

1.1
Location : getSubject
Killed by :
replaced return value with "" for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::getSubject → RUN_ERROR

51

1.1
Location : getPersonalization
Killed by :
negated conditional → RUN_ERROR

52

1.1
Location : getPersonalization
Killed by :
replaced return value with Collections.emptyList for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::getPersonalization → RUN_ERROR

54

1.1
Location : getPersonalization
Killed by :
replaced return value with Collections.emptyList for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::getPersonalization → RUN_ERROR

61

1.1
Location : setSubject
Killed by :
removed call to com/sendgrid/helpers/mail/Mail::setSubject → RUN_ERROR

66

1.1
Location : setFrom
Killed by :
removed call to com/sendgrid/helpers/mail/Mail::setFrom → RUN_ERROR

71

1.1
Location : addContent
Killed by :
removed call to com/sendgrid/helpers/mail/Mail::addContent → RUN_ERROR

76

1.1
Location : addPersonalization
Killed by :
removed call to com/sendgrid/helpers/mail/Mail::addPersonalization → RUN_ERROR

81

1.1
Location : addAttachments
Killed by :
removed call to com/sendgrid/helpers/mail/Mail::addAttachments → RUN_ERROR

86

1.1
Location : build
Killed by :
replaced return value with "" for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::build → RUN_ERROR

92

1.1
Location : getDelegate
Killed by :
replaced return value with null for fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/compat/CorrectPackageNameMailCompat::getDelegate → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1