fix security vulnerabilities
[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
76
77
78 //@RunWith(MockitoJUnitRunner.class)
79 //@RunWith(PowerMockRunner.class)
80 //@PrepareForTest(PropertiesMapBean.class)
81 public class ShowConsumerCacheTest {
82 /*
83 @InjectMocks
84 TopicServiceImpl topicService;
85
86 @Mock
87 private DMaaPErrorMessages errorMessages;
88
89 @Mock
90 DMaaPContext dmaapContext;
91
92 @Mock
93 ConfigurationReader configReader;
94
95
96 @Mock
97 JSONObject consumers;
98
99 @Mock
100 JSONObject consumerObject;
101
102 @Mock
103 JSONArray jsonConsumersList;
104
105 @Mock
106 DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;
107
108 @Mock
109 NsaApiKey user;
110
111 @Mock
112 NsaSimpleApiKey nsaSimpleApiKey;
113
114 @Mock
115 HttpServletRequest httpServReq;
116
117
118 @Before
119 public void setUp(){
120 MockitoAnnotations.initMocks(this);
121 }
122
123
124 //@Test(expected = DMaaPAccessDeniedException.class)
125 @Test
126 public void testShowConsmerCache()throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException, JSONException{
127 Assert.assertNotNull(topicService);
128
129 String myName = "Brian";
130 Object created = null;
131 Object accessed = null;
132 Object log = null;
133 Object info = null;
134
135 when(consumerObject.put("name", myName)).thenReturn(consumerObject);
136 when(consumerObject.put("created", created)).thenReturn(consumerObject);
137 when(consumerObject.put("accessed", accessed)).thenReturn(consumerObject);
138 when(consumerObject.put("accessed", Consumer.class)).thenReturn(consumerObject);
139 when(jsonConsumersList.put(consumerObject)).thenReturn(null);
140
141 when(consumers.put("consumers", jsonConsumersList)).thenReturn(consumerObject);
142
143
144
145 }*/
146
147
148 }