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