Refactor code to support no AAF requests
[dmaap/dbcapi.git] / src / test / java / org / onap / dmaap / dbcapi / database / TableHandlerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.dmaap
4  * ================================================================================
5  * Copyright (C) 2018 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 package org.onap.dmaap.dbcapi.database;
21
22 import org.onap.dmaap.dbcapi.database.ConnectionFactory;
23 import org.onap.dmaap.dbcapi.database.DBFieldHandler;
24 import org.onap.dmaap.dbcapi.database.TableHandler;
25 import org.onap.dmaap.dbcapi.model.*;
26 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
27
28 import static org.junit.Assert.*;
29
30 import org.junit.After;
31 import org.junit.Before;
32 import org.junit.Test;
33 import java.util.*;
34 import java.sql.*;
35
36 public class TableHandlerTest {
37
38         private static final String  fmt = "%24s: %s%n";
39
40         ReflectionHarness rh = new ReflectionHarness();
41
42    private static class TopicReplicationTypeHandler implements DBFieldHandler.SqlOp {
43         public Object get(ResultSet rs, int index) throws Exception {
44             int val = rs.getInt(index);
45
46             return (ReplicationType.valueOf(val));
47         }
48         public void set(PreparedStatement ps, int index, Object val) throws Exception {
49             if (val == null) {
50                 ps.setInt(index, 0);
51                 return;
52             }
53             @SuppressWarnings("unchecked")
54             ReplicationType rep = (ReplicationType) val;
55             ps.setInt(index, rep.getValue());
56         }
57     }
58
59
60
61         @Before
62         public void setUp() throws Exception {
63         }
64
65         @After
66         public void tearDown() throws Exception {
67         }
68
69
70         @Test
71         public void test1() {
72
73
74                 //rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );      
75         
76         }
77
78         @Test
79         public void test2() {
80                 String v = "Validate";
81                 //rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.MrTopicConnection", "set", v );
82
83         }
84
85         @Test
86         public void test3() {
87                 TableHandler.setSpecialCase("topic", "replication_case", new TopicReplicationTypeHandler());
88
89                 try {
90                 ConnectionFactory cf = new ConnectionFactory();
91                 TableHandler th = new TableHandler( cf, TopicReplicationTypeHandler.class, "foo", "bar" );
92                 } catch (Exception e ) {
93                 }
94                 try {
95                 ConnectionFactory cf = new ConnectionFactory();
96                 TableHandler th = new TableHandler( TopicReplicationTypeHandler.class, "foo", "bar" );
97                 th.getSpecialCase( "foo", "bar" );
98                 } catch (Exception e ) {
99                 }
100
101         }
102
103
104
105 }
106