including missing files
[dmaap/dbcapi.git] / src / test / java / org / onap / dmaap / dbcapi / service / MR_ClientServiceTest.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.service;
21 import  org.onap.dmaap.dbcapi.model.*;
22
23 import static org.junit.Assert.*;
24
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
28 import java.util.List;
29 import java.util.ArrayList;
30
31 public class MR_ClientServiceTest {
32
33         private static final String  fmt = "%24s: %s%n";
34         
35         private static DmaapObjectFactory factory = new DmaapObjectFactory();
36
37         ReflectionHarness rh = new ReflectionHarness();
38
39         private TopicService ts;
40         private MR_ClusterService mcs;
41         private MR_ClientService cls;
42         private DcaeLocationService dls;
43
44         private String f;
45         private String locname;
46
47         @Before
48         public void setUp() throws Exception {
49                 ts = new TopicService();
50                 mcs = new MR_ClusterService();
51                 cls = new MR_ClientService();
52                 f = "mrsn01.onap.org";
53                 locname = "central-demo";
54
55                 dls = new DcaeLocationService();
56                 DcaeLocation loc = factory.genDcaeLocation( "central" );
57                 dls.addDcaeLocation( loc );
58
59                 ApiError err = new ApiError();
60                 String[] h = { "zplvm009.onap.org", "zplvm007.onap.org", "zplvm008.onap.org" };
61                 MR_Cluster node = factory.genMR_Cluster( "central" );
62                 MR_Cluster n2 = mcs.addMr_Cluster( node, err ); 
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.service.MR_ClientService", "get", null );    
75         
76         }
77
78         @Test
79         public void test2() {
80                 String v = "Validate";
81                 rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClientService", "set", v );
82
83         }
84
85         @Test
86         public void test3() {
87                 Topic topic = factory.genSimpleTopic( "test3" );
88                 ApiError err = new ApiError();
89                 Topic nTopic = ts.addTopic( topic, err );
90                 if ( nTopic != null ) {
91                         assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
92                 }
93                 String[] actions = { "pub", "view" };
94                 MR_Client c = factory.genPublisher( "edge",  topic.getFqtn() );
95
96                 c = cls.addMr_Client( c, topic, err );
97
98         }
99
100         @Test
101         public void test4() {
102                 List<MR_Client> l = cls.getAllMr_Clients();
103
104                 ArrayList<MR_Client> al = cls.getAllMrClients( "foo" );
105
106                 ArrayList<MR_Client> al2 = cls.getClientsByLocation( "central" );
107         }
108
109         @Test
110         public void test5() {
111                 Topic topic = factory.genSimpleTopic( "test5" );
112                 ApiError err = new ApiError();
113                 Topic nTopic = ts.addTopic( topic, err );
114                 if ( nTopic != null ) {
115                         assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
116                 }
117                 MR_Client c = factory.genPublisher( "edge", topic.getFqtn() );
118
119                 c = cls.addMr_Client( c, topic, err );
120                 if ( c != null ) {
121                                 c = factory.genSubscriber( "edge", topic.getFqtn() );
122                                 c = cls.updateMr_Client( c, err );
123                                 assertTrue( err.getCode() == 200 );
124                 }
125         }
126
127 }