1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.mail

File MailStateTest.java

 
parseWhenUnknownStateString: Invalid mail state [unknown]
 

Code metrics

0
17
8
1
94
58
8
0.47
2.12
8
1

Classes

Class Line # Actions
MailStateTest 34 17 0% 8 7
0.7272%
 

Contributing tests

This file is covered by 7 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.mail;
21   
22    import org.junit.Rule;
23    import org.junit.Test;
24    import org.junit.rules.ExpectedException;
25   
26    import static org.junit.Assert.assertEquals;
27   
28    /**
29    * Unit tests for {@link org.xwiki.mail.MailState}.
30    *
31    * @version $Id: 668b1ec25a8094596caeb24e44c761f93c635e27 $
32    * @since 6.4
33    */
 
34    public class MailStateTest
35    {
36    @Rule
37    public ExpectedException thrown = ExpectedException.none();
38   
 
39  0 toggle @Test
40    public void parseWhenUnknownStateString()
41    {
42  0 this.thrown.expect(IllegalArgumentException.class);
43  0 this.thrown.expectMessage("Invalid mail state [unknown]");
44  0 Test failure here MailState.parse("unknown");
45    }
46   
 
47  1 toggle @Test
48    public void parseWhenOldFailedState()
49    {
50  1 MailState state = MailState.parse("failed");
51  1 assertEquals(MailState.SEND_ERROR, state);
52    }
53   
 
54  1 toggle @Test
55    public void parseWhenPrepareSuccessState()
56    {
57  1 MailState state = MailState.parse("prepare_success");
58  1 assertEquals(MailState.PREPARE_SUCCESS, state);
59    }
60   
 
61  0 toggle public void parseWhenPrepareErrorsState()
62    {
63  0 MailState state = MailState.parse("prepare_error");
64  0 assertEquals(MailState.PREPARE_ERROR, state);
65    }
66   
 
67  1 toggle @Test
68    public void parseWhenSendSuccessState()
69    {
70  1 MailState state = MailState.parse("send_success");
71  1 assertEquals(MailState.SEND_SUCCESS, state);
72    }
73   
 
74  1 toggle @Test
75    public void parseWhenSendErrorLowercase()
76    {
77  1 MailState state = MailState.parse("send_error");
78  1 assertEquals(MailState.SEND_ERROR, state);
79    }
80   
 
81  1 toggle @Test
82    public void parseWhenSendErrorStateUppercase()
83    {
84  1 MailState state = MailState.parse("SEND_ERROR");
85  1 assertEquals(MailState.SEND_ERROR, state);
86    }
87   
 
88  1 toggle @Test
89    public void parseWhenSendFatalErrorState()
90    {
91  1 MailState state = MailState.parse("send_fatal_error");
92  1 assertEquals(MailState.SEND_FATAL_ERROR, state);
93    }
94    }