Skip to content
Advertisement

Exception in thread “main” java.lang.ClassCastException: www.logisense.com.pogos.wizardNewProduct.ProductWorkingDates cannot be cast to java.util.List

I’m trying to convert Object to JSON, I have the following POGO classes:

JavaScript

I’m passing the data through cucumber, and I have the following Scenario

Scenario: Provider enters a data in ProductWorkingDates

JavaScript

and I have my step Defenition class, where I’m trying to catch the data through the List<Map<String, String>> productWorkingDates;

JavaScript

Advertisement

Answer

From what I can see, productWorkingDates1 is not a list, but rather an element of a list, of type ProductWorkingDates : ProductWorkingDates productWorkingDates1 = new ProductWorkingDates();

When trying to cast from ProductWorkingDates to List, you are facing the exception you have described : (List<ProductWorkingDates>) productWorkingDates1

What you would need is something looking like this :

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement