| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.mail.internal.factory.text; |
| 21 |
|
|
| 22 |
|
import java.util.Collections; |
| 23 |
|
import java.util.HashMap; |
| 24 |
|
import java.util.Map; |
| 25 |
|
|
| 26 |
|
import javax.mail.internet.MimeBodyPart; |
| 27 |
|
|
| 28 |
|
import org.junit.Rule; |
| 29 |
|
import org.junit.Test; |
| 30 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
| 31 |
|
|
| 32 |
|
import static org.junit.Assert.assertArrayEquals; |
| 33 |
|
import static org.junit.Assert.assertEquals; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
@link |
| 37 |
|
|
| 38 |
|
@version |
| 39 |
|
@since |
| 40 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
| 41 |
|
public class TextMimeBodyPartFactoryTest |
| 42 |
|
{ |
| 43 |
|
@Rule |
| 44 |
|
public MockitoComponentMockingRule<TextMimeBodyPartFactory> mocker = |
| 45 |
|
new MockitoComponentMockingRule<>(TextMimeBodyPartFactory.class); |
| 46 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 47 |
1 |
@Test... |
| 48 |
|
public void createWithoutMimeTypePassed() throws Exception |
| 49 |
|
{ |
| 50 |
1 |
MimeBodyPart bodyPart = this.mocker.getComponentUnderTest().create("Lorem ipsum", |
| 51 |
|
Collections.<String, Object>emptyMap()); |
| 52 |
|
|
| 53 |
1 |
assertEquals("Lorem ipsum", bodyPart.getContent()); |
| 54 |
1 |
assertEquals("text/plain; charset=UTF-8", bodyPart.getContentType()); |
| 55 |
|
} |
| 56 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 57 |
1 |
@Test... |
| 58 |
|
public void createWithMimeTypePassedAndWithHeaders() throws Exception |
| 59 |
|
{ |
| 60 |
1 |
Map<String, Object> parameters = new HashMap<>(); |
| 61 |
1 |
parameters.put("headers", Collections.singletonMap("Content-Transfer-Encoding", "quoted-printable")); |
| 62 |
1 |
parameters.put("mimetype", "text/calendar"); |
| 63 |
|
|
| 64 |
1 |
MimeBodyPart bodyPart = this.mocker.getComponentUnderTest().create("Lorem ipsum", parameters); |
| 65 |
|
|
| 66 |
1 |
assertEquals("Lorem ipsum", bodyPart.getContent()); |
| 67 |
1 |
assertEquals("text/calendar", bodyPart.getContentType()); |
| 68 |
1 |
assertArrayEquals(new String[]{ "quoted-printable" }, bodyPart.getHeader("Content-Transfer-Encoding")); |
| 69 |
|
} |
| 70 |
|
} |