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.files; |
21 |
|
|
22 |
|
import javax.inject.Provider; |
23 |
|
import javax.mail.MessagingException; |
24 |
|
|
25 |
|
import org.junit.Rule; |
26 |
|
import org.junit.Test; |
27 |
|
import org.xwiki.component.manager.ComponentManager; |
28 |
|
import org.xwiki.component.util.DefaultParameterizedType; |
29 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
30 |
|
|
31 |
|
import static org.junit.Assert.assertEquals; |
32 |
|
import static org.junit.Assert.fail; |
33 |
|
import static org.mockito.Mockito.when; |
34 |
|
|
35 |
|
|
36 |
|
@link |
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.33 |
|
41 |
|
public class SerializedFilesMimeMessageFactoryTest |
42 |
|
{ |
43 |
|
@Rule |
44 |
|
public MockitoComponentMockingRule<SerializedFilesMimeMessageFactory> mocker = |
45 |
|
new MockitoComponentMockingRule<>(SerializedFilesMimeMessageFactory.class); |
46 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
47 |
1 |
@Test... |
48 |
|
public void createMessageWhenNoExecution() throws Exception |
49 |
|
{ |
50 |
1 |
Provider<ComponentManager> componentManagerProvider = this.mocker.registerMockComponent( |
51 |
|
new DefaultParameterizedType(null, Provider.class, ComponentManager.class), "context"); |
52 |
1 |
when(componentManagerProvider.get()).thenReturn(this.mocker); |
53 |
|
|
54 |
1 |
try { |
55 |
1 |
this.mocker.getComponentUnderTest().createMessage("batchId", null); |
56 |
0 |
fail("Should have thrown an exception"); |
57 |
|
} catch (MessagingException expected) { |
58 |
1 |
assertEquals("Failed to find an Environment Component", expected.getMessage()); |
59 |
|
} |
60 |
|
} |
61 |
|
} |