2 * ============LICENSE_START====================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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====================================================
22 package org.onap.aaf.auth.actions.test;
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;
38 import static org.mockito.Mockito.*;
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;
47 import org.junit.Test;
49 public class JU_Email {
51 private ByteArrayOutputStream outStream;
52 private ByteArrayOutputStream errStream;
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));
66 usersI = mock(Identity.class);
72 public void testClear() {
73 Assert.assertNotNull(email.clear());
77 public void testIndent() {
78 email.indent("indent");
82 public void testPreamble() {
83 email.preamble("format");
87 public void testAddTo() {
90 // Collection col = mock(Collection.class);
98 public void testAddCC() {
100 email.addCC("email");
104 // public void testAdd() throws OrganizationException {
105 // email.add(usersI, true);
109 public void testSubject() {
110 email.subject("format");
111 email.subject("for%smat","format");
115 public void testSignature() {
116 email.signature("format","arg");
120 public void testMsg() {
125 public void testExec() {
126 AuthzTrans trans = mock(AuthzTrans.class);
127 Organization org = mock(Organization.class);
128 email.preamble("format");
130 email.signature("format","arg");
132 email.exec(trans, org, "text");
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");
146 public void cleanUp() {
147 System.setErr(System.err);
148 System.setOut(System.out);