9ae49e054ebc7abf1e7cc3cbd1208d43152aba92
[dmaap/messagerouter/dmaapclient.git] / src / test / java / org / onap / dmaap / mr / test / support / MRConsumerMockTest.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 package org.onap.dmaap.mr.test.support;
22
23 import static org.junit.Assert.assertTrue;
24
25 import java.io.IOException;
26 import java.util.ArrayList;
27 import java.util.concurrent.TimeUnit;
28
29 import org.junit.After;
30 import org.junit.Before;
31 import org.junit.Test;
32
33 import org.onap.dmaap.mr.client.HostSelector;
34 import org.onap.dmaap.mr.client.MRPublisher.message;
35 import org.onap.dmaap.mr.test.support.MRBatchingPublisherMock.Entry;
36
37 public class MRConsumerMockTest {
38         private MRConsumerMock cons = null;
39         private MRConsumerMock.Entry entry = null;
40
41         @Before
42         public void setUp() throws Exception {
43                 cons = new MRConsumerMock();
44                 entry = cons.new Entry(100, 200, "statusMsg");
45
46         }
47
48         @After
49         public void tearDown() throws Exception {
50
51         }
52
53         @Test
54         public void testClose() {
55
56                 cons.close();
57                 assertTrue(true);
58
59         }
60
61         @Test
62         public void testRun() {
63                 try {
64                         entry.run();
65                 } catch (IOException e) {
66                         // TODO Auto-generated catch block
67                         e.printStackTrace();
68                 }
69
70                 assertTrue(true);
71
72         }
73         
74         @Test
75         public void testSetApiCredentials() {
76                 cons.setApiCredentials("apikey", "apisecret");
77                 assertTrue(true);
78
79         }
80         
81         @Test
82         public void testClearApiCredentials() {
83                 cons.clearApiCredentials();
84                 assertTrue(true);
85
86         }
87         
88         @Test
89         public void testAdd() {
90                 cons.add(entry);
91                 assertTrue(true);
92
93         }
94         
95         @Test
96         public void testAddImmediateMsg() {
97                 cons.addImmediateMsg("ImmediateMsg");
98                 assertTrue(true);
99
100         }
101         
102         @Test
103         public void testAddDelayedMsg() {
104                 cons.addDelayedMsg(100, "msg");
105                 assertTrue(true);
106
107         }
108         
109         @Test
110         public void testAddImmediateMsgGroup() {
111                 cons.addImmediateMsgGroup(new ArrayList<String>());
112                 assertTrue(true);
113
114         }
115         
116         @Test
117         public void testAddDelayedMsgGroup() {
118                 cons.addDelayedMsgGroup(100,new ArrayList<String>());
119                 assertTrue(true);
120
121         }
122         
123         @Test
124         public void testAddImmediateError() {
125                 cons.addImmediateError(200, "OK");
126                 assertTrue(true);
127
128         }
129         
130         @Test
131         public void testFetch() {
132                 try {
133                         cons.fetch();
134                 } catch (IOException e) {
135                         // TODO Auto-generated catch block
136                         e.printStackTrace();
137                 }
138                 assertTrue(true);
139
140         }
141         
142         @Test
143         public void testFetch2() {
144                 try {
145                         cons.fetch(100, 200);
146                 } catch (IOException e) {
147                         // TODO Auto-generated catch block
148                         e.printStackTrace();
149                 }
150                 assertTrue(true);
151
152         }
153         
154         @Test
155         public void testLogTo() {
156                 cons.logTo(null);
157                 assertTrue(true);
158
159         }
160         
161         @Test
162         public void testFetchWithReturnConsumerResponse() {
163                 cons.fetchWithReturnConsumerResponse();
164                 assertTrue(true);
165
166         }
167         
168         @Test
169         public void testGetchWithReturnConsumerResponse() {
170                 cons.fetchWithReturnConsumerResponse(100,200);
171                 assertTrue(true);
172
173         }
174 }