DMAAP-MR - Merge MR repos
[dmaap/messagerouter/messageservice.git] / src / test / java / org / onap / dmaap / mr / cambria / metrics / publisher / impl / DMaaPCambriaConsumerImplTest.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 package org.onap.dmaap.mr.cambria.metrics.publisher.impl;
23
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
26
27 import java.io.IOException;
28 import java.util.ArrayList;
29 import java.util.Collection;
30 import java.util.List;
31 import org.junit.After;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.onap.dmaap.dmf.mr.metrics.publisher.impl.DMaaPCambriaConsumerImpl;
35
36 public class DMaaPCambriaConsumerImplTest {
37         
38         private DMaaPCambriaConsumerImpl consumer = null; 
39         @Before
40         public void setUp() throws Exception {
41                 
42                 Collection<String> hosts = new ArrayList<String>();
43                 
44                 for (int i = 0; i < 5; i++) {
45                         hosts.add("host"+(i+1));
46                 }
47                 consumer = new DMaaPCambriaConsumerImpl(hosts, "testTopic", "consumerGroup1", "1", 2000, 200, "hi", 
48                                 "9AMFFNIZpusO54oG","6BY86UQcio2LJdgyU7Cwg5oQ");
49         }
50
51         @After
52         public void tearDown() throws Exception {
53         }
54
55         @Test
56         public void testStringToList() {
57                 
58                 List<String> response = DMaaPCambriaConsumerImpl.stringToList("Hello world, this is a test string");
59                 assertNotNull(response);
60                 
61                 
62         }
63         
64         @Test
65         public void testFetch() {
66                 
67                 Iterable<String> response = null;
68                 boolean flag = true;
69                 try {
70                         response = consumer.fetch(200, 20);
71                 } catch (IOException e) {
72                         flag = false;
73                         // TODO Auto-generated catch block
74                         e.printStackTrace();
75                 }
76                 if(flag) {
77                         assertNotNull(response);
78                 } else {
79                         assertTrue(true);
80                 }
81                 
82         }
83         
84         
85         @Test
86         public void testCreateUrlPath() {
87         
88                 String response = consumer.createUrlPath(200, 20);
89                 assertNotNull(response);
90         }
91
92
93 }