f69c5dae87e020f74cbae63ee108374b64b27254
[portal/sdk.git] /
1 /*
2  * ============LICENSE_START==========================================
3  * ONAP Portal SDK
4  * ===================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
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
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
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
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
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.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 package org.onap.portalsdk.analytics.xmlobj;
39
40 import static org.junit.Assert.assertEquals;
41 import static org.junit.Assert.assertNull;
42
43 import java.io.InputStream;
44 import java.io.StringReader;
45 import java.sql.Connection;
46 import java.sql.PreparedStatement;
47 import java.sql.ResultSet;
48 import java.sql.ResultSetMetaData;
49 import java.util.ArrayList;
50 import java.util.Date;
51 import java.util.Enumeration;
52 import java.util.HashSet;
53 import java.util.List;
54 import java.util.Set;
55
56 import javax.servlet.http.HttpServletRequest;
57 import javax.servlet.http.HttpServletResponse;
58 import javax.xml.bind.JAXBContext;
59 import javax.xml.bind.JAXBElement;
60 import javax.xml.bind.Marshaller;
61 import javax.xml.bind.Unmarshaller;
62 import javax.xml.namespace.QName;
63
64 import org.junit.Before;
65 import org.junit.Test;
66 import org.junit.runner.RunWith;
67 import org.mockito.InjectMocks;
68 import org.mockito.Matchers;
69 import org.mockito.Mock;
70 import org.mockito.Mockito;
71 import org.mockito.MockitoAnnotations;
72 import org.onap.portalsdk.analytics.error.RaptorException;
73 import org.onap.portalsdk.analytics.model.ReportLoader;
74 import org.onap.portalsdk.analytics.model.base.ReportWrapper;
75 import org.onap.portalsdk.analytics.model.runtime.ChartJSONHelper;
76 import org.onap.portalsdk.analytics.model.runtime.ReportRuntime;
77 import org.onap.portalsdk.analytics.system.AppUtils;
78 import org.onap.portalsdk.analytics.system.DbUtils;
79 import org.onap.portalsdk.analytics.system.Globals;
80 import org.onap.portalsdk.analytics.util.AppConstants;
81 import org.onap.portalsdk.analytics.util.DataSet;
82 import org.onap.portalsdk.core.domain.User;
83 import org.onap.portalsdk.core.restful.domain.EcompRole;
84 import org.onap.portalsdk.core.web.support.UserUtils;
85 import org.powermock.api.mockito.PowerMockito;
86 import org.powermock.core.classloader.annotations.PrepareForTest;
87 import org.powermock.modules.junit4.PowerMockRunner;
88
89 import com.fasterxml.jackson.databind.ObjectMapper;
90
91 @RunWith(PowerMockRunner.class)
92 @PrepareForTest({UserUtils.class,AppUtils.class, DbUtils.class, ReportRuntime.class, Globals.class, UserUtils.class,ReportLoader.class})
93 public class ChartJSONHelperTest {
94     
95         @InjectMocks
96         ChartJSONHelper chartJSONHelper= new ChartJSONHelper();
97         
98         @Mock
99         Connection connection;
100         @Mock
101         PreparedStatement stmt;
102         @Mock
103         ResultSet rs ;
104         @Mock
105         java.sql.Clob clob;
106         @Mock
107         InputStream in;
108         
109         @Before
110         public void setup() {
111                 MockitoAnnotations.initMocks(this);
112         }
113
114         MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
115         HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
116         HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
117
118         
119         @Test(expected = java.lang.ClassCastException.class)
120         public void generateJSONTest() throws RaptorException, Exception
121         {
122                 EcompRole role = new EcompRole();
123                 mockedRequest.getSession().setAttribute("test", role);
124                 Set<String> set = new HashSet<String>(); 
125                 set.add("test");
126             Enumeration<String> x = new IteratorEnumeration<String>(set.iterator());
127                 Mockito.when(mockedRequest.getSession().getAttributeNames()).thenReturn(x);
128                 
129                 User user = new User();
130                 user.setOrgUserId("test12");
131                 PowerMockito.mockStatic(UserUtils.class);
132                 Mockito.when(UserUtils.getUserId(mockedRequest)).thenReturn(3); 
133                 PowerMockito.mockStatic(AppUtils.class);
134                 Mockito.when(mockedRequest.getParameter(AppConstants.RI_REFRESH)).thenReturn("yes");
135                 Mockito.when(AppUtils.getRequestFlag(mockedRequest,"display_content")).thenReturn(true);
136                 Mockito.when(AppUtils.getRequestFlag(mockedRequest, "noFormFields")).thenReturn(true);
137                 PowerMockito.mockStatic(ReportLoader.class);
138                 String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CustomReportType xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"><reportName>name</reportName><reportDescr>desc</reportDescr><chartType>type</chartType><showChartTitle>false</showChartTitle><public>false</public><createId>id</createId><pageNav>false</pageNav></CustomReportType>";
139         Mockito.when(ReportLoader.loadCustomReportXML("1")).thenReturn(str);
140        
141                 ReportRuntime rr = mockReportRunTime1();
142                 rr.setChartType("BarChart3D");
143                 rr.setMultiSeries(true);
144                 rr.setDashboardType(true);
145                 Mockito.when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr);
146                 
147                 PowerMockito.mockStatic(Globals.class);
148                 PowerMockito.mockStatic(DbUtils.class);
149
150                 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
151                 ResultSet rs = PowerMockito.mock(ResultSet.class);
152                 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
153                 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
154                 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
155                 DataSet datset = PowerMockito.mock(DataSet.class);
156                 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
157                 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
158                 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
159                 Mockito.when(DbUtils.getConnection()).thenReturn(connection);
160                 Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("java.lang.String");
161                 Mockito.when(connection.prepareStatement("test")).thenReturn(stmt);
162                 Mockito.when(stmt.executeQuery()).thenReturn(rs);
163                 Mockito.when(Globals.isWeblogicServer()).thenReturn(true);
164                 Mockito.when(rs.getClob(1)).thenReturn(clob);
165                 Mockito.when(rs.next()).thenReturn(true);
166                 Mockito.when(clob.getAsciiStream()).thenReturn(in);
167                 Mockito.when(in.read(Matchers.any())).thenReturn(1);
168 //               PowerMockito.mockStatic(ReportRuntime.class);
169               Mockito.when(ReportRuntime.unmarshal(str, "1", mockedRequest)).thenReturn(rr);
170                         Mockito.when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test");
171                         Mockito.when(AppUtils.nvl(rr.getLegendLabelAngle())).thenReturn("standard");
172                         Mockito.when(AppUtils.getRequestNvlValue(Matchers.any(), Matchers.anyString())).thenReturn("test");
173                         Mockito.when(AppUtils.nvl("Y")).thenReturn("Y");
174                         Mockito.when(AppUtils.nvl("bottom")).thenReturn("Y");
175                         Mockito.when(AppUtils.nvl("test")).thenReturn("test|");
176                         Mockito.when(AppUtils.getRequestValue(mockedRequest, "c_dashboard")).thenReturn("1");
177                         Mockito.when(ReportLoader.isDashboardType("-1")).thenReturn(false);
178                 assertEquals(chartJSONHelper.generateJSON("1", mockedRequest, false).getClass(), String.class);
179         }
180         
181         
182         @Test(expected = java.lang.NullPointerException.class)
183         public void generateJSONTest1() throws RaptorException, Exception
184         {
185                 EcompRole role = new EcompRole();
186                 mockedRequest.getSession().setAttribute("test", role);
187                 
188                 Set<String> set = new HashSet<String>(); 
189             Enumeration<String> x = new IteratorEnumeration<String>(set.iterator());
190                 Mockito.when(mockedRequest.getSession().getAttributeNames()).thenReturn(x);
191                 User user = new User();
192                 user.setOrgUserId("test12");
193                 PowerMockito.mockStatic(UserUtils.class);
194                 Mockito.when(UserUtils.getUserId(mockedRequest)).thenReturn(3); 
195                 PowerMockito.mockStatic(AppUtils.class);
196                 Mockito.when(mockedRequest.getParameter(AppConstants.RI_REFRESH)).thenReturn("yes");
197                 Mockito.when(AppUtils.getRequestFlag(mockedRequest,AppConstants.RI_DISPLAY_CONTENT)).thenReturn(true);
198                 Mockito.when(AppUtils.getRequestFlag(mockedRequest, "noFormFields")).thenReturn(false);
199                 PowerMockito.mockStatic(ReportLoader.class);
200             ReportRuntime rr = mockReportRunTime();
201                 PowerMockito.mockStatic(Globals.class);
202                 PowerMockito.mockStatic(DbUtils.class);
203
204                 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
205                 ResultSet rs = PowerMockito.mock(ResultSet.class);
206                 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
207                 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
208                 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
209                 DataSet datset = PowerMockito.mock(DataSet.class);
210                 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
211                 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
212                 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
213                 CustomReportType customReportType = new CustomReportType();
214                 Mockito.when(DbUtils.getConnection()).thenReturn(connection);
215                 Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("test");
216                 Mockito.when(connection.prepareStatement("test")).thenReturn(stmt);
217                 Mockito.when(stmt.executeQuery()).thenReturn(rs);
218                 Mockito.when(Globals.isWeblogicServer()).thenReturn(false);
219                 Mockito.when(Globals.isPostgreSQL()).thenReturn(true);
220                 Mockito.when(rs.getClob(1)).thenReturn(clob);
221                 Mockito.when(rs.next()).thenReturn(true);
222                 Mockito.when(clob.getAsciiStream()).thenReturn(in);
223                 Mockito.when(in.read(Matchers.any())).thenReturn(1);
224                 Mockito.when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_DASHBOARD_ID)).thenReturn("test");
225                 mockedRequest.getSession().setAttribute("report_runtime", rr);          
226                 chartJSONHelper.generateJSON("1", mockedRequest, false);
227         }
228         
229         @Test
230         public void generateJSON1Test() throws RaptorException, Exception
231         {
232                 
233                 PowerMockito.mockStatic(Globals.class);
234                 PowerMockito.mockStatic(DbUtils.class);
235
236                 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
237                 ResultSet rs = PowerMockito.mock(ResultSet.class);
238                 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
239                 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
240                 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
241                 DataSet datset = PowerMockito.mock(DataSet.class);
242                 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
243                 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
244                 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
245                 CustomReportType customReportType = new CustomReportType();
246                 DataSourceList dataSourceList = new DataSourceList();
247                 List<DataSourceType> list = new ArrayList<>();
248                 DataSourceType dataSourceType = new DataSourceType();
249                 dataSourceType.setTableName("test");
250                 dataSourceType.setRefTableId("1");
251                 List<DataColumnType> dataColumnTypeList = new ArrayList<>();
252                 DataColumnType dataColumnType = new DataColumnType();
253                 dataColumnType.setChartGroup("test");
254                 dataColumnType.setYAxis("test");
255                 dataColumnTypeList.add(dataColumnType);
256                 DataColumnList dataColumnList = new DataColumnList();
257                 dataColumnList.dataColumn = dataColumnTypeList;
258                 dataSourceType.setDataColumnList(dataColumnList);
259                 list.add(dataSourceType);
260                 dataSourceList.dataSource = list;
261                 customReportType.setReportType("test");
262                 customReportType.setDataSourceList(dataSourceList);
263                 ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions();
264                 chartAdditionalOptions.setLabelAngle("test");
265                 chartAdditionalOptions.setTimeSeriesRender("test");
266                 chartAdditionalOptions.setMultiSeries(false);
267                 customReportType.setChartAdditionalOptions(chartAdditionalOptions);
268                 FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class);
269                 formFieldList.setComment("test");
270                 customReportType.setFormFieldList(formFieldList);
271                 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", "1", true);
272                 PowerMockito.mockStatic(UserUtils.class);
273                 ReportRuntime rr = new ReportRuntime(reportWrapper, mockedRequest);
274                 rr.setLegendLabelAngle("test");
275                 rr.setMultiSeries(false);
276                 rr.setChartType("test");
277                 PowerMockito.mockStatic(AppUtils.class);
278                 Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test12");
279                 Mockito.when(AppUtils.nvl("test")).thenReturn("test");
280                 Mockito.when(AppUtils.nvl("N")).thenReturn("Y");
281                 Mockito.when(AppUtils.nvl("bottom")).thenReturn("Y");
282                 Mockito.when(UserUtils.getUserId(mockedRequest)).thenReturn(1);
283                 assertEquals(chartJSONHelper.generateJSON(rr, mockedRequest, false).getClass(), String.class);
284         }
285         
286
287         
288         public ReportRuntime mockReportRunTime() throws Exception
289         {               
290                 PowerMockito.mockStatic(Globals.class);
291                 PowerMockito.mockStatic(DbUtils.class);
292                 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
293                 ResultSet rs = PowerMockito.mock(ResultSet.class);
294                 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
295                 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
296                 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
297                 DataSet datset = PowerMockito.mock(DataSet.class);
298                 // datset = new DataSet(rs);
299                 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
300                 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
301                 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
302                 CustomReportType customReportType = new CustomReportType();
303                 DataSourceList dataSourceList = new DataSourceList();
304                 List<DataSourceType> list = new ArrayList<>();
305                 DataSourceType dataSourceType = new DataSourceType();
306                 dataSourceType.setTableName("test");
307                 dataSourceType.setRefTableId("1");
308                 List<DataColumnType> dataColumnTypeList = new ArrayList<>();
309                 DataColumnType dataColumnType = new DataColumnType();
310                 dataColumnType.setChartGroup("test");
311                 dataColumnType.setYAxis("test");
312                 dataColumnType.setColName("test");
313                 dataColumnType.setColOnChart("test");
314                 dataColumnType.setDisplayName("test");
315                 dataColumnTypeList.add(dataColumnType);
316                 DataColumnList dataColumnList = new DataColumnList();
317                 dataColumnList.dataColumn = dataColumnTypeList;
318                 dataSourceType.setDataColumnList(dataColumnList);
319                 list.add(dataSourceType);
320                 dataSourceList.dataSource = list;
321                 customReportType.setReportType("test");
322                 customReportType.setDataSourceList(dataSourceList);
323                 ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions();
324                 chartAdditionalOptions.setLabelAngle("test");
325                 chartAdditionalOptions.setTimeSeriesRender("test");
326                 chartAdditionalOptions.setMultiSeries(false);
327                 customReportType.setChartAdditionalOptions(chartAdditionalOptions);
328                 FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class);
329                 formFieldList.setComment("test");
330                 customReportType.setFormFieldList(formFieldList);
331                 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", "1", true);
332                 PowerMockito.mockStatic(UserUtils.class);
333                 ReportRuntime rr = new ReportRuntime(reportWrapper, mockedRequest);
334                 rr.setLegendLabelAngle("test");
335                 rr.setMultiSeries(false);
336                 rr.setChartType("test");
337                 return rr;
338         }
339         
340         public ReportRuntime mockReportRunTime1() throws Exception
341         {               
342                 PowerMockito.mockStatic(Globals.class);
343                 PowerMockito.mockStatic(DbUtils.class);
344                 Mockito.when(Globals.getReportUserAccess()).thenReturn("test");
345                 ResultSet rs = PowerMockito.mock(ResultSet.class);
346                 ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class);
347                 Mockito.when(rsmd.getColumnCount()).thenReturn(1);
348                 Mockito.when(rs.getMetaData()).thenReturn(rsmd);
349                 DataSet datset = PowerMockito.mock(DataSet.class);
350                 // datset = new DataSet(rs);
351                 Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
352                 Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset);
353                 Mockito.when(Globals.getNewScheduleData()).thenReturn("test");
354                 CustomReportType customReportType = new CustomReportType();
355                 DataSourceList dataSourceList = new DataSourceList();
356                 List<DataSourceType> list = new ArrayList<>();
357                 DataSourceType dataSourceType = new DataSourceType();
358                 dataSourceType.setTableName("test");
359                 dataSourceType.setRefTableId("1");
360                 dataSourceType.setTableId("1");
361                 List<DataColumnType> dataColumnTypeList = new ArrayList<>();
362                 DataColumnType dataColumnType = new DataColumnType();
363                 dataColumnType.setChartGroup("test");
364                 dataColumnType.setYAxis("test");
365                 dataColumnType.setColName("[test");
366                 dataColumnType.setColOnChart("LEGEND");
367                 dataColumnType.setDisplayName("chart_total");
368                 dataColumnType.setColId("1");
369                 dataColumnType.setTableId("1");
370                 dataColumnType.setColType("DATE");
371                 dataColumnTypeList.add(dataColumnType);
372                 DataColumnList dataColumnList = new DataColumnList();
373                 dataColumnList.dataColumn = dataColumnTypeList;
374                 dataSourceType.setDataColumnList(dataColumnList);
375                 list.add(dataSourceType);
376                 dataSourceList.dataSource = list;
377                 customReportType.setReportType("test");
378                 customReportType.setReportTitle("test");
379                 customReportType.setDataSourceList(dataSourceList);
380                 ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions();
381                 chartAdditionalOptions.setLabelAngle("test");
382                 chartAdditionalOptions.setTimeSeriesRender("test");
383                 chartAdditionalOptions.setMultiSeries(false);
384                 customReportType.setChartAdditionalOptions(chartAdditionalOptions);
385                 FormFieldList formFieldList = new FormFieldList();
386                 formFieldList.setComment("test");
387                 List<FormFieldType> formFields = new ArrayList<>();
388                 FormFieldType formFieldType = new FormFieldType();
389                 formFieldType.setFieldId("test");
390                 formFieldType.setColId("1");
391                 formFieldType.setFieldName("test");
392                 formFieldType.setFieldType("type");
393                 formFieldType.setValidationType("validation");
394                 formFieldType.setMandatory("Y");
395                 formFieldType.setDefaultValue("test");
396                 formFields.add(formFieldType);
397                 formFieldList.formField = formFields;
398                 customReportType.setFormFieldList(formFieldList);
399                 ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", "1", true);
400                 PowerMockito.mockStatic(UserUtils.class);
401                 Mockito.when(Globals.getRequestParams()).thenReturn("test");
402                 Mockito.when(Globals.getSessionParams()).thenReturn("test");
403                 Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test");
404                 PowerMockito.mockStatic(AppUtils.class);
405                 Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test12");
406                 ReportRuntime rr = new ReportRuntime(reportWrapper, mockedRequest);
407                 rr.setLegendLabelAngle("test");
408                 rr.setMultiSeries(false);
409                 rr.setChartType("test");
410                 return rr;
411         }
412         
413         @Test
414         public void getFlagFromDateStrTest()
415         {       
416                 assertEquals(chartJSONHelper.getFlagFromDateStr("11/11/2000"),3);
417                 assertEquals(chartJSONHelper.getFlagFromDateStr("111, 11/11/2000"),0);
418                 assertEquals(chartJSONHelper.getFlagFromDateStr("00/00/0000"),3);
419         }
420         
421         @Test
422         public void getDateFromDateStrTest()
423         {
424                 Date date = new Date("Sat Nov 11 00:00:00 EST 2000");
425                 assertNull(chartJSONHelper.getDateFromDateStr("111, 11/11/2000"));
426         }
427         
428         @Test
429         public void generateChartSQLTest() throws Exception
430         {
431                 ReportRuntime rr = mockReportRunTime();
432                 rr.setWholeSQL("select * from test");
433                 chartJSONHelper = new ChartJSONHelper(rr);
434                 assertEquals(chartJSONHelper.generateChartSQL("test", mockedRequest),"SELECT 1 a, 1 a_1, 1 FROM test  ORDER BY 1");
435         }
436         
437         @Test
438         public void generateChartSQL1Test() throws Exception
439         {
440                 ReportRuntime rr = mockReportRunTime1();
441                 rr.setWholeSQL("select * from test");
442                 rr.setReportType("Hive");
443                 chartJSONHelper = new ChartJSONHelper(rr);
444                 assertEquals(chartJSONHelper.generateChartSQL("test", mockedRequest),"SELECT TO_CHAR([test, '%m/%d/%Y') 1, TO_CHAR([test, '%m/%d/%Y') 1_1, chart_total chart_total, 1 FROM test ");
445         }
446         
447         public static void main(String[] args) throws Exception {
448                 CustomReportType t = new CustomReportType();
449                 t.setPageNav(false);
450                 t.setReportName("name");
451                 t.setReportDescr("desc");
452                 t.setChartType("type");
453                 t.setCreateId("id");
454                 t.setCreateDate(null);
455                 
456                 ObjectMapper mapper = new ObjectMapper();
457
458                 
459                 EcompRole  role = new EcompRole();
460                 role.setName("test");
461                 role.setId((long) 1);
462                 role.setRoleFunctions(null);
463                 
464                 System.out.println(mapper.writeValueAsString(role));
465                 JAXBContext jc = JAXBContext.newInstance("org.onap.portalsdk.analytics.xmlobj");
466                 JAXBElement<CustomReportType> jaxbElement =
467                                   new JAXBElement(new QName("CustomReportType"), 
468                                                   CustomReportType.class,t);
469                 Unmarshaller u = jc.createUnmarshaller();
470                 StringReader rs = new java.io.StringReader(
471                                 mapper.writeValueAsString(role));
472                 System.out.println(rs);
473                 
474                 Marshaller jaxbMarshaller = jc.createMarshaller();
475                 jaxbMarshaller.marshal(jaxbElement, System.out);
476                 String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CustomReportType xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"><reportName>name</reportName><reportDescr>desc</reportDescr><chartType>type</chartType><showChartTitle>false</showChartTitle><public>false</public><createId>id</createId><pageNav>false</pageNav></CustomReportType>";
477
478                 javax.xml.bind.JAXBElement<CustomReportType> doc = (javax.xml.bind.JAXBElement<CustomReportType>) u.unmarshal(new java.io.StringReader(
479                                 str));
480                 System.out.println(doc.getValue());
481                         
482         }
483         
484         
485 }
486