baef7be8604da101a4e689cf17c9dc30a5b759ab
[dmaap/messagerouter/msgrtr.git] / src / test / java / com / att / nsa / cambria / service / impl / BaseTransactionDbImplTest.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.cambria.service.impl;\r
22 \r
23 import static org.junit.Assert.*;\r
24 \r
25 import java.io.ByteArrayInputStream;\r
26 import java.io.IOException;\r
27 import java.io.InputStream;\r
28 \r
29 import com.att.dmf.mr.CambriaApiException;\r
30 import com.att.dmf.mr.backends.ConsumerFactory.UnavailableException;\r
31 import com.att.dmf.mr.beans.DMaaPContext;\r
32 import com.att.dmf.mr.metabroker.Broker.TopicExistsException;\r
33 import com.att.dmf.mr.service.impl.BaseTransactionDbImpl;\r
34 import com.att.dmf.mr.transaction.DMaaPTransactionObjDB.KeyExistsException;\r
35 import com.att.nsa.configs.ConfigDbException;\r
36 import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;\r
37 import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
38 \r
39 import org.junit.After;\r
40 import org.junit.Before;\r
41 import org.junit.Test;\r
42 \r
43 public class BaseTransactionDbImplTest {\r
44 \r
45         @Before\r
46         public void setUp() throws Exception {\r
47         }\r
48 \r
49         @After\r
50         public void tearDown() throws Exception {\r
51         }\r
52         \r
53         @Test\r
54         public void testCreateTransactionObj() {\r
55                 \r
56                 \r
57                 try {\r
58                         \r
59                         BaseTransactionDbImpl service = new BaseTransactionDbImpl(null, null);\r
60                         service.createTransactionObj("transition");\r
61                 } catch (org.json.JSONException e) {\r
62                         // TODO Auto-generated catch block\r
63                         e.printStackTrace();\r
64                 } catch (NullPointerException e) {\r
65                         // TODO Auto-generated catch block\r
66                         //e.printStackTrace();\r
67                         assertTrue(true);\r
68                 } catch (KeyExistsException e) {\r
69                         // TODO Auto-generated catch block\r
70                         e.printStackTrace();\r
71                 } catch (ConfigDbException e) {\r
72                         // TODO Auto-generated catch block\r
73                         e.printStackTrace();\r
74                 }               \r
75                 \r
76                 String trueValue = "True";\r
77                 assertTrue(trueValue.equalsIgnoreCase("True"));\r
78                 \r
79         }\r
80         \r
81         @Test\r
82         public void testSaveTransactionObj() {\r
83                 \r
84                 \r
85                 try {\r
86                         \r
87                         BaseTransactionDbImpl service = new BaseTransactionDbImpl(null, null);\r
88                         service.saveTransactionObj(null);\r
89                 } catch (org.json.JSONException e) {\r
90                         // TODO Auto-generated catch block\r
91                         e.printStackTrace();\r
92                 } catch (NullPointerException e) {\r
93                         // TODO Auto-generated catch block\r
94                         //e.printStackTrace();\r
95                         assertTrue(true);\r
96                 } catch (ConfigDbException e) {\r
97                         // TODO Auto-generated catch block\r
98                         e.printStackTrace();\r
99                 }               \r
100                 \r
101                 String trueValue = "True";\r
102                 assertTrue(trueValue.equalsIgnoreCase("True"));\r
103                 \r
104         }\r
105         \r
106         @Test\r
107         public void testLoadTransactionObj() {\r
108                 \r
109                 try {\r
110                         \r
111                         BaseTransactionDbImpl service = new BaseTransactionDbImpl(null, null);\r
112                         service.loadTransactionObj("34");\r
113                 } catch (org.json.JSONException e) {\r
114                         // TODO Auto-generated catch block\r
115                         e.printStackTrace();\r
116                 } catch (NullPointerException e) {\r
117                         // TODO Auto-generated catch block\r
118                         //e.printStackTrace();\r
119                         assertTrue(true);\r
120                 } catch (ConfigDbException e) {\r
121                         // TODO Auto-generated catch block\r
122                         e.printStackTrace();\r
123                 }               \r
124                 \r
125                 String trueValue = "True";\r
126                 assertTrue(trueValue.equalsIgnoreCase("True"));\r
127                 \r
128         }\r
129         \r
130 \r
131         @Test\r
132         public void testLoadAllTransactionObjs() {\r
133                 \r
134                 try {\r
135                         \r
136                         BaseTransactionDbImpl service = new BaseTransactionDbImpl(null, null);\r
137                         service.loadAllTransactionObjs();\r
138                 } catch (org.json.JSONException e) {\r
139                         // TODO Auto-generated catch block\r
140                         e.printStackTrace();\r
141                 } catch (NullPointerException e) {\r
142                         // TODO Auto-generated catch block\r
143                         //e.printStackTrace();\r
144                         assertTrue(true);\r
145                 } catch (ConfigDbException e) {\r
146                         // TODO Auto-generated catch block\r
147                         e.printStackTrace();\r
148                 }               \r
149                 \r
150                 String trueValue = "True";\r
151                 assertTrue(trueValue.equalsIgnoreCase("True"));\r
152                 \r
153         }\r
154 \r
155 \r
156         \r
157         \r
158 }\r