More unit tests to pass 50%
[dmaap/dbcapi.git] / src / test / java / org / onap / dmaap / dbcapi / aaf / client / DrProvConnectionTest.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.aaf.client;
21
22 import org.onap.dmaap.dbcapi.model.*;
23 import org.onap.dmaap.dbcapi.service.*;
24 import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
25 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
26
27 import static org.junit.Assert.*;
28
29 import org.junit.After;
30 import org.junit.Before;
31 import org.junit.Test;
32 import java.util.List;
33 import java.util.ArrayList;
34 import java.io.InputStream;
35 import java.io.FileInputStream;
36 import java.io.FileNotFoundException;
37
38 public class DrProvConnectionTest {
39
40         private static final String  fmt = "%24s: %s%n";
41         private static DmaapObjectFactory factory = new DmaapObjectFactory();
42
43         ReflectionHarness rh = new ReflectionHarness();
44
45         DrProvConnection ns;
46         MR_ClusterService mcs;
47         TopicService ts;
48
49         @Before
50         public void setUp() throws Exception {
51                 ns = new DrProvConnection();
52         }
53
54         @After
55         public void tearDown() throws Exception {
56         }
57
58
59         @Test
60         public void test1() {
61
62
63                 rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.DrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" ); 
64         
65         }
66
67         @Test
68         public void test2() {
69                 String v = "Validate";
70                 rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.DrProvConnection", "set", v );
71
72         }
73
74         @Test
75         public void test3() {
76                 String locname = "central-demo";
77
78                 DcaeLocationService dls = new DcaeLocationService();
79                 DcaeLocation loc = factory.genDcaeLocation( "central" );
80                 dls.addDcaeLocation( loc );
81
82                 ApiError err = new ApiError();
83                 String[] hl = { "host1", "host2", "host3" };
84                 ns.makeFeedConnection( );
85                 ns.makeFeedConnection( "01" );
86                 ns.makeSubPostConnection( "part0/part1/part2/part3/part4" );
87                 ns.makeSubPutConnection( "44" );
88                 ns.makeIngressConnection( "01", "aUser", "10.10.10.10", "aNode" );
89                 ns.makeEgressConnection( "01", "aNode" );
90                 ns.makeNodesConnection( "someVar" );
91                 Feed feed = new Feed( "dgl feed 1" ,
92                                 "v1.0",
93                                 "dgl feed 1 for testing",
94                                 "TEST",
95                                 "unclassified"
96                     );
97             ArrayList<DR_Pub> pubs = new ArrayList<DR_Pub>();
98             pubs.add( new DR_Pub( "central-demo" ) );
99             feed.setPubs(pubs);
100
101                 String resp = ns.doPostFeed( feed, err );
102                 resp = ns.doPutFeed( feed, err );
103                 resp = ns.doDeleteFeed( feed, err );
104
105                 int i = ns.doXgressPost( err );
106
107                 DR_Sub sub = factory.genDrSub( "central", feed.getFeedId() );
108                 assertTrue( sub != null );
109                 String sr = ns.doPostDr_Sub( sub, err );
110                 /*
111                  * TODO:
112                         - create a new DR_Sub based on a simulated response
113                         - update using ns.doPutDr_Sub( sub, err );
114                  */
115         }
116
117         @Test
118         public void test4() {
119                 ApiError err = new ApiError();
120                 String resp = ns.doGetNodes( err );
121                 ns.makeNodesConnection( "someVar", "host1|host2" );
122                 resp = ns.doPutNodes( err );
123                 try {
124                         InputStream is = new FileInputStream( "./etc/dmaapbc.properties" );                             
125                         String body = ns.bodyToString( is );
126                 } catch ( FileNotFoundException fnfe ) {
127                 }
128         }
129
130 }
131