ea6535a2d4d80206adeaeb93fb8cdd80a3bc413d
[dmaap/messagerouter/messageservice.git] / src / test / java / com / att / nsa / dmaap / service / UIRestServicesTest.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP Policy Engine\r
4  * ================================================================================\r
5  * Copyright (C) 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 \r
21 package com.att.nsa.dmaap.service;\r
22 \r
23 import static org.junit.Assert.*;\r
24 \r
25 import java.lang.reflect.InvocationTargetException;\r
26 import java.lang.reflect.Method;\r
27 \r
28 import org.junit.After;\r
29 import org.junit.Before;\r
30 import org.junit.Test;\r
31 \r
32 import org.onap.dmaap.dmf.mr.CambriaApiException;\r
33 import com.att.nsa.configs.ConfigDbException;\r
34 import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
35 \r
36 public class UIRestServicesTest {\r
37 \r
38         private UIRestServices service = null;\r
39 \r
40         @Before\r
41         public void setUp() throws Exception {\r
42                 service = new UIRestServices();\r
43         }\r
44 \r
45         @After\r
46         public void tearDown() throws Exception {\r
47         }\r
48 \r
49         @Test\r
50         public void testHello() {\r
51 \r
52                 try {\r
53                         service.hello();\r
54                 } catch (NullPointerException e) {\r
55                         assertTrue(true);\r
56                 }\r
57                 assertTrue(true);\r
58         }\r
59         \r
60         @Test\r
61         public void testGetApiKeysTable() {\r
62 \r
63                 try {\r
64                         service.getApiKeysTable();\r
65                 } catch (NullPointerException e) {\r
66                         assertTrue(true);\r
67                 }\r
68                 assertTrue(true);\r
69         }\r
70         \r
71 \r
72         @Test\r
73         public void testGetApiKey() {\r
74 \r
75                 try {\r
76                         service.getApiKey("apikey");\r
77                 } catch (NullPointerException e) {\r
78                         assertTrue(true);\r
79                 }\r
80                 assertTrue(true);\r
81         }\r
82         \r
83         @Test\r
84         public void testGetTopicsTable() {\r
85 \r
86                 try {\r
87                         service.getTopicsTable();\r
88                 } catch (NullPointerException e) {\r
89                         assertTrue(true);\r
90                 }\r
91                 assertTrue(true);\r
92         }\r
93         \r
94         @Test\r
95         public void testGetTopic() {\r
96 \r
97                 try {\r
98                         service.getTopic("topicName");\r
99                 } catch (NullPointerException e) {\r
100                         assertTrue(true);\r
101                 }\r
102                 assertTrue(true);\r
103         }\r
104         \r
105         @Test\r
106         public void testGetDmaapContext() {\r
107                 Class clazz = null;\r
108                 Method method = null;\r
109                 try {\r
110                         clazz = Class.forName("UIRestServices");\r
111                         Object obj = clazz.newInstance();\r
112                         method = clazz.getDeclaredMethod("getDmaapContext", null);\r
113                         method.setAccessible(true);\r
114                         method.invoke(obj, null);\r
115                 } catch (ClassNotFoundException e) {\r
116                         // TODO Auto-generated catch block\r
117                         e.printStackTrace();\r
118                 } catch (NoSuchMethodException e) {\r
119                         // TODO Auto-generated catch block\r
120                         e.printStackTrace();\r
121                 } catch (SecurityException e) {\r
122                         // TODO Auto-generated catch block\r
123                         e.printStackTrace();\r
124                 } catch (InstantiationException e) {\r
125                         // TODO Auto-generated catch block\r
126                         e.printStackTrace();\r
127                 } catch (IllegalAccessException e) {\r
128                         // TODO Auto-generated catch block\r
129                         e.printStackTrace();\r
130                 } catch (IllegalArgumentException e) {\r
131                         // TODO Auto-generated catch block\r
132                         e.printStackTrace();\r
133                 } catch (InvocationTargetException e) {\r
134                         // TODO Auto-generated catch block\r
135                         e.printStackTrace();\r
136                 }\r
137 \r
138                 assertTrue(true);\r
139         }\r
140         \r
141 \r
142 }