DMAAP-MR - Merge MR repos
[dmaap/messagerouter/messageservice.git] / src / test / java / org / onap / dmaap / mr / cambria / service / impl / TransactionServiceImplTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 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.dmaap.mr.cambria.service.impl;
24
25 import com.att.aft.dme2.internal.jettison.json.JSONException;
26 import com.att.nsa.configs.ConfigDbException;
27 import org.junit.After;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
31 import org.onap.dmaap.dmf.mr.service.impl.TransactionServiceImpl;
32 import org.onap.dmaap.dmf.mr.transaction.TransactionObj;
33
34 import java.io.IOException;
35
36 import static org.junit.Assert.assertTrue;
37
38 public class TransactionServiceImplTest {
39
40         @Before
41         public void setUp() throws Exception {
42         }
43
44         @After
45         public void tearDown() throws Exception {
46         }
47         
48         @Test
49         public void testCheckTransaction() {
50                 
51                 TransactionServiceImpl service = new TransactionServiceImpl();
52                 service.checkTransaction(new TransactionObj("23", 1100, 1000, 10));             
53                 
54                 String trueValue = "True";
55                 assertTrue(trueValue.equalsIgnoreCase("True"));
56                 
57         }
58         
59         @Test
60         public void testGetAllTransactionObjs() {
61                 
62                 TransactionServiceImpl service = new TransactionServiceImpl();
63                 try {
64                         service.getAllTransactionObjs(new DMaaPContext());
65                 } catch (ConfigDbException | IOException e) {
66                         // TODO Auto-generated catch block
67                         e.printStackTrace();
68                 }               
69                 
70                 String trueValue = "True";
71                 assertTrue(trueValue.equalsIgnoreCase("True"));
72                 
73         }
74         
75         @Test
76         public void testGetTransactionObj() {
77                 
78                 TransactionServiceImpl service = new TransactionServiceImpl();
79                 try {
80                         service.getTransactionObj(new DMaaPContext(), "23");
81                 } catch (ConfigDbException | IOException e) {
82                         // TODO Auto-generated catch block
83                         e.printStackTrace();
84                 } catch (JSONException e) {
85                         // TODO Auto-generated catch block
86                         e.printStackTrace();
87                 }               
88                 
89                 String trueValue = "True";
90                 assertTrue(trueValue.equalsIgnoreCase("True"));
91                 
92         }
93         
94         
95 }