add testcases
[dmaap/messagerouter/msgrtr.git] / src / test / java / org / onap / dmaap / mr / cambria / resources / CambriaOutboundEventStreamTest.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.cambria.resources;
22
23 import static org.junit.Assert.*;
24
25 import java.io.IOException;
26
27 import org.json.JSONException;
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31
32 import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
33 import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
34 import org.onap.dmaap.dmf.mr.resources.CambriaOutboundEventStream;
35 import org.onap.dmaap.dmf.mr.resources.CambriaOutboundEventStream.operation;
36
37 public class CambriaOutboundEventStreamTest {
38
39         private CambriaOutboundEventStream coes = null;
40         
41         @Before
42         public void setUp() throws Exception {
43                 coes = new CambriaOutboundEventStream.Builder(null).timeout(10).limit(1).filter(CambriaConstants.kNoFilter)
44                                 .pretty(false).withMeta(true).build();
45                 DMaaPContext ctx = new DMaaPContext();
46                 //ctx.set...
47                 coes.setDmaapContext(ctx);
48                 coes.setTopic(null);
49                 coes.setTransEnabled(true);
50                 coes.setTopicStyle(true);
51         }
52
53         @After
54         public void tearDown() throws Exception {
55         }
56
57         @Test
58         public void testGetSentCount() {
59                 int sentCount = coes.getSentCount();
60                 assertTrue("Doesn't match, got " + sentCount, sentCount==0);;
61         }
62
63         @Test
64         public void testWrite() {
65                 //fail("Not yet implemented");
66         }
67
68         @Test
69         public void testForEachMessage() {
70                 try {
71                         coes.forEachMessage(new operation(){
72
73                                 @Override
74                                 public void onWait() throws IOException {
75                                         // TODO Auto-generated method stub
76                                         
77                                 }
78
79                                 @Override
80                                 public void onMessage(int count, String msg, String transId, long offSet)
81                                                 throws IOException, JSONException {
82                                         // TODO Auto-generated method stub
83                                         
84                                 }
85                                 
86                         });
87                 } catch (Exception e) {
88                         // TODO Auto-generated catch block
89                 } 
90         }
91
92         @Test
93         public void testGetDmaapContext() {
94                 DMaaPContext ctx = coes.getDmaapContext();
95                 
96                 assertNotNull(ctx);
97         }
98
99         @Test
100         public void testSetDmaapContext() {
101                 DMaaPContext ctx = new DMaaPContext();
102                 coes.setDmaapContext(ctx);
103                 assertTrue(ctx.equals(coes.getDmaapContext()));
104         }
105
106         @Test
107         public void testGetTopic() {
108                 coes.getTopic();
109                 assertTrue(true);
110         }
111
112         @Test
113         public void testSetTopic() {
114                 //fail("Not yet implemented");
115         }
116
117         @Test
118         public void testSetTopicStyle() {
119                 coes.setTopicStyle(true);
120                 assertTrue(true);
121         }
122
123         @Test
124         public void testSetTransEnabled() {
125                 coes.setTransEnabled(true);
126                 assertTrue(true);
127         }
128
129 }