[AAF-21] Initial code import
[aaf/authz.git] / authz-certman / src / test / java / com / att / authz / cm / api / JU_API_Cert.java
1 /*******************************************************************************\r
2  * ============LICENSE_START====================================================\r
3  * * org.onap.aai\r
4  * * ===========================================================================\r
5  * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * * Copyright © 2017 Amdocs\r
7  * * ===========================================================================\r
8  * * Licensed under the Apache License, Version 2.0 (the "License");\r
9  * * you may not use this file except in compliance with the License.\r
10  * * You may obtain a copy of the License at\r
11  * * \r
12  *  *      http://www.apache.org/licenses/LICENSE-2.0\r
13  * * \r
14  *  * Unless required by applicable law or agreed to in writing, software\r
15  * * distributed under the License is distributed on an "AS IS" BASIS,\r
16  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
17  * * See the License for the specific language governing permissions and\r
18  * * limitations under the License.\r
19  * * ============LICENSE_END====================================================\r
20  * *\r
21  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
22  * *\r
23  ******************************************************************************/\r
24 package com.att.authz.cm.api;\r
25 \r
26 import static org.junit.Assert.*;\r
27 import static org.mockito.Mockito.mock;\r
28 \r
29 import javax.servlet.http.HttpServletRequest;\r
30 import javax.servlet.http.HttpServletResponse;\r
31 \r
32 import org.junit.BeforeClass;\r
33 import org.junit.Rule;\r
34 import org.junit.Test;\r
35 import org.junit.rules.ExpectedException;\r
36 import org.junit.runner.RunWith;\r
37 import org.mockito.Mock;\r
38 import org.mockito.runners.MockitoJUnitRunner;\r
39 \r
40 import com.att.authz.cm.service.CertManAPI;\r
41 import com.att.authz.env.AuthzTrans;\r
42 ;\r
43 \r
44 @RunWith(MockitoJUnitRunner.class)\r
45 public class JU_API_Cert {\r
46         \r
47         @Mock\r
48         private static API_Cert api;\r
49         \r
50         @Mock\r
51         private static CertManAPI certManApi;\r
52         \r
53         private static CertManAPI noMockAPI;\r
54         private static API_Cert api_1;\r
55         \r
56         private static HttpServletRequest req;\r
57         private static HttpServletResponse res;\r
58         \r
59         @BeforeClass\r
60         public static void setUp() {\r
61                 AuthzTrans trans = mock(AuthzTrans.class);\r
62                 req = mock(HttpServletRequest.class);\r
63                 trans.setProperty("testTag", "UserValue");\r
64                 trans.set(req);\r
65         }\r
66         \r
67         @Rule\r
68     public ExpectedException thrown= ExpectedException.none();\r
69         \r
70         @Test\r
71         public void init_bothValued() {\r
72                 try {\r
73                         api.init(certManApi);\r
74                 } catch (Exception e) {\r
75                         //thrown.expect(NullPointerException.class);\r
76                         e.printStackTrace();\r
77                 }\r
78         }\r
79         \r
80         @Test\r
81         public void init_Null_() {\r
82                 try {\r
83                         api.init(null);\r
84                 } catch (Exception e) {\r
85                         //thrown.expect(Exception.class);\r
86                         e.printStackTrace();\r
87                 }\r
88         }\r
89         \r
90         @Test\r
91         public void init_NMC_Null() {\r
92                 try {\r
93                         api_1.init(null);\r
94                 } catch (Exception e) {\r
95                         //thrown.expect(NullPointerException.class);\r
96                         e.printStackTrace();\r
97                 }\r
98         }\r
99         \r
100         @Test\r
101         public void init_NMC() {\r
102                 try {\r
103                         api_1.init(noMockAPI);\r
104                 } catch (Exception e) {\r
105                         //thrown.expect(NullPointerException.class);\r
106                         e.printStackTrace();\r
107                 }\r
108         }\r
109 }\r