496329750f11bde03cfe3ab033d65df78ce00f75
[aaf/authz.git] / auth / auth-certman / src / test / java / org / onap / aaf / auth / cm / api / JU_API_Cert.java
1 /*******************************************************************************
2  * ============LICENSE_START====================================================
3  * * org.onap.aaf
4  * * ===========================================================================
5  * * Copyright © 2017 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
23 package org.onap.aaf.auth.cm.api;
24
25 import static org.junit.Assert.*;
26 import static org.mockito.Mockito.mock;
27
28 import javax.servlet.http.HttpServletRequest;
29 import javax.servlet.http.HttpServletResponse;
30
31 import org.junit.BeforeClass;
32 import org.junit.Rule;
33 import org.junit.Test;
34 import org.junit.rules.ExpectedException;
35 import org.junit.runner.RunWith;
36 import org.mockito.Mock;
37 import org.mockito.runners.MockitoJUnitRunner;
38 import org.onap.aaf.auth.cm.AAF_CM;
39 import org.onap.aaf.auth.cm.api.API_Cert;
40 import org.onap.aaf.auth.env.AuthzTrans;
41 ;
42
43 @RunWith(MockitoJUnitRunner.class)
44 public class JU_API_Cert {
45     
46     @Mock
47     private static API_Cert api;
48     
49     @Mock
50     private static AAF_CM certManApi;
51     
52     private static AAF_CM noMockAPI;
53     private static API_Cert api_1;
54     
55     private static HttpServletRequest req;
56     private static HttpServletResponse res;
57     
58     @BeforeClass
59     public static void setUp() {
60         AuthzTrans trans = mock(AuthzTrans.class);
61         req = mock(HttpServletRequest.class);
62         trans.setProperty("testTag", "UserValue");
63         trans.set(req);
64     }
65     
66     @Rule
67     public ExpectedException thrown= ExpectedException.none();
68     
69     @Test
70     public void init_bothValued() {
71         try {
72             api.init(certManApi);
73         } catch (Exception e) {
74             //thrown.expect(NullPointerException.class);
75             e.printStackTrace();
76         }
77     }
78     
79     @Test
80     public void init_Null_() {
81         try {
82             api.init(null);
83         } catch (Exception e) {
84             //thrown.expect(Exception.class);
85             e.printStackTrace();
86         }
87     }
88     
89     @Test
90     public void init_NMC_Null() {
91         try {
92             api_1.init(null);
93         } catch (Exception e) {
94             //thrown.expect(NullPointerException.class);
95             e.printStackTrace();
96         }
97     }
98     
99     @Test
100     public void init_NMC() {
101         try {
102             api_1.init(noMockAPI);
103         } catch (Exception e) {
104             //thrown.expect(NullPointerException.class);
105             e.printStackTrace();
106         }
107     }
108 }