/** * The assertion method is useful to manage assertion hard and soft. * @param isBlocking it is a boolean that indicates if it is necessary to use an hard assertion (true) or a soft one (false) * @param assertType it is a string that represents the name of the method to call for a normal assert (example: assertEquals, ...) * @param message it is a string representing the message related to the assertion * @param currentObjs it is the array of objects to analyse in the assertion * @return a boolean, true is the assertion is ok, false otherwise. */ public boolean assertion(boolean isBlocking, String assertType, String message, Object... currentObjs) { boolean checkOk = true; try { if (isBlocking) { Assertion hardAssertion = new Assertion(); executeAssertion(assertType, message, hardAssertion, currentObjs); } else { CustomSoftAssert softAssertion = new CustomSoftAssert(); executeAssertion(assertType, message, softAssertion, currentObjs); if (!softAssertion.getErrorsRetrieved().isEmpty()) { checkOk = false; } } } catch (NoSuchMethodException | IllegalAccessException oEx) { throw new HeatException(logUtils.getExceptionDetails() + "exception '" + oEx.getClass() + "' with message '" + oEx.getLocalizedMessage() + "'"); } catch (InvocationTargetException oEx) { //this is the exception raised in case of failure of the reflection-called method throw new HeatException(oEx.getCause().toString().split(":")[1].trim()); } return checkOk; }
/** * The assertion method is useful to manage assertion hard and soft. * @param isBlocking it is a boolean that indicates if it is necessary to use an hard assertion (true) or a soft one (false) * @param assertType it is a string that represents the name of the method to call for a normal assert (example: assertEquals, ...) * @param message it is a string representing the message related to the assertion * @param currentObjs it is the array of objects to analyse in the assertion * @return a boolean, true is the assertion is ok, false otherwise. */ public boolean assertion(boolean isBlocking, String assertType, String message, Object... currentObjs) { boolean checkOk = true; try { if (isBlocking) { Assertion hardAssertion = new Assertion(); executeAssertion(assertType, message, hardAssertion, currentObjs); } else { CustomSoftAssert softAssertion = new CustomSoftAssert(); executeAssertion(assertType, message, softAssertion, currentObjs); if (!softAssertion.getErrorsRetrieved().isEmpty()) { checkOk = false; } } } catch (NoSuchMethodException | IllegalAccessException oEx) { throw new HeatException(logUtils.getExceptionDetails() + "exception '" + oEx.getClass() + "' with message '" + oEx.getLocalizedMessage() + "'"); } catch (InvocationTargetException oEx) { //this is the exception raised in case of failure of the reflection-called method throw new HeatException(oEx.getCause().toString().split(":")[1].trim()); } return checkOk; }