[DMAAP-CLIENT] First sonar issues review part2
[dmaap/messagerouter/dmaapclient.git] / src / test / java / org / onap / dmaap / mr / client / MRClientFactoryTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  *  Modifications Copyright © 2018 IBM.
8  *  Modifications Copyright © 2021 Orange.
9  * ================================================================================
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.dmaap.mr.client;
25
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Test;
29
30 import java.io.IOException;
31 import java.util.ArrayList;
32 import java.util.Collection;
33
34 import static org.junit.Assert.assertTrue;
35
36
37 public class MRClientFactoryTest {
38
39     private Collection<String> hostSet = new ArrayList<String>();
40
41     private String[] hostArray = new String[10];
42
43     @Before
44     public void setUp() throws Exception {
45
46         for (int i = 0; i < 10; i++) {
47             hostSet.add("host" + (i + 1));
48             hostArray[i] = "host" + (i + 1);
49         }
50     }
51
52     @After
53     public void tearDown() throws Exception {
54
55     }
56
57     @Test
58     public void testCreateConsumer() {
59
60         MRClientFactory.createConsumer("hostList hostList2", "testTopic");
61         assertTrue(true);
62
63     }
64
65     @Test
66     public void testCreateConsumer2() {
67
68         MRClientFactory.createConsumer(hostSet, "testTopic");
69         assertTrue(true);
70
71     }
72
73     @Test
74     public void testCreateConsumer3() {
75         MRClientFactory.createConsumer(hostSet, "testTopic", "filter");
76         assertTrue(true);
77     }
78
79     @Test
80     public void testCreateConsumer4() {
81         MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22");
82         assertTrue(true);
83     }
84
85     @Test
86     public void testCreateConsumer5() {
87         MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100);
88         assertTrue(true);
89     }
90
91     @Test
92     public void testCreateConsumer6() {
93         MRClientFactory.createConsumer("hostList", "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
94         assertTrue(true);
95     }
96
97     @Test
98     public void testCreateConsumer7() {
99         MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
100         assertTrue(true);
101     }
102
103     @Test
104     public void testCreateSimplePublisher() {
105         MRClientFactory.createSimplePublisher("hostList", "testTopic");
106         assertTrue(true);
107     }
108
109     @Test
110     public void testCreateBatchingPublisher1() {
111         MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10);
112         assertTrue(true);
113     }
114
115     @Test
116     public void testCreateBatchingPublisher2() {
117         MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10, true);
118         assertTrue(true);
119     }
120
121     @Test
122     public void testCreateBatchingPublisher3() {
123         MRClientFactory.createBatchingPublisher(hostArray, "testTopic", 100, 10, true);
124         assertTrue(true);
125     }
126
127     @Test
128     public void testCreateBatchingPublisher4() {
129         MRClientFactory.createBatchingPublisher(hostSet, "testTopic", 100, 10, true);
130         assertTrue(true);
131     }
132
133     @Test
134     public void testCreateBatchingPublisher5() {
135         MRClientFactory.createBatchingPublisher("host", "testTopic", "username", "password", 100, 10, true,
136                 "protocolFlag");
137         assertTrue(true);
138     }
139
140     @Test(expected = IOException.class)
141     public void testCreateBatchingPublisher6() throws IOException {
142         MRClientFactory.createBatchingPublisher("/producer");
143     }
144
145     @Test(expected = IOException.class)
146     public void testCreateBatchingPublisher7() throws IOException {
147         MRClientFactory.createBatchingPublisher("/producer", true);
148     }
149
150     @Test
151     public void testCreateIdentityManager() {
152         MRClientFactory.createIdentityManager(hostSet, "apikey", "apisecret");
153         assertTrue(true);
154     }
155
156     @Test
157     public void testCreateTopicManager() {
158         MRClientFactory.createTopicManager(hostSet, "apikey", "apisecret");
159         assertTrue(true);
160     }
161
162     @Test(expected = IOException.class)
163     public void testCreateConsumer8() throws IOException {
164         MRClientFactory.createConsumer("/consumer");
165     }
166
167     @Test
168     public void testCreateConsumer9() {
169         MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", "protocolFlag",
170                 "/consumer", 1, 2);
171         assertTrue(true);
172     }
173
174     @Test
175     public void testCreateConsumer10() {
176         MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", 1, 2, "protocolFlag",
177                 "/consumer");
178         assertTrue(true);
179     }
180
181     @Test
182     public void test$testInject() {
183         MRClientFactory.$testInject(null);
184         assertTrue(true);
185     }
186
187 }