2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
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;
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;
37 import javax.servlet.http.HttpServletRequest;
38 import javax.servlet.http.HttpServletResponse;
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;
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;
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;
74 import jline.internal.Log;
75 import kafka.consumer.Consumer;
79 //@RunWith(MockitoJUnitRunner.class)
80 //@RunWith(PowerMockRunner.class)
81 //@PrepareForTest(PropertiesMapBean.class)
82 public class ShowConsumerCacheTest {
85 TopicServiceImpl topicService;
88 private DMaaPErrorMessages errorMessages;
91 DMaaPContext dmaapContext;
94 ConfigurationReader configReader;
101 JSONObject consumerObject;
104 JSONArray jsonConsumersList;
107 DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;
113 NsaSimpleApiKey nsaSimpleApiKey;
116 HttpServletRequest httpServReq;
121 MockitoAnnotations.initMocks(this);
125 //@Test(expected = DMaaPAccessDeniedException.class)
127 public void testShowConsmerCache()throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException, JSONException{
128 Assert.assertNotNull(topicService);
130 String myName = "Brian";
131 Object created = null;
132 Object accessed = null;
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);
142 when(consumers.put("consumers", jsonConsumersList)).thenReturn(consumerObject);