bump the version
[dmaap/messagerouter/msgrtr.git] / src / test / java / org / onap / dmaap / mr / cambria / service / impl / ShowConsumerCacheTest.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.service.impl;
22 import static org.junit.Assert.assertEquals;
23 import static org.mockito.Matchers.anyBoolean;
24 import static org.mockito.Matchers.anyInt;
25 import static org.mockito.Matchers.anyString;
26 import static org.mockito.Mockito.mock;
27 import static org.mockito.Mockito.times;
28 import static org.mockito.Mockito.verify;
29 import static org.mockito.Mockito.when;
30
31 import java.io.IOException;
32 import java.util.Arrays;
33 import java.util.Collection;
34 import java.util.HashSet;
35 import java.util.Iterator;
36
37 import javax.servlet.http.HttpServletRequest;
38 import javax.servlet.http.HttpServletResponse;
39
40 import org.junit.Assert;
41 import org.junit.Before;
42 import org.junit.Test;
43 import org.junit.runner.RunWith;
44 import org.mockito.InjectMocks;
45 import org.mockito.Mock;
46 import org.mockito.MockitoAnnotations;
47 import org.powermock.api.mockito.PowerMockito;
48 import org.powermock.core.classloader.annotations.PrepareForTest;
49 import org.powermock.modules.junit4.PowerMockRunner;
50 import org.mockito.runners.MockitoJUnitRunner;
51
52 import com.att.aft.dme2.internal.jettison.json.JSONArray;
53 import com.att.aft.dme2.internal.jettison.json.JSONException;
54 import com.att.aft.dme2.internal.jettison.json.JSONObject;
55
56 import com.att.ajsc.beans.PropertiesMapBean;
57 import org.onap.dmaap.dmf.mr.CambriaApiException;
58 import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
59 import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
60 import org.onap.dmaap.dmf.mr.CambriaApiException;
61 import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
62 import org.onap.dmaap.dmf.mr.beans.TopicBean;
63 import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
64 import org.onap.dmaap.dmf.mr.exception.DMaaPAccessDeniedException;
65 import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
66 import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;
67 import org.onap.dmaap.dmf.mr.metabroker.Topic;
68 import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;
69 import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
70 import org.onap.dmaap.dmf.mr.utils.DMaaPResponseBuilder;
71 import com.att.nsa.security.NsaApiKey;
72 import com.att.nsa.security.db.simple.NsaSimpleApiKey;
73
74 import jline.internal.Log;
75 import kafka.consumer.Consumer;
76
77
78
79 //@RunWith(MockitoJUnitRunner.class)
80 //@RunWith(PowerMockRunner.class)
81 //@PrepareForTest(PropertiesMapBean.class)
82 public class ShowConsumerCacheTest {
83 /*
84 @InjectMocks
85 TopicServiceImpl topicService;
86
87 @Mock
88 private DMaaPErrorMessages errorMessages;
89
90 @Mock
91 DMaaPContext dmaapContext;
92
93 @Mock
94 ConfigurationReader configReader;
95
96
97 @Mock
98 JSONObject consumers;
99
100 @Mock
101 JSONObject consumerObject;
102
103 @Mock
104 JSONArray jsonConsumersList;
105
106 @Mock
107 DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;
108
109 @Mock
110 NsaApiKey user;
111
112 @Mock
113 NsaSimpleApiKey nsaSimpleApiKey;
114
115 @Mock
116 HttpServletRequest httpServReq;
117
118
119 @Before
120 public void setUp(){
121 MockitoAnnotations.initMocks(this);
122 }
123
124
125 //@Test(expected = DMaaPAccessDeniedException.class)
126 @Test
127 public void testShowConsmerCache()throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException, JSONException{
128 Assert.assertNotNull(topicService);
129
130 String myName = "Brian";
131 Object created = null;
132 Object accessed = null;
133 Object log = null;
134 Object info = null;
135
136 when(consumerObject.put("name", myName)).thenReturn(consumerObject);
137 when(consumerObject.put("created", created)).thenReturn(consumerObject);
138 when(consumerObject.put("accessed", accessed)).thenReturn(consumerObject);
139 when(consumerObject.put("accessed", Consumer.class)).thenReturn(consumerObject);
140 when(jsonConsumersList.put(consumerObject)).thenReturn(null);
141
142 when(consumers.put("consumers", jsonConsumersList)).thenReturn(consumerObject);
143
144
145
146 }*/
147
148
149 }