paypal / SeLion

Enabling Test Automation in Java
http://selion.io
Apache License 2.0
281 stars 233 forks source link

Support "Date" date type in ExcelDataProvider #144

Closed reachkrishnaraj closed 9 years ago

reachkrishnaraj commented 9 years ago

The framework doesnt seem to handle the "Date" data type in ExcelDataProvider. I see the following error when trying to read a class that contains a field that belongs to "Date" type.

Below is the stacktrace.

I understand there are changes required in the "com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.prepareObject" method and trying for a fix.

In the meantime, any pointers to easily fix it will greatly help.

Error Stacktrace:

com.paypal.selion.platform.dataprovider.ExcelDataProviderException at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.prepareObject(AbstractExcelDataProvider.java:300) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.getSingleExcelRow(AbstractExcelDataProvider.java:157) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.getSingleExcelRow(AbstractExcelDataProvider.java:114) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.setValueForArrayType(AbstractExcelDataProvider.java:372) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.prepareObject(AbstractExcelDataProvider.java:291) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.getSingleExcelRow(AbstractExcelDataProvider.java:157) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.getSingleExcelRow(AbstractExcelDataProvider.java:114) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.setValueForNonArrayType(AbstractExcelDataProvider.java:433) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.prepareObject(AbstractExcelDataProvider.java:297) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.getSingleExcelRow(AbstractExcelDataProvider.java:157) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.getSingleExcelRow(AbstractExcelDataProvider.java:114) at com.paypal.selion.platform.dataprovider.SimpleExcelDataProvider.getSingleExcelRow(SimpleExcelDataProvider.java:149) at com.walmart.qa.asda.dataread.BackendDataReader.getSingleRowOfBackEndData(BackendDataReader.java:54) at com.walmart.qa.asda.AppTest.testExcelDataProvider(AppTest.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.setValueForNonArrayType(AbstractExcelDataProvider.java:419) at com.paypal.selion.platform.dataprovider.AbstractExcelDataProvider.prepareObject(AbstractExcelDataProvider.java:297) ... 26 more Caused by: java.lang.IllegalArgumentException at java.util.Date.parse(Date.java:617) at java.util.Date.(Date.java:274) ... 32 more java.lang.NullPointerException at com.walmart.qa.asda.AppTest.testExcelDataProvider(AppTest.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

ysecaran commented 9 years ago

@reachkrishnaraj Please elaborate the use case and also share some sample data for me to understand this further. Also, what is it that you are going to use this date for?

sundaramrajendran commented 9 years ago

@reachkrishnaraj Please try to use the String data type in POJO to load the date value from excel and use SimpleDateFormat to convert to date format.

reachkrishnaraj commented 9 years ago

Hi folks, sorry, the Date data type is support and was able to test it. Closing the issue.