diff --git a/core-java/src/main/java/io/github/boykaframework/actions/data/DataRow.java b/core-java/src/main/java/io/github/boykaframework/actions/data/DataRow.java index 83af10a07..b263849bb 100644 --- a/core-java/src/main/java/io/github/boykaframework/actions/data/DataRow.java +++ b/core-java/src/main/java/io/github/boykaframework/actions/data/DataRow.java @@ -24,6 +24,7 @@ import java.util.Objects; import io.github.boykaframework.actions.interfaces.data.IDataRow; +import lombok.ToString; import org.apache.logging.log4j.Logger; /** @@ -32,6 +33,7 @@ * @author Wasiq Bhamla * @since 28-Nov-2023 */ +@ToString class DataRow implements IDataRow { private static final Logger LOGGER = getLogger (); diff --git a/core-java/src/main/java/io/github/boykaframework/enums/Message.java b/core-java/src/main/java/io/github/boykaframework/enums/Message.java index 150db43ed..261eb2cae 100644 --- a/core-java/src/main/java/io/github/boykaframework/enums/Message.java +++ b/core-java/src/main/java/io/github/boykaframework/enums/Message.java @@ -278,6 +278,11 @@ public enum Message { * Test Error. */ TEST_ERROR ("Test error..."), + /** + * Unsupported Excel value format. + */ + UNSUPPORTED_EXCEL_VALUE_FORMAT ( + "The Excel value format of ({0}) is not supported. Please create a GitHub issue " + "with details to handle the same."), /** * User name required for cloud execution */ diff --git a/core-java/src/main/java/io/github/boykaframework/parser/ExcelParser.java b/core-java/src/main/java/io/github/boykaframework/parser/ExcelParser.java index 9e571ed60..f147626b9 100644 --- a/core-java/src/main/java/io/github/boykaframework/parser/ExcelParser.java +++ b/core-java/src/main/java/io/github/boykaframework/parser/ExcelParser.java @@ -22,6 +22,7 @@ import static io.github.boykaframework.enums.Message.ERROR_READING_FILE; import static io.github.boykaframework.enums.Message.ERROR_SETTER_NOT_FOUND; import static io.github.boykaframework.enums.Message.PATH_NOT_DIRECTORY; +import static io.github.boykaframework.enums.Message.UNSUPPORTED_EXCEL_VALUE_FORMAT; import static io.github.boykaframework.manager.ParallelSession.getSession; import static io.github.boykaframework.utils.ErrorHandler.handleAndThrow; import static io.github.boykaframework.utils.ErrorHandler.throwError; @@ -42,7 +43,6 @@ import java.util.List; import java.util.Objects; -import io.github.boykaframework.utils.ErrorHandler; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -142,7 +142,7 @@ private List getDataFromFile (final List data, final Constructo } result.add (dataObject); } catch (final InstantiationException | IllegalAccessException | InvocationTargetException e) { - ErrorHandler.handleAndThrow (ERROR_CALLING_SETTER, e, format ("set{0}", capitalize (header)), dataCtor.getClass () + handleAndThrow (ERROR_CALLING_SETTER, e, format ("set{0}", capitalize (header)), dataCtor.getClass () .getSimpleName ()); } } @@ -162,11 +162,17 @@ private void setFieldValue (final T dataObject, final Object value, final St } else if (value instanceof Double) { method = dataClass.getMethod (methodName, Double.class); method.invoke (dataObject, Double.parseDouble (value.toString ())); + } else if (value instanceof Boolean) { + method = dataClass.getMethod (methodName, Boolean.class); + method.invoke (dataObject, Boolean.parseBoolean (value.toString ())); + } else { + throwError (UNSUPPORTED_EXCEL_VALUE_FORMAT, value.getClass () + .getSimpleName ()); } } catch (final IllegalAccessException | InvocationTargetException e) { - ErrorHandler.handleAndThrow (ERROR_CALLING_SETTER, e, methodName, dataClass.getSimpleName ()); + handleAndThrow (ERROR_CALLING_SETTER, e, methodName, dataClass.getSimpleName ()); } catch (final NoSuchMethodException e) { - ErrorHandler.handleAndThrow (ERROR_SETTER_NOT_FOUND, e, methodName, dataClass.getSimpleName (), value.getClass () + handleAndThrow (ERROR_SETTER_NOT_FOUND, e, methodName, dataClass.getSimpleName (), value.getClass () .getSimpleName ()); } } diff --git a/core-java/src/test/java/io/github/boykaframework/testng/api/restful/data/BookingDataProviders.java b/core-java/src/test/java/io/github/boykaframework/testng/api/restful/data/BookingDataProviders.java index c89f2354b..7fab2bd3b 100644 --- a/core-java/src/test/java/io/github/boykaframework/testng/api/restful/data/BookingDataProviders.java +++ b/core-java/src/test/java/io/github/boykaframework/testng/api/restful/data/BookingDataProviders.java @@ -50,6 +50,7 @@ public static Iterator getBookingData () { public static Iterator getBookingDataObject () { final var rows = DATA.get (BookingTestData.class); return rows.stream () + .filter (BookingTestData::getEnabled) .map (d -> new Object[] { d }) .toList () .iterator (); diff --git a/core-java/src/test/java/io/github/boykaframework/testng/api/restful/pojo/BookingTestData.java b/core-java/src/test/java/io/github/boykaframework/testng/api/restful/pojo/BookingTestData.java index a4656488b..13991dc59 100644 --- a/core-java/src/test/java/io/github/boykaframework/testng/api/restful/pojo/BookingTestData.java +++ b/core-java/src/test/java/io/github/boykaframework/testng/api/restful/pojo/BookingTestData.java @@ -22,12 +22,13 @@ @ToString @Data public class BookingTestData { - private String additionalNeeds; - private String checkInDate; - private String checkOutDate; - private String depositPaid; - private String firstName; - private String lastName; - private Double srNo; - private Double totalPrice; + private String additionalNeeds; + private String checkInDate; + private String checkOutDate; + private String depositPaid; + private Boolean enabled; + private String firstName; + private String lastName; + private Double srNo; + private Double totalPrice; } diff --git a/core-java/src/test/resources/data/excel/BookingData.xlsx b/core-java/src/test/resources/data/excel/BookingData.xlsx index d6b4459e2..abfc6dd19 100644 Binary files a/core-java/src/test/resources/data/excel/BookingData.xlsx and b/core-java/src/test/resources/data/excel/BookingData.xlsx differ