| 1 | package fr.sii.ogham.email.message.fluent; | |
| 2 | ||
| 3 | import java.io.File; | |
| 4 | import java.io.IOException; | |
| 5 | import java.io.InputStream; | |
| 6 | import java.nio.file.Path; | |
| 7 | import java.util.ArrayList; | |
| 8 | import java.util.List; | |
| 9 | ||
| 10 | import fr.sii.ogham.core.resource.FileResource; | |
| 11 | import fr.sii.ogham.core.resource.LookupResource; | |
| 12 | import fr.sii.ogham.core.resource.OverrideNameWrapper; | |
| 13 | import fr.sii.ogham.core.resource.path.ResourcePath; | |
| 14 | import fr.sii.ogham.core.resource.path.UnresolvedPath; | |
| 15 | import fr.sii.ogham.email.attachment.Attachment; | |
| 16 | import fr.sii.ogham.email.attachment.ContentDisposition; | |
| 17 | import fr.sii.ogham.email.message.Email; | |
| 18 | ||
| 19 | /** | |
| 20 | * Fluent API to attach a file to the email. | |
| 21 | * | |
| 22 | * @author Aurélien Baudet | |
| 23 | * @since 3.0.0 | |
| 24 | */ | |
| 25 | public class AttachBuilder { | |
| 26 | private final Email parent; | |
| 27 | private final List<Attachment> attachments; | |
| 28 | ||
| 29 | /** | |
| 30 | * Initializes with the parent to go back to. | |
| 31 | * | |
| 32 | * @param parent | |
| 33 | * the parent instance | |
| 34 | */ | |
| 35 | public AttachBuilder(Email parent) { | |
| 36 | super(); | |
| 37 | this.parent = parent; | |
| 38 | this.attachments = new ArrayList<>(); | |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * Attach a file to the email. The name of the attachment uses the name of | |
| 43 | * the file. | |
| 44 | * | |
| 45 | * <p> | |
| 46 | * The disposition of the attachment is set to | |
| 47 | * {@link ContentDisposition#ATTACHMENT}. | |
| 48 | * | |
| 49 | * <p> | |
| 50 | * The Content-Type of the attachment is automatically determined. | |
| 51 | * | |
| 52 | * @param file | |
| 53 | * the file to attach | |
| 54 | * @return the email instance for fluent chaining | |
| 55 | */ | |
| 56 | public Email file(File file) { | |
| 57 |
2
1. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → NO_COVERAGE 2. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → KILLED |
return file(file, null); |
| 58 | } | |
| 59 | ||
| 60 | /** | |
| 61 | * Attach a file to the email. The name of the attachment uses the name of | |
| 62 | * the file. | |
| 63 | * | |
| 64 | * <p> | |
| 65 | * The disposition of the attachment is set to | |
| 66 | * {@link ContentDisposition#ATTACHMENT}. | |
| 67 | * | |
| 68 | * <p> | |
| 69 | * The Content-Type of the attachment is explicitly set. | |
| 70 | * | |
| 71 | * @param file | |
| 72 | * the file to attach | |
| 73 | * @param contentType | |
| 74 | * the Content-Type of the attachment | |
| 75 | * @return the email instance for fluent chaining | |
| 76 | */ | |
| 77 | public Email file(File file, String contentType) { | |
| 78 |
2
1. file : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → NO_COVERAGE 2. file : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → KILLED |
attach(new Attachment(file), contentType); |
| 79 |
2
1. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → NO_COVERAGE 2. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → KILLED |
return parent; |
| 80 | } | |
| 81 | ||
| 82 | /** | |
| 83 | * Attach a file to the email. The name of the attachment is explicitly | |
| 84 | * specified. | |
| 85 | * | |
| 86 | * <p> | |
| 87 | * The disposition of the attachment is set to | |
| 88 | * {@link ContentDisposition#ATTACHMENT}. | |
| 89 | * | |
| 90 | * <p> | |
| 91 | * The Content-Type of the attachment is automatically determined. | |
| 92 | * | |
| 93 | * @param customName | |
| 94 | * the name to use for the attachment | |
| 95 | * @param file | |
| 96 | * the file to attach | |
| 97 | * @return the email instance for fluent chaining | |
| 98 | */ | |
| 99 | public Email file(String customName, File file) { | |
| 100 |
1
1. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → NO_COVERAGE |
return file(customName, file, null); |
| 101 | } | |
| 102 | ||
| 103 | /** | |
| 104 | * Attach a file to the email. The name of the attachment is explicitly | |
| 105 | * specified. | |
| 106 | * | |
| 107 | * <p> | |
| 108 | * The disposition of the attachment is set to | |
| 109 | * {@link ContentDisposition#ATTACHMENT}. | |
| 110 | * | |
| 111 | * <p> | |
| 112 | * The Content-Type of the attachment is explicitly set. | |
| 113 | * | |
| 114 | * @param customName | |
| 115 | * the name to use for the attachment | |
| 116 | * @param file | |
| 117 | * the file to attach | |
| 118 | * @param contentType | |
| 119 | * the Content-Type of the attachment | |
| 120 | * @return the email instance for fluent chaining | |
| 121 | */ | |
| 122 | public Email file(String customName, File file, String contentType) { | |
| 123 |
2
1. file : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → NO_COVERAGE 2. file : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → KILLED |
attach(new Attachment(new FileResource(file, customName)), contentType); |
| 124 |
2
1. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → NO_COVERAGE 2. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → KILLED |
return parent; |
| 125 | } | |
| 126 | ||
| 127 | /** | |
| 128 | * Attach a file to the email. The name of the attachment uses the name of | |
| 129 | * the file. | |
| 130 | * | |
| 131 | * <p> | |
| 132 | * The disposition of the attachment is set to | |
| 133 | * {@link ContentDisposition#ATTACHMENT}. | |
| 134 | * | |
| 135 | * <p> | |
| 136 | * The Content-Type of the attachment is automatically determined. | |
| 137 | * | |
| 138 | * @param path | |
| 139 | * the path to the file to attach | |
| 140 | * @return the email instance for fluent chaining | |
| 141 | */ | |
| 142 | public Email file(Path path) { | |
| 143 |
1
1. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → NO_COVERAGE |
return file(path, null); |
| 144 | } | |
| 145 | ||
| 146 | /** | |
| 147 | * Attach a file to the email. The name of the attachment uses the name of | |
| 148 | * the file. | |
| 149 | * | |
| 150 | * <p> | |
| 151 | * The disposition of the attachment is set to | |
| 152 | * {@link ContentDisposition#ATTACHMENT}. | |
| 153 | * | |
| 154 | * <p> | |
| 155 | * The Content-Type of the attachment is explicitly set. | |
| 156 | * | |
| 157 | * @param path | |
| 158 | * the path to the file to attach | |
| 159 | * @param contentType | |
| 160 | * the Content-Type of the attachment | |
| 161 | * @return the email instance for fluent chaining | |
| 162 | */ | |
| 163 | public Email file(Path path, String contentType) { | |
| 164 |
1
1. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → NO_COVERAGE |
return file(path.toFile(), contentType); |
| 165 | } | |
| 166 | ||
| 167 | /** | |
| 168 | * Attach a file to the email. The name of the attachment is explicitly | |
| 169 | * specified. | |
| 170 | * | |
| 171 | * <p> | |
| 172 | * The disposition of the attachment is set to | |
| 173 | * {@link ContentDisposition#ATTACHMENT}. | |
| 174 | * | |
| 175 | * <p> | |
| 176 | * The Content-Type of the attachment is automatically determined. | |
| 177 | * | |
| 178 | * @param customName | |
| 179 | * the name to use for the attachment | |
| 180 | * @param path | |
| 181 | * the path to the file to attach | |
| 182 | * @return the email instance for fluent chaining | |
| 183 | */ | |
| 184 | public Email file(String customName, Path path) { | |
| 185 |
1
1. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → NO_COVERAGE |
return file(customName, path, null); |
| 186 | } | |
| 187 | ||
| 188 | /** | |
| 189 | * Attach a file to the email. The name of the attachment is explicitly | |
| 190 | * specified. | |
| 191 | * | |
| 192 | * <p> | |
| 193 | * The disposition of the attachment is set to | |
| 194 | * {@link ContentDisposition#ATTACHMENT}. | |
| 195 | * | |
| 196 | * <p> | |
| 197 | * The Content-Type of the attachment is explicitly set. | |
| 198 | * | |
| 199 | * @param customName | |
| 200 | * the name to use for the attachment | |
| 201 | * @param path | |
| 202 | * the path to the file to attach | |
| 203 | * @param contentType | |
| 204 | * the Content-Type of the attachment | |
| 205 | * @return the email instance for fluent chaining | |
| 206 | */ | |
| 207 | public Email file(String customName, Path path, String contentType) { | |
| 208 |
1
1. file : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::file → NO_COVERAGE |
return file(customName, path.toFile(), contentType); |
| 209 | } | |
| 210 | ||
| 211 | /** | |
| 212 | * Attach a resource loaded from a path to the email. The name of the | |
| 213 | * attachment uses the name of the resource (extracted from the path). | |
| 214 | * | |
| 215 | * <p> | |
| 216 | * The path may contain the lookup prefix (a prefix that indicates where to | |
| 217 | * find the resource). For example: | |
| 218 | * <ul> | |
| 219 | * <li><code>"classpath:/path/to/file.pdf"</code> references a resource that | |
| 220 | * is located at "path/to/file.pdf" in the classpath (from the root)</li> | |
| 221 | * <li><code>"file:/path/to/file.pdf"</code> references a resource that is | |
| 222 | * located at "/path/to/file.pdf" in the file system</li> | |
| 223 | * </ul> | |
| 224 | * By default, if the path doesn't contain any lookup prefix then the | |
| 225 | * resource is loaded from the root of the classpath. | |
| 226 | * | |
| 227 | * <p> | |
| 228 | * The disposition of the attachment is set to | |
| 229 | * {@link ContentDisposition#ATTACHMENT}. | |
| 230 | * | |
| 231 | * <p> | |
| 232 | * The Content-Type of the attachment is automatically determined. | |
| 233 | * | |
| 234 | * @param path | |
| 235 | * the path to the resource to attach | |
| 236 | * @return the email instance for fluent chaining | |
| 237 | */ | |
| 238 | public Email resource(String path) { | |
| 239 |
2
1. resource : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → NO_COVERAGE 2. resource : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → KILLED |
attach(new Attachment(path), null); |
| 240 |
2
1. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → NO_COVERAGE 2. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → KILLED |
return parent; |
| 241 | } | |
| 242 | ||
| 243 | /** | |
| 244 | * Attach a resource loaded from a path to the email. The name of the | |
| 245 | * attachment is explicitly set. | |
| 246 | * | |
| 247 | * <p> | |
| 248 | * The path may contain the lookup prefix (a prefix that indicates where to | |
| 249 | * find the resource). For example: | |
| 250 | * <ul> | |
| 251 | * <li><code>"classpath:/path/to/file.pdf"</code> references a resource that | |
| 252 | * is located at "path/to/file.pdf" in the classpath (from the root)</li> | |
| 253 | * <li><code>"file:/path/to/file.pdf"</code> references a resource that is | |
| 254 | * located at "/path/to/file.pdf" in the file system</li> | |
| 255 | * </ul> | |
| 256 | * By default, if the path doesn't contain any lookup prefix then the | |
| 257 | * resource is loaded from the root of the classpath. | |
| 258 | * | |
| 259 | * <p> | |
| 260 | * The disposition of the attachment is set to | |
| 261 | * {@link ContentDisposition#ATTACHMENT}. | |
| 262 | * | |
| 263 | * <p> | |
| 264 | * The Content-Type of the attachment is automatically determined. | |
| 265 | * | |
| 266 | * @param customName | |
| 267 | * the name to use for the attachment | |
| 268 | * @param path | |
| 269 | * the path to the resource to attach | |
| 270 | * @return the email instance for fluent chaining | |
| 271 | */ | |
| 272 | public Email resource(String customName, String path) { | |
| 273 |
2
1. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → NO_COVERAGE 2. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → KILLED |
return resource(customName, path, null); |
| 274 | } | |
| 275 | ||
| 276 | /** | |
| 277 | * Attach a resource loaded from a path to the email. The name of the | |
| 278 | * attachment is explicitly set. | |
| 279 | * | |
| 280 | * <p> | |
| 281 | * The path may contain the lookup prefix (a prefix that indicates where to | |
| 282 | * find the resource). For example: | |
| 283 | * <ul> | |
| 284 | * <li><code>"classpath:/path/to/file.pdf"</code> references a resource that | |
| 285 | * is located at "path/to/file.pdf" in the classpath (from the root)</li> | |
| 286 | * <li><code>"file:/path/to/file.pdf"</code> references a resource that is | |
| 287 | * located at "/path/to/file.pdf" in the file system</li> | |
| 288 | * </ul> | |
| 289 | * By default, if the path doesn't contain any lookup prefix then the | |
| 290 | * resource is loaded from the root of the classpath. | |
| 291 | * | |
| 292 | * <p> | |
| 293 | * The disposition of the attachment is set to | |
| 294 | * {@link ContentDisposition#ATTACHMENT}. | |
| 295 | * | |
| 296 | * <p> | |
| 297 | * The Content-Type of the attachment is explicitly set. | |
| 298 | * | |
| 299 | * @param customName | |
| 300 | * the name to use for the attachment | |
| 301 | * @param path | |
| 302 | * the path to the resource to attach | |
| 303 | * @param contentType | |
| 304 | * the Content-Type of the attachment | |
| 305 | * @return the email instance for fluent chaining | |
| 306 | */ | |
| 307 | public Email resource(String customName, String path, String contentType) { | |
| 308 |
2
1. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → NO_COVERAGE 2. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → KILLED |
return resource(customName, new UnresolvedPath(path), contentType); |
| 309 | } | |
| 310 | ||
| 311 | /** | |
| 312 | * Attach a resource loaded from a path to the email. The name of the | |
| 313 | * attachment uses the name of the resource (extracted from the path). | |
| 314 | * | |
| 315 | * <p> | |
| 316 | * The path may contain the lookup prefix (a prefix that indicates where to | |
| 317 | * find the resource). For example: | |
| 318 | * <ul> | |
| 319 | * <li><code>"classpath:/path/to/file.pdf"</code> references a resource that | |
| 320 | * is located at "path/to/file.pdf" in the classpath (from the root)</li> | |
| 321 | * <li><code>"file:/path/to/file.pdf"</code> references a resource that is | |
| 322 | * located at "/path/to/file.pdf" in the file system</li> | |
| 323 | * </ul> | |
| 324 | * By default, if the path doesn't contain any lookup prefix then the | |
| 325 | * resource is loaded from the root of the classpath. | |
| 326 | * | |
| 327 | * <p> | |
| 328 | * The disposition of the attachment is set to | |
| 329 | * {@link ContentDisposition#ATTACHMENT}. | |
| 330 | * | |
| 331 | * <p> | |
| 332 | * The Content-Type of the attachment is automatically determined. | |
| 333 | * | |
| 334 | * @param path | |
| 335 | * the path to the resource to attach | |
| 336 | * @return the email instance for fluent chaining | |
| 337 | */ | |
| 338 | public Email resource(ResourcePath path) { | |
| 339 |
1
1. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → NO_COVERAGE |
return resource(path, null); |
| 340 | } | |
| 341 | ||
| 342 | /** | |
| 343 | * Attach a resource loaded from a path to the email. The name of the | |
| 344 | * attachment uses the name of the resource (extracted from the path). | |
| 345 | * | |
| 346 | * <p> | |
| 347 | * The path may contain the lookup prefix (a prefix that indicates where to | |
| 348 | * find the resource). For example: | |
| 349 | * <ul> | |
| 350 | * <li><code>"classpath:/path/to/file.pdf"</code> references a resource that | |
| 351 | * is located at "path/to/file.pdf" in the classpath (from the root)</li> | |
| 352 | * <li><code>"file:/path/to/file.pdf"</code> references a resource that is | |
| 353 | * located at "/path/to/file.pdf" in the file system</li> | |
| 354 | * </ul> | |
| 355 | * By default, if the path doesn't contain any lookup prefix then the | |
| 356 | * resource is loaded from the root of the classpath. | |
| 357 | * | |
| 358 | * <p> | |
| 359 | * The disposition of the attachment is set to | |
| 360 | * {@link ContentDisposition#ATTACHMENT}. | |
| 361 | * | |
| 362 | * <p> | |
| 363 | * The Content-Type of the attachment is explicitly set. | |
| 364 | * | |
| 365 | * @param path | |
| 366 | * the path to the resource to attach | |
| 367 | * @param contentType | |
| 368 | * the Content-Type of the attachment | |
| 369 | * @return the email instance for fluent chaining | |
| 370 | */ | |
| 371 | public Email resource(ResourcePath path, String contentType) { | |
| 372 |
1
1. resource : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → NO_COVERAGE |
attach(new Attachment(path), contentType); |
| 373 |
1
1. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → NO_COVERAGE |
return parent; |
| 374 | } | |
| 375 | ||
| 376 | /** | |
| 377 | * Attach a resource loaded from a path to the email. The name of the | |
| 378 | * attachment is explicitly set. | |
| 379 | * | |
| 380 | * <p> | |
| 381 | * The path may contain the lookup prefix (a prefix that indicates where to | |
| 382 | * find the resource). For example: | |
| 383 | * <ul> | |
| 384 | * <li><code>"classpath:/path/to/file.pdf"</code> references a resource that | |
| 385 | * is located at "path/to/file.pdf" in the classpath (from the root)</li> | |
| 386 | * <li><code>"file:/path/to/file.pdf"</code> references a resource that is | |
| 387 | * located at "/path/to/file.pdf" in the file system</li> | |
| 388 | * </ul> | |
| 389 | * By default, if the path doesn't contain any lookup prefix then the | |
| 390 | * resource is loaded from the root of the classpath. | |
| 391 | * | |
| 392 | * <p> | |
| 393 | * The disposition of the attachment is set to | |
| 394 | * {@link ContentDisposition#ATTACHMENT}. | |
| 395 | * | |
| 396 | * <p> | |
| 397 | * The Content-Type of the attachment is automatically determined. | |
| 398 | * | |
| 399 | * @param customName | |
| 400 | * the name to use for the attachment | |
| 401 | * @param path | |
| 402 | * the path to the resource to attach | |
| 403 | * @return the email instance for fluent chaining | |
| 404 | */ | |
| 405 | public Email resource(String customName, ResourcePath path) { | |
| 406 |
1
1. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → NO_COVERAGE |
return resource(customName, path, null); |
| 407 | } | |
| 408 | ||
| 409 | /** | |
| 410 | * Attach a resource loaded from a path to the email. The name of the | |
| 411 | * attachment is explicitly set. | |
| 412 | * | |
| 413 | * <p> | |
| 414 | * The path may contain the lookup prefix (a prefix that indicates where to | |
| 415 | * find the resource). For example: | |
| 416 | * <ul> | |
| 417 | * <li><code>"classpath:/path/to/file.pdf"</code> references a resource that | |
| 418 | * is located at "path/to/file.pdf" in the classpath (from the root)</li> | |
| 419 | * <li><code>"file:/path/to/file.pdf"</code> references a resource that is | |
| 420 | * located at "/path/to/file.pdf" in the file system</li> | |
| 421 | * </ul> | |
| 422 | * By default, if the path doesn't contain any lookup prefix then the | |
| 423 | * resource is loaded from the root of the classpath. | |
| 424 | * | |
| 425 | * <p> | |
| 426 | * The disposition of the attachment is set to | |
| 427 | * {@link ContentDisposition#ATTACHMENT}. | |
| 428 | * | |
| 429 | * <p> | |
| 430 | * The Content-Type of the attachment is explicitly set. | |
| 431 | * | |
| 432 | * @param customName | |
| 433 | * the name to use for the attachment | |
| 434 | * @param path | |
| 435 | * the path to the resource to attach | |
| 436 | * @param contentType | |
| 437 | * the Content-Type of the attachment | |
| 438 | * @return the email instance for fluent chaining | |
| 439 | */ | |
| 440 | public Email resource(String customName, ResourcePath path, String contentType) { | |
| 441 |
2
1. resource : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → NO_COVERAGE 2. resource : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → KILLED |
attach(new Attachment(new OverrideNameWrapper(new LookupResource(path), customName)), contentType); |
| 442 |
2
1. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → NO_COVERAGE 2. resource : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::resource → KILLED |
return parent; |
| 443 | } | |
| 444 | ||
| 445 | /** | |
| 446 | * Attach a resource to the email directly using the bytes. The name of the | |
| 447 | * attachment must be explicitly set. | |
| 448 | * | |
| 449 | * <p> | |
| 450 | * The disposition of the attachment is set to | |
| 451 | * {@link ContentDisposition#ATTACHMENT}. | |
| 452 | * | |
| 453 | * <p> | |
| 454 | * The Content-Type of the attachment is automatically determined. | |
| 455 | * | |
| 456 | * @param attachmentName | |
| 457 | * the name of the attachment | |
| 458 | * @param bytes | |
| 459 | * the content of the attachment | |
| 460 | * @return the email instance for fluent chaining | |
| 461 | */ | |
| 462 | public Email bytes(String attachmentName, byte[] bytes) { | |
| 463 |
2
1. bytes : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::bytes → NO_COVERAGE 2. bytes : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::bytes → KILLED |
return bytes(attachmentName, bytes, null); |
| 464 | } | |
| 465 | ||
| 466 | /** | |
| 467 | * Attach a resource to the email directly using the bytes. The name of the | |
| 468 | * attachment must be explicitly set. | |
| 469 | * | |
| 470 | * <p> | |
| 471 | * The disposition of the attachment is set to | |
| 472 | * {@link ContentDisposition#ATTACHMENT}. | |
| 473 | * | |
| 474 | * <p> | |
| 475 | * The Content-Type of the attachment is explicitly set. | |
| 476 | * | |
| 477 | * @param attachmentName | |
| 478 | * the name of the attachment | |
| 479 | * @param bytes | |
| 480 | * the content of the attachment | |
| 481 | * @param contentType | |
| 482 | * the Content-Type of the attachment | |
| 483 | * @return the email instance for fluent chaining | |
| 484 | */ | |
| 485 | public Email bytes(String attachmentName, byte[] bytes, String contentType) { | |
| 486 |
2
1. bytes : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → NO_COVERAGE 2. bytes : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → KILLED |
attach(new Attachment(attachmentName, bytes), contentType); |
| 487 |
2
1. bytes : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::bytes → NO_COVERAGE 2. bytes : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::bytes → KILLED |
return parent; |
| 488 | } | |
| 489 | ||
| 490 | /** | |
| 491 | * Attach a resource to the email directly using the bytes read from the | |
| 492 | * {@link InputStream}. The {@link InputStream} is immediately read and | |
| 493 | * converted to a byte array. The name of the attachment must be explicitly | |
| 494 | * set. | |
| 495 | * | |
| 496 | * <p> | |
| 497 | * <strong>IMPORTANT:</strong> You need to manually close the stream. | |
| 498 | * | |
| 499 | * <p> | |
| 500 | * The disposition of the attachment is set to | |
| 501 | * {@link ContentDisposition#ATTACHMENT}. | |
| 502 | * | |
| 503 | * <p> | |
| 504 | * The Content-Type of the attachment is automatically determined. | |
| 505 | * | |
| 506 | * @param attachmentName | |
| 507 | * the name of the attachment | |
| 508 | * @param stream | |
| 509 | * the content of the attachment | |
| 510 | * @return the email instance for fluent chaining | |
| 511 | * @throws IOException | |
| 512 | * when the {@link InputStream} can't be read | |
| 513 | */ | |
| 514 | public Email stream(String attachmentName, InputStream stream) throws IOException { | |
| 515 |
2
1. stream : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::stream → NO_COVERAGE 2. stream : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::stream → KILLED |
return stream(attachmentName, stream, null); |
| 516 | } | |
| 517 | ||
| 518 | /** | |
| 519 | * Attach a resource to the email directly using the bytes read from the | |
| 520 | * {@link InputStream}. The {@link InputStream} is immediately read and | |
| 521 | * converted to a byte array. The name of the attachment must be explicitly | |
| 522 | * set. | |
| 523 | * | |
| 524 | * <p> | |
| 525 | * <strong>IMPORTANT:</strong> You need to manually close the stream. | |
| 526 | * | |
| 527 | * <p> | |
| 528 | * The disposition of the attachment is set to | |
| 529 | * {@link ContentDisposition#ATTACHMENT}. | |
| 530 | * | |
| 531 | * <p> | |
| 532 | * The Content-Type of the attachment is explicitly set. | |
| 533 | * | |
| 534 | * @param attachmentName | |
| 535 | * the name of the attachment | |
| 536 | * @param stream | |
| 537 | * the content of the attachment | |
| 538 | * @param contentType | |
| 539 | * the Content-Type of the attachment | |
| 540 | * @return the email instance for fluent chaining | |
| 541 | * @throws IOException | |
| 542 | * when the {@link InputStream} can't be read | |
| 543 | */ | |
| 544 | public Email stream(String attachmentName, InputStream stream, String contentType) throws IOException { | |
| 545 |
2
1. stream : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → NO_COVERAGE 2. stream : removed call to fr/sii/ogham/email/message/fluent/AttachBuilder::attach → KILLED |
attach(new Attachment(attachmentName, stream), contentType); |
| 546 |
2
1. stream : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::stream → NO_COVERAGE 2. stream : replaced return value with null for fr/sii/ogham/email/message/fluent/AttachBuilder::stream → KILLED |
return parent; |
| 547 | } | |
| 548 | ||
| 549 | /** | |
| 550 | * Provides the list of attachments. | |
| 551 | * | |
| 552 | * @return the list of attachments | |
| 553 | */ | |
| 554 | public List<Attachment> build() { | |
| 555 |
5
1. build : replaced return value with Collections.emptyList for fr/sii/ogham/email/message/fluent/AttachBuilder::build → NO_COVERAGE 2. build : replaced return value with Collections.emptyList for fr/sii/ogham/email/message/fluent/AttachBuilder::build → SURVIVED 3. build : replaced return value with Collections.emptyList for fr/sii/ogham/email/message/fluent/AttachBuilder::build → TIMED_OUT 4. build : replaced return value with Collections.emptyList for fr/sii/ogham/email/message/fluent/AttachBuilder::build → KILLED 5. build : replaced return value with Collections.emptyList for fr/sii/ogham/email/message/fluent/AttachBuilder::build → KILLED |
return attachments; |
| 556 | } | |
| 557 | ||
| 558 | private void attach(Attachment attachment, String contentType) { | |
| 559 |
3
1. attach : removed call to fr/sii/ogham/email/attachment/Attachment::setContentType → NO_COVERAGE 2. attach : removed call to fr/sii/ogham/email/attachment/Attachment::setContentType → SURVIVED 3. attach : removed call to fr/sii/ogham/email/attachment/Attachment::setContentType → KILLED |
attachment.setContentType(contentType); |
| 560 | attachments.add(attachment); | |
| 561 | } | |
| 562 | } | |
Mutations | ||
| 57 |
1.1 2.2 |
|
| 78 |
1.1 2.2 |
|
| 79 |
1.1 2.2 |
|
| 100 |
1.1 |
|
| 123 |
1.1 2.2 |
|
| 124 |
1.1 2.2 |
|
| 143 |
1.1 |
|
| 164 |
1.1 |
|
| 185 |
1.1 |
|
| 208 |
1.1 |
|
| 239 |
1.1 2.2 |
|
| 240 |
1.1 2.2 |
|
| 273 |
1.1 2.2 |
|
| 308 |
1.1 2.2 |
|
| 339 |
1.1 |
|
| 372 |
1.1 |
|
| 373 |
1.1 |
|
| 406 |
1.1 |
|
| 441 |
1.1 2.2 |
|
| 442 |
1.1 2.2 |
|
| 463 |
1.1 2.2 |
|
| 486 |
1.1 2.2 |
|
| 487 |
1.1 2.2 |
|
| 515 |
1.1 2.2 |
|
| 545 |
1.1 2.2 |
|
| 546 |
1.1 2.2 |
|
| 555 |
1.1 2.2 3.3 4.4 5.5 |
|
| 559 |
1.1 2.2 3.3 |