2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
36 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
38 package org.onap.portalsdk.analytics.xmlobj;
40 import static org.junit.Assert.*;
42 import java.io.IOException;
43 import java.sql.ResultSet;
44 import java.sql.ResultSetMetaData;
45 import java.util.ArrayList;
46 import java.util.Enumeration;
47 import java.util.HashMap;
48 import java.util.HashSet;
49 import java.util.List;
52 import java.util.Vector;
54 import javax.servlet.ServletContext;
55 import javax.servlet.http.HttpServletRequest;
56 import javax.servlet.http.HttpServletResponse;
58 import org.junit.Before;
59 import org.junit.Test;
60 import org.junit.runner.RunWith;
61 import org.mockito.InjectMocks;
62 import org.mockito.Matchers;
63 import org.mockito.Mock;
64 import org.mockito.Mockito;
65 import org.mockito.MockitoAnnotations;
66 import org.onap.portalsdk.analytics.controller.Action;
67 import org.onap.portalsdk.analytics.controller.ActionMapping;
68 import org.onap.portalsdk.analytics.error.RaptorException;
69 import org.onap.portalsdk.analytics.error.ReportSQLException;
70 import org.onap.portalsdk.analytics.model.DataCache;
71 import org.onap.portalsdk.analytics.model.ReportHandler;
72 import org.onap.portalsdk.analytics.model.ReportLoader;
73 import org.onap.portalsdk.analytics.model.base.IdNameValue;
74 import org.onap.portalsdk.analytics.model.base.ReportUserRole;
75 import org.onap.portalsdk.analytics.model.base.ReportWrapper;
76 import org.onap.portalsdk.analytics.model.definition.ReportDefinition;
77 import org.onap.portalsdk.analytics.model.definition.SecurityEntry;
78 import org.onap.portalsdk.analytics.model.definition.wizard.ColumnEditJSON;
79 import org.onap.portalsdk.analytics.model.definition.wizard.DefinitionJSON;
80 import org.onap.portalsdk.analytics.model.definition.wizard.FormEditJSON;
81 import org.onap.portalsdk.analytics.model.definition.wizard.IdNameBooleanJSON;
82 import org.onap.portalsdk.analytics.model.definition.wizard.ImportJSON;
83 import org.onap.portalsdk.analytics.model.definition.wizard.MessageJSON;
84 import org.onap.portalsdk.analytics.model.definition.wizard.NameBooleanJSON;
85 import org.onap.portalsdk.analytics.model.definition.wizard.QueryJSON;
86 import org.onap.portalsdk.analytics.model.runtime.ReportRuntime;
87 import org.onap.portalsdk.analytics.system.AppUtils;
88 import org.onap.portalsdk.analytics.system.ConnectionUtils;
89 import org.onap.portalsdk.analytics.system.DbUtils;
90 import org.onap.portalsdk.analytics.system.Globals;
91 import org.onap.portalsdk.analytics.system.fusion.web.RaptorControllerAsync;
92 import org.onap.portalsdk.analytics.util.AppConstants;
93 import org.onap.portalsdk.analytics.util.DataSet;
94 import org.onap.portalsdk.analytics.util.Utils;
95 import org.onap.portalsdk.analytics.util.XSSFilter;
96 import org.onap.portalsdk.core.service.DataAccessService;
97 import org.onap.portalsdk.core.util.SecurityCodecUtil;
98 import org.onap.portalsdk.core.web.support.UserUtils;
99 import org.owasp.esapi.ESAPI;
100 import org.owasp.esapi.Encoder;
101 import org.owasp.esapi.codecs.Codec;
102 import org.powermock.api.mockito.PowerMockito;
103 import org.powermock.core.classloader.annotations.PrepareForTest;
104 import org.powermock.modules.junit4.PowerMockRunner;
106 @RunWith(PowerMockRunner.class)
107 @PrepareForTest({ AppConstants.class, Globals.class, AppUtils.class, ReportWrapper.class, DataCache.class,
108 DbUtils.class, DataSet.class , ReportLoader.class ,ReportRuntime.class, Utils.class, ESAPI.class,
109 Codec.class,SecurityCodecUtil.class , ConnectionUtils.class, XSSFilter.class, ReportDefinition.class})
110 public class RaptorControllerAsyncNewTest {
113 RaptorControllerAsync raptorControllerAsync = new RaptorControllerAsync();
116 public void setup() {
117 MockitoAnnotations.initMocks(this);
121 DataAccessService dataAccessService;
124 AppConstants appConstants;
129 Action action = new Action("test", "RaptorControllerAsync", "test", "test");
131 ActionMapping actionMapping = new ActionMapping();
133 ReportDefinition reportDefinition ;
136 ReportHandler reportHandler = new ReportHandler();
138 MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
139 HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
140 HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
141 NullPointerException nullPointerException = new NullPointerException();
143 MockRunTimeReport mockRunTimeReport = new MockRunTimeReport();
145 @Test(expected = org.onap.portalsdk.analytics.error.ValidationException.class)
146 public void retrieveDataForGivenQueryTest() throws Exception
148 QueryJSON queryJSON = new QueryJSON();
149 queryJSON.setQuery("select * from test");
150 ServletContext servletContext = PowerMockito.mock(ServletContext.class);
151 Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext);
152 PowerMockito.mockStatic(Globals.class);
153 Mockito.when(Globals.isSystemInitialized()).thenReturn(true);
154 PowerMockito.mockStatic(ReportRuntime.class);
156 PowerMockito.mockStatic(Globals.class);
157 PowerMockito.mockStatic(DbUtils.class);
158 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
159 ResultSet rs = PowerMockito.mock(ResultSet.class);
160 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
161 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
162 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
163 DataSet datset = PowerMockito.mock(DataSet.class);
164 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
165 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
166 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
167 CustomReportType customReportType = new CustomReportType();
168 DataSourceList dataSourceList = new DataSourceList();
169 List<DataSourceType> list = new ArrayList<>();
170 DataSourceType dataSourceType = new DataSourceType();
171 dataSourceType.setTableName("test");
172 dataSourceType.setRefTableId("1");
173 List<DataColumnType> dataColumnTypeList = new ArrayList<>();
174 DataColumnType dataColumnType = new DataColumnType();
175 dataColumnType.setChartGroup("test");
176 dataColumnType.setYAxis("test");
177 dataColumnType.setColName("test");
178 dataColumnType.setColOnChart("test");
179 dataColumnType.setDisplayName("test");
180 dataColumnTypeList.add(dataColumnType);
181 DataColumnList dataColumnList = new DataColumnList();
182 dataColumnList.dataColumn = dataColumnTypeList;
183 dataSourceType.setDataColumnList(dataColumnList);
184 list.add(dataSourceType);
185 dataSourceList.dataSource = list;
186 customReportType.setReportType("test");
187 customReportType.setDbInfo("test");
188 customReportType.setDataSourceList(dataSourceList);
189 customReportType.setDbType("dbtype");
190 ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions();
191 chartAdditionalOptions.setLabelAngle("test");
192 chartAdditionalOptions.setTimeSeriesRender("test");
193 chartAdditionalOptions.setMultiSeries(false);
194 customReportType.setChartAdditionalOptions(chartAdditionalOptions);
195 FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class);
196 formFieldList.setComment("test");
197 customReportType.setFormFieldList(formFieldList);
198 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", "1", true);
199 reportWrapper.setWholeSQL("select * from test;");
200 ReportDefinition rdf = new ReportDefinition(reportWrapper, mockedRequest);
201 Mockito.when(mockedRequest.getSession().getAttribute("report_definition")).thenReturn(rdf);
202 PowerMockito.mockStatic(AppUtils.class);
203 Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test12");
204 PowerMockito.mockStatic(Utils.class);
205 Mockito.when(Utils.replaceInString(Matchers.anyString(), Matchers.anyString(), Matchers.anyString())).thenReturn("test");
206 Mockito.when(Globals.getRequestParams()).thenReturn("test,2");
207 Mockito.when(Globals.getSessionParams()).thenReturn("session,2");
208 Mockito.when(mockedRequest.getParameter("test")).thenReturn("test");
209 PowerMockito.mockStatic(ESAPI.class);
210 Encoder encoder = PowerMockito.mock(Encoder.class);
211 Mockito.when(ESAPI.encoder()).thenReturn(encoder);
212 Codec codec = PowerMockito.mock(Codec.class);
213 PowerMockito.mockStatic(SecurityCodecUtil.class);
214 Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec);
215 Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class),Matchers.anyString())).thenReturn("select *");
216 PowerMockito.mockStatic(ConnectionUtils.class);
217 DataSet set = new DataSet();
218 Mockito.when(ConnectionUtils.getDataSet("test", "local", true)).thenReturn(set);
219 PowerMockito.mockStatic(XSSFilter.class);
220 Mockito.when(XSSFilter.filterRequestOnlyScript(Matchers.anyString())).thenReturn("select distinct from test");
221 raptorControllerAsync.retrieveDataForGivenQuery(false, queryJSON, mockedRequest, mockedResponse);
225 public void importReportTest() throws Exception
227 QueryJSON queryJSON = new QueryJSON();
228 queryJSON.setQuery("select * from test");
229 ServletContext servletContext = PowerMockito.mock(ServletContext.class);
230 Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext);
231 PowerMockito.mockStatic(Globals.class);
232 Mockito.when(Globals.isSystemInitialized()).thenReturn(true);
233 PowerMockito.mockStatic(ReportRuntime.class);
235 PowerMockito.mockStatic(Globals.class);
236 PowerMockito.mockStatic(DbUtils.class);
237 PowerMockito.mockStatic(AppUtils.class);
238 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
239 ResultSet rs = PowerMockito.mock(ResultSet.class);
240 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
241 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
242 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
243 DataSet datset = PowerMockito.mock(DataSet.class);
244 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
245 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
246 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
247 CustomReportType customReportType = new CustomReportType();
248 DataSourceList dataSourceList = new DataSourceList();
249 List<DataSourceType> list = new ArrayList<>();
250 DataSourceType dataSourceType = new DataSourceType();
251 dataSourceType.setTableName("test");
252 dataSourceType.setRefTableId("1");
253 List<DataColumnType> dataColumnTypeList = new ArrayList<>();
254 DataColumnType dataColumnType = new DataColumnType();
255 dataColumnType.setChartGroup("test");
256 dataColumnType.setYAxis("test");
257 dataColumnType.setColName("test");
258 dataColumnType.setColOnChart("test");
259 dataColumnType.setDisplayName("test");
260 dataColumnTypeList.add(dataColumnType);
261 DataColumnList dataColumnList = new DataColumnList();
262 dataColumnList.dataColumn = dataColumnTypeList;
263 dataSourceType.setDataColumnList(dataColumnList);
264 list.add(dataSourceType);
265 dataSourceList.dataSource = list;
266 customReportType.setReportType("test");
267 customReportType.setDbInfo("test");
268 customReportType.setDataSourceList(dataSourceList);
269 customReportType.setDbType("dbtype");
270 ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions();
271 chartAdditionalOptions.setLabelAngle("test");
272 chartAdditionalOptions.setTimeSeriesRender("test");
273 chartAdditionalOptions.setMultiSeries(false);
274 customReportType.setChartAdditionalOptions(chartAdditionalOptions);
275 FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class);
276 formFieldList.setComment("test");
277 customReportType.setFormFieldList(formFieldList);
278 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", "1", true);
279 reportWrapper.setWholeSQL("select * from test;");
280 // ReportDefinition rdf = new ReportDefinition(reportWrapper, mockedRequest);
281 ReportDefinition rdf = PowerMockito.mock(ReportDefinition.class);
282 ImportJSON importJSON = new ImportJSON();
283 importJSON.setReportXML("test");
284 PowerMockito.whenNew(ReportDefinition.class).withArguments(Matchers.any(ReportWrapper.class), Matchers.any(HttpServletRequest.class)).thenReturn(rdf);
285 PowerMockito.mockStatic(ReportDefinition.class);
286 PowerMockito.when(ReportDefinition.unmarshal(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject())).thenReturn(rdf);
287 Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
288 assertEquals(raptorControllerAsync.importReport(importJSON, mockedRequest, mockedResponse).getClass(), MessageJSON.class);
291 @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
292 public void listChildReportColsTest() throws Exception
294 // PowerMockito.mockStatic(ReportRuntime.class);
296 PowerMockito.mockStatic(Globals.class);
297 PowerMockito.mockStatic(DbUtils.class);
298 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
299 ResultSet rs = PowerMockito.mock(ResultSet.class);
300 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
301 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
302 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
303 DataSet datset = PowerMockito.mock(DataSet.class);
304 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
305 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
306 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
307 CustomReportType customReportType = new CustomReportType();
308 DataSourceList dataSourceList = new DataSourceList();
309 List<DataSourceType> list = new ArrayList<>();
310 DataSourceType dataSourceType = new DataSourceType();
311 dataSourceType.setTableName("test");
312 dataSourceType.setRefTableId("1");
313 List<DataColumnType> dataColumnTypeList = new ArrayList<>();
314 DataColumnType dataColumnType = new DataColumnType();
315 dataColumnType.setChartGroup("test");
316 dataColumnType.setYAxis("test");
317 dataColumnType.setColName("test");
318 dataColumnType.setColOnChart("test");
319 dataColumnType.setDisplayName("test");
320 dataColumnTypeList.add(dataColumnType);
321 DataColumnList dataColumnList = new DataColumnList();
322 dataColumnList.dataColumn = dataColumnTypeList;
323 dataSourceType.setDataColumnList(dataColumnList);
324 list.add(dataSourceType);
325 dataSourceList.dataSource = list;
326 customReportType.setReportType("test");
327 customReportType.setDbInfo("test");
328 customReportType.setDataSourceList(dataSourceList);
329 customReportType.setDbType("dbtype");
330 ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions();
331 chartAdditionalOptions.setLabelAngle("test");
332 chartAdditionalOptions.setTimeSeriesRender("test");
333 chartAdditionalOptions.setMultiSeries(false);
334 customReportType.setChartAdditionalOptions(chartAdditionalOptions);
335 FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class);
336 formFieldList.setComment("test");
337 customReportType.setFormFieldList(formFieldList);
338 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", "1", true);
339 reportWrapper.setWholeSQL("select * from test;");
340 PowerMockito.mockStatic(UserUtils.class);
341 ReportRuntime rr = mockRunTimeReport.mockReportRuntime();
342 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr);
343 Mockito.when(ReportRuntime.unmarshal("test", "1", mockedRequest)).thenReturn(rr);
344 ReportHandler reportHandler = PowerMockito.mock(ReportHandler.class);
345 Mockito.when(reportHandler.loadReportRuntime(Matchers.any(HttpServletRequest.class), Matchers.anyString(), Matchers.anyBoolean())).thenReturn(rr);
346 Mockito.when(mockedRequest.getParameter(AppConstants.RI_REFRESH)).thenReturn("test");
347 PowerMockito.mockStatic(AppUtils.class);
348 Mockito.when(AppUtils.getRequestFlag(mockedRequest,"display_content")).thenReturn(true);
349 Mockito.when(AppUtils.getRequestFlag(mockedRequest, "noFormFields")).thenReturn(false);
350 Mockito.when( mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr);
351 Mockito.when(AppUtils.getRequestFlag(mockedRequest, "N")).thenReturn(true);
352 PowerMockito.mockStatic(ReportLoader.class);
353 Mockito.when(ReportLoader.loadCustomReportXML(Matchers.anyString())).thenReturn("test");
354 Mockito.when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test");
355 assertEquals(raptorControllerAsync.listChildReportCols("1", mockedRequest, mockedResponse).size(),1);
359 public void copyReportTest() throws Exception
361 Mockito.when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("test");
362 Mockito.when(mockedRequest.getParameter(AppConstants.RI_WIZARD_ACTION)).thenReturn("Wizard");
363 PowerMockito.mockStatic(Globals.class);
364 PowerMockito.mockStatic(DbUtils.class);
365 PowerMockito.mockStatic(AppUtils.class);
366 PowerMockito.mockStatic(ReportLoader.class);
367 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
368 ResultSet rs = PowerMockito.mock(ResultSet.class);
369 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
370 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
371 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
372 DataSet datset = PowerMockito.mock(DataSet.class);
373 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
374 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
375 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
376 CustomReportType customReportType = new CustomReportType();
377 customReportType.setReportType("test");
378 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1",
380 PowerMockito.mock(ReportDefinition.class);
381 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
382 Mockito.doNothing().when(reportDefinition).generateWizardSequence(null);
383 Mockito.doNothing().when(reportDefinition).setAsCopy(mockedRequest);
384 reportDefinition = new ReportDefinition(reportWrapper, mockedRequest);
385 Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
387 Mockito.when(mockedRequest.getSession().getAttribute(
388 AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
389 Mockito.when(ReportLoader.loadCustomReportXML(Matchers.anyString())).thenReturn("test");
390 raptorControllerAsync.copyReport("-1", mockedRequest, mockedResponse);
394 public void copyReport1Test() throws Exception
396 PowerMockito.mockStatic(AppUtils.class);
397 PowerMockito.mockStatic(ReportLoader.class);
398 PowerMockito.mock(ReportDefinition.class);
399 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
400 Mockito.doNothing().when(reportDefinition).generateWizardSequence(null);
401 Mockito.doNothing().when(reportDefinition).setAsCopy(mockedRequest);
402 Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
404 Mockito.when(mockedRequest.getSession().getAttribute(
405 AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
406 Mockito.when(ReportLoader.loadCustomReportXML(Matchers.anyString())).thenReturn("test");
407 raptorControllerAsync.copyReport("-1", mockedRequest, mockedResponse);
410 public void saveFFTabWiseDataTest() throws Exception
412 FormEditJSON formEditJSON= new FormEditJSON();
413 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
415 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
416 raptorControllerAsync.saveFFTabWiseData(formEditJSON, mockedRequest, mockedResponse);
420 public void saveFFTabWiseDataExceptionTest() throws Exception
422 Mockito.when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("test");
423 Mockito.when(mockedRequest.getParameter(AppConstants.RI_WIZARD_ACTION)).thenReturn("Wizard");
424 PowerMockito.mockStatic(Globals.class);
425 PowerMockito.mockStatic(DbUtils.class);
426 PowerMockito.mockStatic(AppUtils.class);
427 PowerMockito.mockStatic(ReportLoader.class);
428 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
429 ResultSet rs = PowerMockito.mock(ResultSet.class);
430 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
431 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
432 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
433 DataSet datset = PowerMockito.mock(DataSet.class);
434 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
435 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
436 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
437 CustomReportType customReportType = new CustomReportType();
438 customReportType.setReportType("test");
439 FormFieldList formFieldList = new FormFieldList();
440 formFieldList.setComment("test");
441 List<FormFieldType> formField = new ArrayList<>();
442 FormFieldType formFieldType = new FormFieldType();
443 formField.add(formFieldType);
444 formFieldList.formField = formField;
445 customReportType.setFormFieldList(formFieldList);
446 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1",
448 FormEditJSON formEditJSON= new FormEditJSON();
449 ReportDefinition reportDefinition = new ReportDefinition(reportWrapper, mockedRequest);
451 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
452 raptorControllerAsync.saveFFTabWiseData(formEditJSON, mockedRequest, mockedResponse);
456 public void saveFFTabWiseData1Test() throws Exception
458 Mockito.when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("test");
459 Mockito.when(mockedRequest.getParameter(AppConstants.RI_WIZARD_ACTION)).thenReturn("Wizard");
460 PowerMockito.mockStatic(Globals.class);
461 PowerMockito.mockStatic(DbUtils.class);
462 PowerMockito.mockStatic(AppUtils.class);
463 PowerMockito.mockStatic(ReportLoader.class);
464 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
465 ResultSet rs = PowerMockito.mock(ResultSet.class);
466 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
467 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
468 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
469 DataSet datset = PowerMockito.mock(DataSet.class);
470 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
471 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
472 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
473 CustomReportType customReportType = new CustomReportType();
474 customReportType.setReportType("test");
475 FormFieldList formFieldList = new FormFieldList();
476 formFieldList.setComment("test");
477 List<FormFieldType> formField = new ArrayList<>();
478 FormFieldType formFieldType = new FormFieldType();
479 formFieldType.setFieldId("test");
480 formField.add(formFieldType);
481 formFieldList.formField = formField;
482 customReportType.setFormFieldList(formFieldList);
483 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1",
485 FormEditJSON formEditJSON= new FormEditJSON();
486 formEditJSON.setFieldId("test");
487 List<IdNameBooleanJSON> list = new ArrayList<>();
488 IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
489 list.add(idNameBooleanJSON);
490 formEditJSON.setPredefinedValueList(list);
491 ReportDefinition reportDefinition = new ReportDefinition(reportWrapper, mockedRequest);
493 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
494 raptorControllerAsync.saveFFTabWiseData(formEditJSON, mockedRequest, mockedResponse);
498 public void saveFFTabWiseData2Test() throws Exception
500 Mockito.when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("test");
501 Mockito.when(mockedRequest.getParameter(AppConstants.RI_WIZARD_ACTION)).thenReturn("Wizard");
502 PowerMockito.mockStatic(Globals.class);
503 PowerMockito.mockStatic(DbUtils.class);
504 PowerMockito.mockStatic(AppUtils.class);
505 PowerMockito.mockStatic(ReportLoader.class);
506 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
507 ResultSet rs = PowerMockito.mock(ResultSet.class);
508 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
509 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
510 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
511 DataSet datset = PowerMockito.mock(DataSet.class);
512 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
513 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
514 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
515 CustomReportType customReportType = new CustomReportType();
516 customReportType.setReportType("test");
517 FormFieldList formFieldList = new FormFieldList();
518 formFieldList.setComment("test");
519 List<FormFieldType> formField = new ArrayList<>();
520 FormFieldType formFieldType = new FormFieldType();
521 formFieldType.setFieldId("test");
523 List<String> predefinedValue = new ArrayList<>();
524 predefinedValue.add("test");
525 PredefinedValueList predefinedValueList = new PredefinedValueList();
526 predefinedValueList.predefinedValue = predefinedValue;
527 formFieldType.setPredefinedValueList(predefinedValueList);
528 formField.add(formFieldType);
529 formFieldList.formField = formField;
530 customReportType.setFormFieldList(formFieldList);
531 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1",
533 FormEditJSON formEditJSON= new FormEditJSON();
534 formEditJSON.setFieldId("test");
535 ReportDefinition reportDefinition = new ReportDefinition(reportWrapper, mockedRequest);
537 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
538 raptorControllerAsync.saveFFTabWiseData(formEditJSON, mockedRequest, mockedResponse);
542 public void saveColTabWiseDataTest() throws Exception
544 ColumnEditJSON columnEditJSON = new ColumnEditJSON();
545 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
547 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
548 raptorControllerAsync.saveColTabWiseData(columnEditJSON, mockedRequest, mockedResponse);
552 public void saveColTabWiseData5Test() throws Exception
554 ColumnEditJSON columnEditJSON = new ColumnEditJSON();
555 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(null);
556 raptorControllerAsync.saveColTabWiseData(columnEditJSON, mockedRequest, mockedResponse);
560 public void saveColTabWiseData2Test() throws Exception
562 ColumnEditJSON columnEditJSON = new ColumnEditJSON();
563 Mockito.when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("test");
564 Mockito.when(mockedRequest.getParameter(AppConstants.RI_WIZARD_ACTION)).thenReturn("Wizard");
565 PowerMockito.mockStatic(Globals.class);
566 PowerMockito.mockStatic(DbUtils.class);
567 PowerMockito.mockStatic(AppUtils.class);
568 PowerMockito.mockStatic(ReportLoader.class);
569 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
570 ResultSet rs = PowerMockito.mock(ResultSet.class);
571 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
572 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
573 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
574 DataSet datset = PowerMockito.mock(DataSet.class);
575 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
576 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
577 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
578 CustomReportType customReportType = new CustomReportType();
579 customReportType.setReportType("test");
580 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1",
582 ReportDefinition reportDefinition = new ReportDefinition(reportWrapper, mockedRequest);
583 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
584 raptorControllerAsync.saveColTabWiseData(columnEditJSON, mockedRequest, mockedResponse);
589 public void saveColTabWiseData1Test() throws Exception
591 ColumnEditJSON columnEditJSON = new ColumnEditJSON();
592 columnEditJSON.setColId("test");
593 PowerMockito.mockStatic(Globals.class);
594 PowerMockito.mockStatic(DbUtils.class);
595 PowerMockito.mockStatic(AppUtils.class);
596 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
597 ResultSet rs = PowerMockito.mock(ResultSet.class);
598 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
599 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
600 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
601 DataSet datset = PowerMockito.mock(DataSet.class);
602 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
603 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
604 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
605 CustomReportType customReportType = new CustomReportType();
606 DataSourceList dataSourceList = new DataSourceList();
607 List<DataSourceType> list = new ArrayList<>();
608 DataSourceType dataSourceType = new DataSourceType();
609 dataSourceType.setTableName("test");
610 dataSourceType.setRefTableId("1");
611 List<DataColumnType> dataColumnTypeList = new ArrayList<>();
612 DataColumnType dataColumnType = new DataColumnType();
613 dataColumnType.setChartGroup("test");
614 dataColumnType.setYAxis("test");
615 dataColumnType.setColName("test");
616 dataColumnType.setColOnChart("test");
617 dataColumnType.setDisplayName("test");
618 dataColumnType.setColId("test");
619 dataColumnTypeList.add(dataColumnType);
620 DataColumnList dataColumnList = new DataColumnList();
621 dataColumnList.dataColumn = dataColumnTypeList;
622 dataSourceType.setDataColumnList(dataColumnList);
623 list.add(dataSourceType);
624 dataSourceList.dataSource = list;
625 customReportType.setReportType("test");
626 customReportType.setDbInfo("test");
627 customReportType.setDataSourceList(dataSourceList);
628 customReportType.setDbType("dbtype");
629 ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions();
630 chartAdditionalOptions.setLabelAngle("test");
631 chartAdditionalOptions.setTimeSeriesRender("test");
632 chartAdditionalOptions.setMultiSeries(false);
633 customReportType.setChartAdditionalOptions(chartAdditionalOptions);
634 FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class);
635 formFieldList.setComment("test");
636 customReportType.setFormFieldList(formFieldList);
637 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", "1", true);
638 reportWrapper.setWholeSQL("select * from test;");
639 ReportDefinition rdf = new ReportDefinition(reportWrapper, mockedRequest);
640 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf);
641 raptorControllerAsync.saveColTabWiseData(columnEditJSON, mockedRequest, mockedResponse);
644 public void saveDefTabWiseDataExceptionTest() throws Exception
646 DefinitionJSON definitionJSON= new DefinitionJSON();
647 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(null);
648 raptorControllerAsync.saveDefTabWiseData("InSession", definitionJSON, mockedRequest, mockedResponse);
652 public void saveDefTabWiseDataTest() throws Exception
654 DefinitionJSON definitionJSON= new DefinitionJSON();
655 definitionJSON.setPageSize(1);
656 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
657 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
659 List<IdNameBooleanJSON> list = new ArrayList<>();
660 IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
661 list.add(idNameBooleanJSON);
662 List<NameBooleanJSON> list1 = new ArrayList<>();
663 NameBooleanJSON nameBooleanJSON = new NameBooleanJSON();
664 nameBooleanJSON.setSelected(true);
665 nameBooleanJSON.setName("HideFormFields");
666 list1.add(nameBooleanJSON);
667 list.add(idNameBooleanJSON);
668 definitionJSON.setDisplayArea(list);
669 definitionJSON.setHideFormFieldsAfterRun(false);
670 definitionJSON.setMaxRowsInExcelCSVDownload(4);
671 definitionJSON.setFrozenColumns(4);
672 definitionJSON.setRuntimeColSortDisabled(false);
673 definitionJSON.setNumFormCols(4);
674 definitionJSON.setDisplayOptions(list1);
675 raptorControllerAsync.saveDefTabWiseData("InSession", definitionJSON, mockedRequest, mockedResponse);
679 public void saveDefTabWiseData1Test() throws Exception
681 DefinitionJSON definitionJSON= new DefinitionJSON();
682 definitionJSON.setPageSize(1);
683 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
684 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
686 List<IdNameBooleanJSON> list = new ArrayList<>();
687 IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
688 list.add(idNameBooleanJSON);
689 List<NameBooleanJSON> list1 = new ArrayList<>();
690 NameBooleanJSON nameBooleanJSON = new NameBooleanJSON();
691 nameBooleanJSON.setSelected(true);
692 nameBooleanJSON.setName("HideChart");
693 list1.add(nameBooleanJSON);
694 list.add(idNameBooleanJSON);
695 definitionJSON.setDisplayArea(list);
696 definitionJSON.setHideFormFieldsAfterRun(false);
697 definitionJSON.setMaxRowsInExcelCSVDownload(4);
698 definitionJSON.setFrozenColumns(4);
699 definitionJSON.setRuntimeColSortDisabled(false);
700 definitionJSON.setNumFormCols(4);
701 definitionJSON.setDisplayOptions(list1);
702 raptorControllerAsync.saveDefTabWiseData("InSession", definitionJSON, mockedRequest, mockedResponse);
706 public void saveDefTabWiseData2Test() throws Exception
708 DefinitionJSON definitionJSON= new DefinitionJSON();
709 definitionJSON.setPageSize(1);
710 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
711 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
713 List<IdNameBooleanJSON> list = new ArrayList<>();
714 IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
715 list.add(idNameBooleanJSON);
716 List<NameBooleanJSON> list1 = new ArrayList<>();
717 NameBooleanJSON nameBooleanJSON = new NameBooleanJSON();
718 nameBooleanJSON.setSelected(true);
719 nameBooleanJSON.setName("HideReportData");
720 list1.add(nameBooleanJSON);
721 list.add(idNameBooleanJSON);
722 definitionJSON.setDisplayArea(list);
723 definitionJSON.setHideFormFieldsAfterRun(false);
724 definitionJSON.setMaxRowsInExcelCSVDownload(4);
725 definitionJSON.setFrozenColumns(4);
726 definitionJSON.setRuntimeColSortDisabled(false);
727 definitionJSON.setNumFormCols(4);
728 definitionJSON.setDisplayOptions(list1);
729 raptorControllerAsync.saveDefTabWiseData("InSession", definitionJSON, mockedRequest, mockedResponse);
733 public void saveDefTabWiseData3Test() throws Exception
735 DefinitionJSON definitionJSON= new DefinitionJSON();
736 definitionJSON.setPageSize(1);
737 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
738 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
740 List<IdNameBooleanJSON> list = new ArrayList<>();
741 IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
742 list.add(idNameBooleanJSON);
743 List<NameBooleanJSON> list1 = new ArrayList<>();
744 NameBooleanJSON nameBooleanJSON = new NameBooleanJSON();
745 nameBooleanJSON.setSelected(true);
746 nameBooleanJSON.setName("HideExcel");
747 list1.add(nameBooleanJSON);
748 list.add(idNameBooleanJSON);
749 definitionJSON.setDisplayArea(list);
750 definitionJSON.setHideFormFieldsAfterRun(false);
751 definitionJSON.setMaxRowsInExcelCSVDownload(4);
752 definitionJSON.setFrozenColumns(4);
753 definitionJSON.setRuntimeColSortDisabled(false);
754 definitionJSON.setNumFormCols(4);
755 definitionJSON.setDisplayOptions(list1);
756 raptorControllerAsync.saveDefTabWiseData("InSession", definitionJSON, mockedRequest, mockedResponse);
760 public void saveDefTabWiseData4Test() throws Exception
762 DefinitionJSON definitionJSON= new DefinitionJSON();
763 definitionJSON.setPageSize(1);
764 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
765 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
767 List<IdNameBooleanJSON> list = new ArrayList<>();
768 IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
769 list.add(idNameBooleanJSON);
770 List<NameBooleanJSON> list1 = new ArrayList<>();
771 NameBooleanJSON nameBooleanJSON = new NameBooleanJSON();
772 nameBooleanJSON.setSelected(true);
773 nameBooleanJSON.setName("HidePdf");
774 list1.add(nameBooleanJSON);
775 list.add(idNameBooleanJSON);
776 definitionJSON.setDisplayArea(list);
777 definitionJSON.setHideFormFieldsAfterRun(false);
778 definitionJSON.setMaxRowsInExcelCSVDownload(4);
779 definitionJSON.setFrozenColumns(4);
780 definitionJSON.setRuntimeColSortDisabled(false);
781 definitionJSON.setNumFormCols(4);
782 definitionJSON.setDisplayOptions(list1);
783 raptorControllerAsync.saveDefTabWiseData("InSession", definitionJSON, mockedRequest, mockedResponse);
787 public void saveDefTabWiseDataIfIdCrateTest() throws Exception
789 DefinitionJSON definitionJSON= new DefinitionJSON();
790 definitionJSON.setPageSize(1);
791 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
792 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition);
794 List<IdNameBooleanJSON> list = new ArrayList<>();
795 IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
796 list.add(idNameBooleanJSON);
797 List<NameBooleanJSON> list1 = new ArrayList<>();
798 NameBooleanJSON nameBooleanJSON = new NameBooleanJSON();
799 nameBooleanJSON.setSelected(true);
800 nameBooleanJSON.setName("HidePdf");
801 list1.add(nameBooleanJSON);
802 list.add(idNameBooleanJSON);
803 definitionJSON.setDisplayArea(list);
804 definitionJSON.setHideFormFieldsAfterRun(false);
805 definitionJSON.setMaxRowsInExcelCSVDownload(4);
806 definitionJSON.setFrozenColumns(4);
807 definitionJSON.setRuntimeColSortDisabled(false);
808 definitionJSON.setNumFormCols(4);
809 definitionJSON.setDisplayOptions(list1);
810 Set<String> set = new HashSet<String>();
812 Enumeration<String> x = new IteratorEnumeration<String>(set.iterator());
813 Mockito.when(mockedRequest.getSession().getAttributeNames()).thenReturn(x);
814 raptorControllerAsync.saveDefTabWiseData("Create", definitionJSON, mockedRequest, mockedResponse);
817 public void retrieveFormTabWiseDataTest() throws Exception {
818 Map<String, String> map = new HashMap<>();
819 map.put("test", "test");
820 map.put("id", "add");
821 map.put("action", "delete");
823 QueryJSON queryJSON = new QueryJSON();
824 queryJSON.setQuery("select * from test");
825 ServletContext servletContext = PowerMockito.mock(ServletContext.class);
826 Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext);
827 PowerMockito.mockStatic(Globals.class);
828 Mockito.when(Globals.isSystemInitialized()).thenReturn(true);
829 PowerMockito.mockStatic(ReportRuntime.class);
831 PowerMockito.mockStatic(Globals.class);
832 PowerMockito.mockStatic(DbUtils.class);
833 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
834 ResultSet rs = PowerMockito.mock(ResultSet.class);
835 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
836 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
837 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
838 DataSet datset = PowerMockito.mock(DataSet.class);
839 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
840 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
841 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
842 CustomReportType customReportType = new CustomReportType();
843 DataSourceList dataSourceList = new DataSourceList();
844 List<DataSourceType> list = new ArrayList<>();
845 DataSourceType dataSourceType = new DataSourceType();
846 dataSourceType.setTableName("test");
847 dataSourceType.setRefTableId("1");
848 List<DataColumnType> dataColumnTypeList = new ArrayList<>();
849 DataColumnType dataColumnType = new DataColumnType();
850 dataColumnType.setChartGroup("test");
851 dataColumnType.setYAxis("test");
852 dataColumnType.setColName("test");
853 dataColumnType.setColOnChart("test");
854 dataColumnType.setDisplayName("test");
855 dataColumnTypeList.add(dataColumnType);
856 DataColumnList dataColumnList = new DataColumnList();
857 dataColumnList.dataColumn = dataColumnTypeList;
858 dataSourceType.setDataColumnList(dataColumnList);
859 list.add(dataSourceType);
860 dataSourceList.dataSource = list;
861 customReportType.setReportType("test");
862 customReportType.setDbInfo("test");
863 customReportType.setDataSourceList(dataSourceList);
864 customReportType.setDbType("dbtype");
865 FormFieldList formFieldList = new FormFieldList();
866 formFieldList.setComment("test");
867 List<FormFieldType> formField = new ArrayList<>();
868 FormFieldType formFieldType = new FormFieldType();
869 formFieldType.setFieldId("test");
870 formFieldType.setVisible("yes");
871 List<String> predefinedValue = new ArrayList<>();
872 predefinedValue.add("test");
873 PredefinedValueList predefinedValueList = new PredefinedValueList();
874 predefinedValueList.predefinedValue = predefinedValue;
875 formFieldType.setPredefinedValueList(predefinedValueList);
876 formField.add(formFieldType);
877 formFieldList.formField = formField;
878 customReportType.setFormFieldList(formFieldList);
879 ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions();
880 chartAdditionalOptions.setLabelAngle("test");
881 chartAdditionalOptions.setTimeSeriesRender("test");
882 chartAdditionalOptions.setMultiSeries(false);
883 customReportType.setChartAdditionalOptions(chartAdditionalOptions);
884 formFieldList.setComment("test");
885 customReportType.setFormFieldList(formFieldList);
886 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1",
888 reportWrapper.setWholeSQL("select * from test;");
889 ReportDefinition reportDefinition = new ReportDefinition(reportWrapper, mockedRequest);
890 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION))
891 .thenReturn(reportDefinition);
892 Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext);
893 PowerMockito.mockStatic(Globals.class);
894 Mockito.when(Globals.isSystemInitialized()).thenReturn(true);
896 raptorControllerAsync.retrieveFormTabWiseData(map, mockedRequest, mockedResponse);
901 public void saveDefTabWiseDataIfIdCrateExceptionTest() throws Exception
903 DefinitionJSON definitionJSON= new DefinitionJSON();
904 definitionJSON.setPageSize(1);
905 ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class);
906 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenThrow(nullPointerException);
908 List<IdNameBooleanJSON> list = new ArrayList<>();
909 IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
910 list.add(idNameBooleanJSON);
911 List<NameBooleanJSON> list1 = new ArrayList<>();
912 NameBooleanJSON nameBooleanJSON = new NameBooleanJSON();
913 nameBooleanJSON.setSelected(true);
914 nameBooleanJSON.setName("HidePdf");
915 list1.add(nameBooleanJSON);
916 list.add(idNameBooleanJSON);
917 definitionJSON.setDisplayArea(list);
918 definitionJSON.setHideFormFieldsAfterRun(false);
919 definitionJSON.setMaxRowsInExcelCSVDownload(4);
920 definitionJSON.setFrozenColumns(4);
921 definitionJSON.setRuntimeColSortDisabled(false);
922 definitionJSON.setNumFormCols(4);
923 definitionJSON.setDisplayOptions(list1);
924 Set<String> set = new HashSet<String>();
926 Enumeration<String> x = new IteratorEnumeration<String>(set.iterator());
927 Mockito.when(mockedRequest.getSession().getAttributeNames()).thenReturn(x);
928 raptorControllerAsync.saveDefTabWiseData("InSession", definitionJSON, mockedRequest, mockedResponse);
932 public ReportDefinition mockReportDefinition() throws Exception
934 PowerMockito.mockStatic(Globals.class);
935 Mockito.when(Globals.isSystemInitialized()).thenReturn(true);
936 PowerMockito.mockStatic(ReportRuntime.class);
938 PowerMockito.mockStatic(Globals.class);
939 PowerMockito.mockStatic(DbUtils.class);
940 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
941 ResultSet rs = PowerMockito.mock(ResultSet.class);
942 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
943 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
944 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
945 DataSet datset = PowerMockito.mock(DataSet.class);
946 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
947 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
948 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
949 CustomReportType customReportType = new CustomReportType();
950 DataSourceList dataSourceList = new DataSourceList();
951 List<DataSourceType> list = new ArrayList<>();
952 DataSourceType dataSourceType = new DataSourceType();
953 dataSourceType.setTableName("test");
954 dataSourceType.setRefTableId("1");
955 List<DataColumnType> dataColumnTypeList = new ArrayList<>();
956 DataColumnType dataColumnType = new DataColumnType();
957 dataColumnType.setChartGroup("test");
958 dataColumnType.setYAxis("test");
959 dataColumnType.setColName("test");
960 dataColumnType.setColOnChart("test");
961 dataColumnType.setDisplayName("test");
962 dataColumnTypeList.add(dataColumnType);
963 dataColumnType.setColId("test");
964 DataColumnList dataColumnList = new DataColumnList();
965 dataColumnList.dataColumn = dataColumnTypeList;
966 dataSourceType.setDataColumnList(dataColumnList);
967 list.add(dataSourceType);
968 dataSourceList.dataSource = list;
969 customReportType.setReportType("test");
970 customReportType.setDbInfo("test");
971 customReportType.setDataSourceList(dataSourceList);
972 customReportType.setDbType("dbtype");
973 FormFieldList formFieldList = new FormFieldList();
974 formFieldList.setComment("test");
975 List<FormFieldType> formField = new ArrayList<>();
976 FormFieldType formFieldType = new FormFieldType();
977 formFieldType.setFieldId("test");
978 formFieldType.setVisible("yes");
979 List<String> predefinedValue = new ArrayList<>();
980 predefinedValue.add("test");
981 PredefinedValueList predefinedValueList = new PredefinedValueList();
982 predefinedValueList.predefinedValue = predefinedValue;
983 formFieldType.setPredefinedValueList(predefinedValueList);
984 formField.add(formFieldType);
985 formFieldList.formField = formField;
986 customReportType.setFormFieldList(formFieldList);
987 ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions();
988 chartAdditionalOptions.setLabelAngle("test");
989 chartAdditionalOptions.setTimeSeriesRender("test");
990 chartAdditionalOptions.setMultiSeries(false);
991 customReportType.setChartAdditionalOptions(chartAdditionalOptions);
992 formFieldList.setComment("test");
993 customReportType.setFormFieldList(formFieldList);
994 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1",
996 reportWrapper.setWholeSQL("select * from test;");
997 ReportDefinition reportDefinition = new ReportDefinition(reportWrapper, mockedRequest);
998 return reportDefinition;
1001 public void retrieveColTabWiseDataTest() throws Exception
1003 Map<String, String> map = new HashMap<>();
1004 map.put("test", "test");
1005 map.put("id", "add");
1006 map.put("action", "delete");
1007 Mockito.when((ReportDefinition) mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(null);
1008 PowerMockito.mockStatic(Globals.class);
1009 Mockito.when(Globals.isSystemInitialized()).thenReturn(false);
1010 assertEquals(raptorControllerAsync.retrieveColTabWiseData(map, mockedRequest, mockedResponse).getClass(), ColumnEditJSON.class);
1014 public void retrieveColTabWiseData1Test() throws Exception
1016 Map<String, String> map = new HashMap<>();
1017 map.put("test", "test");
1018 map.put("id", "test");
1019 map.put("action", "delete");
1020 ReportDefinition rdf = mockReportDefinition();
1021 Mockito.when((ReportDefinition) mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf);
1022 PowerMockito.mockStatic(Globals.class);
1023 Mockito.when(Globals.isSystemInitialized()).thenReturn(false);
1024 assertEquals(raptorControllerAsync.retrieveColTabWiseData(map, mockedRequest, mockedResponse).getClass(), ColumnEditJSON.class);
1028 public void retrieveSqlTabWiseDataTest() throws Exception
1030 Map<String, String> map = new HashMap<>();
1031 map.put("test", "test");
1032 map.put("id", "test");
1033 map.put("action", "delete");
1034 Mockito.when((ReportDefinition) mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(null);
1035 PowerMockito.mockStatic(Globals.class);
1036 Mockito.when(Globals.isSystemInitialized()).thenReturn(false);
1037 PowerMockito.mockStatic(ReportLoader.class);
1038 Mockito.when(ReportLoader.loadCustomReportXML("1")).thenReturn("test");
1039 ReportDefinition rdf = PowerMockito.mock(ReportDefinition.class);
1040 PowerMockito.whenNew(ReportDefinition.class).withArguments(Matchers.any(ReportWrapper.class), Matchers.any(HttpServletRequest.class)).thenReturn(rdf);
1041 PowerMockito.mockStatic(ReportDefinition.class);
1042 PowerMockito.when(ReportDefinition.unmarshal(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject())).thenReturn(rdf);
1043 assertEquals(raptorControllerAsync.retrieveSqlTabWiseData(map, mockedRequest, mockedResponse).getClass(), QueryJSON.class);
1047 public void retrieveSqlTabWiseData1Test() throws Exception
1049 Map<String, String> map = new HashMap<>();
1050 map.put("test", "test");
1051 map.put("id", "test");
1052 map.put("detailId", "detailId");
1053 ReportDefinition rdf1 = mockReportDefinition();
1054 Mockito.when((ReportDefinition) mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1055 PowerMockito.mockStatic(Globals.class);
1056 Mockito.when(Globals.isSystemInitialized()).thenReturn(false);
1057 PowerMockito.mockStatic(ReportLoader.class);
1058 Mockito.when(ReportLoader.loadCustomReportXML("1")).thenReturn("test");
1059 ReportDefinition rdf = PowerMockito.mock(ReportDefinition.class);
1060 PowerMockito.whenNew(ReportDefinition.class).withArguments(Matchers.any(ReportWrapper.class), Matchers.any(HttpServletRequest.class)).thenReturn(rdf);
1061 PowerMockito.mockStatic(ReportDefinition.class);
1062 PowerMockito.when(ReportDefinition.unmarshal(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject())).thenReturn(rdf);
1063 Set<String> set = new HashSet<String>();
1065 Enumeration<String> x = new IteratorEnumeration<String>(set.iterator());
1066 Mockito.when(mockedRequest.getSession().getAttributeNames()).thenReturn(x);
1067 assertEquals(raptorControllerAsync.retrieveSqlTabWiseData(map, mockedRequest, mockedResponse).getClass(), QueryJSON.class);
1070 public void getReportUserListTest() throws Exception
1072 Vector<SecurityEntry> entity = new Vector<>();
1073 SecurityEntry SecurityEntry = new SecurityEntry();
1074 entity.add(SecurityEntry);
1075 ReportDefinition rdf1 = PowerMockito.mock(ReportDefinition.class);
1076 Mockito.when(rdf1.getReportUsers(mockedRequest)).thenReturn(entity);
1077 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1078 raptorControllerAsync.getReportUserList(mockedRequest);
1083 public void getReportRoleListTest() throws Exception
1085 PowerMockito.mockStatic(Utils.class);
1086 Vector<IdNameValue> entity = new Vector<>();
1087 IdNameValue SecurityEntry = new IdNameValue();
1088 entity.add(SecurityEntry);
1089 ReportDefinition rdf1 = PowerMockito.mock(ReportDefinition.class);
1090 Mockito.when(rdf1.getReportUsers(mockedRequest)).thenReturn(entity);
1091 Mockito.when(Utils.getRolesNotInList(Matchers.any(Vector.class),Matchers.any(HttpServletRequest.class))).thenReturn(entity);
1092 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1093 raptorControllerAsync.getReportRoleList(mockedRequest);
1098 public void getReportUserListQueryTest() throws Exception
1100 PowerMockito.mockStatic(Utils.class);
1101 Vector<IdNameValue> entity = new Vector<>();
1102 IdNameValue SecurityEntry = new IdNameValue();
1103 entity.add(SecurityEntry);
1104 ReportDefinition rdf1 = mockReportDefinition();
1105 // Mockito.when(rdf1.getReportUsers(mockedRequest)).thenReturn(entity);
1106 Mockito.when(Utils.getRolesNotInList(Matchers.any(Vector.class),Matchers.any(HttpServletRequest.class))).thenReturn(entity);
1107 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1108 List<ReportUserRole> queriedUserList = new ArrayList<>();
1109 ReportUserRole reportUserRole = new ReportUserRole();
1110 reportUserRole.setRoleId((long) 1);
1111 reportUserRole.setOrderNo((long) 1);
1112 reportUserRole.setUserId((long) 1);
1113 queriedUserList.add(reportUserRole);
1114 Mockito.when(dataAccessService.executeNamedQuery(Matchers.anyString(), Matchers.anyMap(), Matchers.anyMap())).thenReturn(queriedUserList);
1115 raptorControllerAsync.getReportUserListQuery(mockedRequest);
1120 public void addSelectedReportUserExceptionTest() throws Exception
1122 ReportDefinition rdf1 = mockReportDefinition();
1123 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1124 raptorControllerAsync.addSelectedReportUser("test", mockedRequest, mockedResponse);
1128 public void addSelectedReportUserTest() throws Exception
1130 ReportDefinition rdf1 = mockReportDefinition();
1131 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1132 Mockito.when(Globals.getAddUserAccess()).thenReturn("[reportID]");
1133 Mockito.when(DbUtils.executeUpdate(Matchers.anyString())).thenReturn(1);
1134 raptorControllerAsync.addSelectedReportUser("test", mockedRequest, mockedResponse);
1137 public void removeSelectedReportUserTest() throws Exception{
1138 PowerMockito.mockStatic(Globals.class);
1139 ReportDefinition rdf1 = mockReportDefinition();
1140 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1141 Mockito.when(Globals.getRemoveUserAccess()).thenReturn("[reportID]");
1142 raptorControllerAsync.removeSelectedReportUser("test", mockedRequest, mockedResponse);
1146 public void removeSelectedReportUserExceptionTest() throws Exception{
1147 PowerMockito.mockStatic(Globals.class);
1148 ReportDefinition rdf1 = mockReportDefinition();
1149 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1150 Mockito.when(Globals.getRemoveUserAccess()).thenReturn("[reportID]");
1151 raptorControllerAsync.removeSelectedReportUser(null, mockedRequest, mockedResponse);
1154 public void addSelectedReportRoleTest() throws Exception
1156 ReportDefinition rdf1 = mockReportDefinition();
1157 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1158 PowerMockito.mockStatic(Globals.class);
1159 Mockito.when(Globals.getAddRoleAccess()).thenReturn("[roleID]");
1160 raptorControllerAsync.addSelectedReportRole("test", mockedRequest, mockedResponse);
1165 public void addSelectedReportRole1Test() throws Exception {
1166 ReportDefinition rdf1 = mockReportDefinition();
1167 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1168 PowerMockito.mockStatic(Globals.class);
1169 Mockito.when(Globals.getAddRoleAccess()).thenReturn("[reportID]");
1170 raptorControllerAsync.addSelectedReportRole("test", mockedRequest, mockedResponse);
1174 public void addSelectedReportRoleExceptionTest() throws Exception {
1175 ReportDefinition rdf1 = mockReportDefinition();
1176 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1177 assertNull(raptorControllerAsync.addSelectedReportRole("test", mockedRequest, mockedResponse));
1182 public void removeSelectedReportRoleExceptionTest() throws Exception
1184 ReportDefinition rdf1 = mockReportDefinition();
1185 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1186 assertNull(raptorControllerAsync.removeSelectedReportRole("test", mockedRequest, mockedResponse));
1191 public void removeSelectedReportRoleTest() throws Exception
1193 ReportDefinition rdf1 = mockReportDefinition();
1194 PowerMockito.mockStatic(Globals.class);
1195 Mockito.when(Globals.getRemoveRoleAccess()).thenReturn("[reportID]");
1196 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1197 raptorControllerAsync.removeSelectedReportRole("test", mockedRequest, mockedResponse);
1202 public void updateReportSecurityInfoExceptionTest() throws Exception
1204 ReportDefinition rdf1 = mockReportDefinition();
1205 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1206 Map<String,String> map = new HashMap<>();
1208 assertNull(raptorControllerAsync.updateReportSecurityInfo(map, mockedRequest, mockedResponse));
1212 public void updateReportSecurityInfoTest() throws Exception {
1213 ReportDefinition rdf1 = mockReportDefinition();
1214 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1215 Map<String, String> map = new HashMap<>();
1216 map.put("isPublic", "isPublic");
1218 assertEquals(raptorControllerAsync.updateReportSecurityInfo(map, mockedRequest, mockedResponse).getClass(),
1222 public void toggleUserEditAccessExceptionTest() throws Exception
1224 ReportDefinition rdf1 = mockReportDefinition();
1225 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1226 assertNull(raptorControllerAsync.toggleUserEditAccess("test", "readOnly", mockedRequest, mockedResponse));
1230 public void toggleUserEditAccessTest() throws Exception
1232 ReportDefinition rdf1 = mockReportDefinition();
1233 PowerMockito.mockStatic(Globals.class);
1234 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1235 Mockito.when(Globals.getUpdateUserAccess()).thenReturn("[userID]");
1236 assertEquals(raptorControllerAsync.toggleUserEditAccess("test", "N", mockedRequest, mockedResponse).getClass(), HashMap.class);
1239 public void toggleRoleEditAccessExceptionTest() throws Exception
1241 ReportDefinition rdf1 = mockReportDefinition();
1242 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1243 assertNull(raptorControllerAsync.toggleUserEditAccess("test", "readOnly", mockedRequest, mockedResponse));
1247 public void toggleRoleEditAccessTest() throws Exception
1249 ReportDefinition rdf1 = mockReportDefinition();
1250 PowerMockito.mockStatic(Globals.class);
1251 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1252 Mockito.when(Globals.getUpdateRoleAccess()).thenReturn("[userID]");
1253 assertEquals(raptorControllerAsync.toggleRoleEditAccess("test", "N", mockedRequest, mockedResponse).getClass(), HashMap.class);
1256 public void getReportOwnerInListTest() throws Exception
1258 ReportDefinition rdf1 = mockReportDefinition();
1259 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1260 PowerMockito.mockStatic(Globals.class);
1261 PowerMockito.mockStatic(AppUtils.class);
1262 Mockito.when(Globals.getCustomizedScheduleQueryForUsers()).thenReturn("test");
1263 Mockito.when(AppUtils.getUserBackdoorLoginId(mockedRequest)).thenReturn("test");
1264 Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true);
1265 Vector<IdNameValue> entity = new Vector<>();
1266 IdNameValue SecurityEntry = new IdNameValue();
1267 entity.add(SecurityEntry);
1268 Mockito.when(Globals.getSessionParams()).thenReturn("session,2");
1269 Mockito.when(AppUtils.getAllUsers(Matchers.anyString(), Matchers.anyString(), Matchers.anyBoolean())).thenReturn(entity);
1270 assertEquals(raptorControllerAsync.getReportOwnerInList(mockedRequest).getClass(), ArrayList.class);
1273 public void getReportSecurityInfoTest() throws Exception
1275 ReportDefinition rdf1 = mockReportDefinition();
1276 PowerMockito.mockStatic(AppUtils.class);
1277 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1278 Mockito.when(AppUtils.getUserName(Matchers.anyString())).thenReturn("test");
1279 assertEquals(raptorControllerAsync.getReportSecurityInfo(mockedRequest).getClass(), HashMap.class);
1281 @Test(expected = RaptorException.class)
1282 public void retrieveDefTabWiseDataTest() throws Exception
1284 Map<String, String> map = new HashMap<>();
1285 map.put("id", "test");
1286 map.put("detailId", "test");
1287 ServletContext servletContext = PowerMockito.mock(ServletContext.class);
1288 Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext);
1289 PowerMockito.mockStatic(Globals.class);
1290 PowerMockito.mockStatic(AppUtils.class);
1291 Mockito.when(Globals.isSystemInitialized()).thenReturn(true);
1292 ReportDefinition rdf1 = mockReportDefinition();
1293 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(null);
1294 Set<String> set = new HashSet<String>();
1296 Enumeration<String> x = new IteratorEnumeration<String>(set.iterator());
1297 Mockito.when(mockedRequest.getSession().getAttributeNames()).thenReturn(x);
1298 Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
1299 PowerMockito.mockStatic(ReportLoader.class);
1300 Mockito.when(ReportLoader.loadCustomReportXML(Matchers.anyString())).thenReturn("test");
1301 PowerMockito.whenNew(ReportDefinition.class)
1302 .withArguments(Matchers.any(ReportWrapper.class), Matchers.any(HttpServletRequest.class))
1304 // PowerMockito.mockStatic(ReportDefinition.class);
1305 Mockito.when(AppUtils.nvl(Matchers.anyString())).thenReturn("test");
1306 PowerMockito.when(ReportDefinition.unmarshal(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject()))
1308 Vector vc = new Vector<>();
1310 Mockito.when(AppUtils.getQuickLinksMenuIDs()).thenReturn(vc);
1311 assertEquals(raptorControllerAsync.retrieveDefTabWiseData(map, mockedRequest, mockedResponse).getClass(), DefinitionJSON.class);
1314 public void retrieveDataForGivenQuery3Test() throws Exception
1316 QueryJSON queryJSON = new QueryJSON();
1317 queryJSON.setQuery("test");
1318 ServletContext servletContext = PowerMockito.mock(ServletContext.class);
1319 Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext);
1320 ReportDefinition rdf1 = PowerMockito.mock(ReportDefinition.class);
1321 PowerMockito.mockStatic(Globals.class);
1322 Mockito.when(Globals.isSystemInitialized()).thenReturn(true);
1323 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1324 raptorControllerAsync.retrieveDataForGivenQuery(false, queryJSON, mockedRequest, mockedResponse);
1328 public void retrieveDataForGivenQuery1Test() throws Exception
1330 QueryJSON queryJSON = new QueryJSON();
1331 queryJSON.setQuery("test");
1332 ServletContext servletContext = PowerMockito.mock(ServletContext.class);
1333 Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext);
1334 ReportDefinition rdf1 = PowerMockito.mock(ReportDefinition.class);
1335 PowerMockito.mockStatic(Globals.class);
1336 Mockito.when(Globals.isSystemInitialized()).thenReturn(true);
1337 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(null);
1338 raptorControllerAsync.retrieveDataForGivenQuery(false, queryJSON, mockedRequest, mockedResponse);
1342 public void retrieveDataForGivenQuery2Test() throws Exception
1344 QueryJSON queryJSON = new QueryJSON();
1345 queryJSON.setQuery("select");
1346 ServletContext servletContext = PowerMockito.mock(ServletContext.class);
1347 Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext);
1348 ReportDefinition rdf1 = PowerMockito.mock(ReportDefinition.class);
1349 PowerMockito.mockStatic(Globals.class);
1350 Mockito.when(Globals.isSystemInitialized()).thenReturn(true);
1351 Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdf1);
1352 PowerMockito.mockStatic(AppUtils.class);
1353 PowerMockito.mockStatic(ESAPI.class);
1354 PowerMockito.mockStatic(Utils.class);
1355 PowerMockito.mockStatic(SecurityCodecUtil.class);
1357 Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
1358 Mockito.when(Globals.getRequestParams()).thenReturn("test,2");
1359 Mockito.when(Globals.getSessionParams()).thenReturn("session,2");
1360 Codec codec = PowerMockito.mock(Codec.class);
1361 Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec);
1364 PowerMockito.mockStatic(ESAPI.class);
1365 Encoder encoder = PowerMockito.mock(Encoder.class);
1366 Mockito.when(ESAPI.encoder()).thenReturn(encoder);
1367 Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class),Matchers.anyString())).thenReturn("select *");
1368 PowerMockito.mockStatic(ConnectionUtils.class);
1369 Mockito.when(Utils.replaceInString(Matchers.anyString(), Matchers.anyString(), Matchers.anyString())).thenReturn("test");
1371 DataSet set = new DataSet();
1372 Mockito.when(ConnectionUtils.getDataSet("test", "local", true)).thenReturn(set);
1373 PowerMockito.mockStatic(XSSFilter.class);
1374 Mockito.when(XSSFilter.filterRequestOnlyScript(Matchers.anyString())).thenReturn("select distinct from test");
1375 raptorControllerAsync.setViewName("test");
1376 assertEquals(raptorControllerAsync.getViewName(),"test");
1377 assertEquals(raptorControllerAsync.nvl(null),"");
1378 assertEquals(raptorControllerAsync.nvl("test"),"test");
1379 assertEquals(raptorControllerAsync.nvl("","default"),"default");
1380 assertEquals(raptorControllerAsync.nvl("test","default"),"test");
1383 raptorControllerAsync.retrieveDataForGivenQuery(false, queryJSON, mockedRequest, mockedResponse);