Merge "Fix sonar issues in Mapper1_0"
[aaf/authz.git] / auth / auth-batch / src / test / java / org / onap / aaf / auth / actions / test / JU_Email.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
4  * ===========================================================================
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6  * ===========================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END====================================================
19  *
20  */
21
22 package org.onap.aaf.auth.actions.test;
23
24 import static org.junit.Assert.*;
25 import org.junit.After;
26 import org.junit.Assert;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.mockito.Mock;
30 import org.mockito.Mockito;
31 import org.onap.aaf.auth.actions.Email;
32 import org.onap.aaf.auth.actions.Message;
33 import org.onap.aaf.auth.env.AuthzTrans;
34 import org.onap.aaf.auth.org.Organization.Identity;
35 import org.onap.aaf.auth.org.Organization;
36 import org.onap.aaf.auth.org.OrganizationException;
37
38 import static org.mockito.Mockito.*;
39
40 import java.io.ByteArrayOutputStream;
41 import java.io.FileNotFoundException;
42 import java.io.PrintStream;
43 import java.util.Collection;
44 import java.util.Hashtable;
45 import java.util.Set;
46
47 import org.junit.Test;
48
49 public class JU_Email {
50         
51         private ByteArrayOutputStream outStream;
52         private ByteArrayOutputStream errStream;
53         Email email;
54         Identity usersI;
55         Message msg;
56         PrintStream ps;
57         
58         @Before
59         public void setUp() throws FileNotFoundException {
60                 outStream = new ByteArrayOutputStream();
61                 errStream = new ByteArrayOutputStream();
62                 ps = new PrintStream(errStream);
63                 System.setOut(new PrintStream(outStream));
64                 System.setErr(ps);
65                 
66                 usersI = mock(Identity.class);
67                 msg = new Message();
68                 email = new Email();
69         }
70
71         @Test
72         public void testClear() {
73                 Assert.assertNotNull(email.clear());
74         }
75         
76         @Test
77         public void testIndent() {
78                 email.indent("indent");
79         }
80         
81         @Test
82         public void testPreamble() {
83                 email.preamble("format");
84         }
85         
86         @Test
87         public void testAddTo() {
88                 email.addTo(usersI);
89                 
90 //              Collection col = mock(Collection.class);
91 //              col.add("test");
92 //              email.addTo(col);
93                 
94                 email.addTo("email");
95         }
96         
97         @Test
98         public void testAddCC() {
99                 email.addCC(usersI);
100                 email.addCC("email");
101         }
102         
103 //      @Test
104 //      public void testAdd() throws OrganizationException {
105 //              email.add(usersI, true);
106 //      }
107         
108         @Test
109         public void testSubject() {
110                 email.subject("format");
111                 email.subject("for%smat","format");
112         }
113         
114         @Test
115         public void testSignature() {
116                 email.signature("format","arg");
117         }
118         
119         @Test
120         public void testMsg() {
121                 email.msg(msg);
122         }
123         
124         @Test
125         public void testExec() {
126                 AuthzTrans trans = mock(AuthzTrans.class);
127                 Organization org = mock(Organization.class);
128                 email.preamble("format");
129                 email.msg(msg);
130                 email.signature("format","arg");
131                 
132                 email.exec(trans, org, "text");
133         }
134         
135         @Test
136         public void testLog() throws FileNotFoundException {
137                 email.addTo("email");
138                 email.addCC("email");
139                 email.log(ps, "email");
140                 email.addTo("emails");
141                 email.addCC("emails");
142                 email.log(ps, "emails");
143         }
144         
145         @After
146         public void cleanUp() {
147                 System.setErr(System.err);
148                 System.setOut(System.out);
149         }
150
151 }