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