Package com.consol.citrus.exceptions

Examples of com.consol.citrus.exceptions.ValidationException


       
      Double dValue;
      try {
        dValue = Double.parseDouble(value);
      } catch (Exception e) {
        throw new ValidationException(this.getClass().getSimpleName()
                    + " failed for field '" + fieldName
                    + "'. Received value is '" + value
                    + "' and is not a number", e);
    }
     
      if (dValue.isNaN() || dValue.isInfinite()) {
        throw new ValidationException(this.getClass().getSimpleName()
                    + " failed for field '" + fieldName
                    + "'. Received value is '" + value
                    + "' and not a number");
      }
    }
View Full Code Here


                validateJson(tempReceived, tempControl, context);
            } else {
                throw new CitrusRuntimeException("Unsupported json type " + receivedJson.getClass());
            }
        } catch (IllegalArgumentException e) {
            throw new ValidationException("Failed to validate JSON text:\n" + receivedJsonText, e);
        } catch (ParseException e) {
            throw new CitrusRuntimeException("Failed to parse JSON text", e);
        }
       
        log.info("JSON message validation finished successfully: All values OK");
View Full Code Here

            }
            //check if header expression is variable or function
            headerName = context.resolveDynamicValue(headerName);

            if (!receivedHeaders.containsKey(headerName)) {
                throw new ValidationException("Validation failed: Header element '" + headerName + "' is missing");
            }

            if (receivedHeaders.get(headerName) != null) {
                actualValue = receivedHeaders.get(headerName).toString();
            }
           
            //check if value expression is variable or function
            expectedValue = context.replaceDynamicContentInString(expectedValue);

            try {
                if (actualValue != null) {
                    if (ValidationMatcherUtils.isValidationMatcherExpression(expectedValue)) {
                        ValidationMatcherUtils.resolveValidationMatcher(headerName, actualValue,
                                expectedValue, context);
                        continue;
                    }
                   
                    Assert.isTrue(expectedValue != null,
                            "Values not equal for header element '"
                                + headerName + "', expected '"
                                + null + "' but was '"
                                + actualValue + "'");

                    Assert.isTrue(actualValue.equals(expectedValue),
                            "Values not equal for header element '"
                                + headerName + "', expected '"
                                + expectedValue + "' but was '"
                                + actualValue + "'");
                } else {
                    Assert.isTrue(expectedValue == null || expectedValue.length() == 0,
                            "Values not equal for header element '"
                                + headerName + "', expected '"
                                + expectedValue + "' but was '"
                                + null + "'");
                }
            } catch (IllegalArgumentException e) {
                throw new ValidationException("Validation failed:", e);
            }

            if (log.isDebugEnabled()) {
                log.debug("Validating header element: " + headerName + "='" + expectedValue + "': OK.");
            }
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Validating SOAP fault detail content ...");
        }

        if (receivedDetail == null) {
            throw new ValidationException("Missing SOAP fault detail in received message");
        }

        List<ValidationContext> contexts = new ArrayList<ValidationContext>();
        if (validationContext instanceof SoapFaultDetailValidationContext) {
            contexts.addAll(((SoapFaultDetailValidationContext) validationContext).getValidationContexts());
        }

        List<String> receivedDetailElements = receivedDetail.getFaultDetails();
        List<String> controlDetailElements = controlDetail.getFaultDetails();

        if (controlDetailElements.size() > receivedDetailElements.size()) {
            throw new ValidationException("Missing SOAP fault detail entry in received message");
        }

        for (int i = 0; i < controlDetailElements.size(); i++) {
            String receivedDetailString = receivedDetailElements.get(i);
            String controlDetailString = controlDetailElements.get(i);
View Full Code Here

            log.debug("Received fault detail:\n" + StringUtils.trimWhitespace(received));
            log.debug("Control fault detail:\n" + StringUtils.trimWhitespace(control));
        }

        if (!receivedDetail.equals(controlDetail)) {
            throw new ValidationException("SOAP fault validation failed! Fault detail does not match: expected \n'" +
                    controlDetail + "' \n received \n'" + receivedDetail + "'");
        }

        log.info("SOAP fault detail validation successful");
    }
View Full Code Here

        if (controlAttachment.getContentId() == null) {
            if (attachments.size() == 1) {
                matching = attachments.get(0);
            } else {
                throw new ValidationException("Found more than one SOAP attachment - need control attachment content id for validation!");
            }
        } else {
            // try to find attachment by its content id
            for (Attachment attachment : attachments) {
                if (controlAttachment.getContentId() != null &&
                        controlAttachment.getContentId().equals(attachment.getContentId())) {
                    matching = attachment;
                }
            }
        }

        if (matching != null) {
            return SoapAttachment.from(matching);
        } else {
            throw new ValidationException(String.format("Unable to find SOAP attachment with content id '%s'", controlAttachment.getContentId()));
        }
    }
View Full Code Here

            if (controlFault.getFaultString().equals(CitrusConstants.IGNORE_PLACEHOLDER)) {
                log.debug("SOAP fault-string is ignored by placeholder - skipped fault-string validation");
            } else if (ValidationMatcherUtils.isValidationMatcherExpression(controlFault.getFaultString())) {
                ValidationMatcherUtils.resolveValidationMatcher("SOAP fault string", receivedFault.getFaultString(), controlFault.getFaultString(), context);
            } else {
                throw new ValidationException("SOAP fault validation failed! Fault string does not match - expected: '" +
                        controlFault.getFaultString() + "' but was: '" + receivedFault.getFaultString() + "'");
            }
        }
       
        //fault code validation
View Full Code Here

*/
public class EqualsIgnoreCaseValidationMatcher implements ValidationMatcher {

    public void validate(String fieldName, String value, String control, TestContext context) throws ValidationException {
        if (!value.equalsIgnoreCase(control)) {
            throw new ValidationException(this.getClass().getSimpleName()
                    + " failed for field '" + fieldName
                    + "'. Received value is '" + value
                    + "', control value is '" + control + "'.");
        }
    }
View Full Code Here

*/
public class EndsWithValidationMatcher implements ValidationMatcher {

    public void validate(String fieldName, String value, String control, TestContext context) throws ValidationException {
        if (!value.endsWith(control)) {
            throw new ValidationException(this.getClass().getSimpleName()
                    + " failed for field '" + fieldName
                    + "'. Received value is '" + value
                    + "', control value is '" + control + "'.");
        }
    }
View Full Code Here

                    log.debug("Validating database value for column: ''" +
                            columnName + "'' value as expected: NULL - value OK");
                }
                return;
            } else {
                throw new ValidationException("Validation failed for column: '" +  columnName + "'"
                        + "found value: NULL expected value: " + controlValue);
            }
        }

        if (resultValue.equals(controlValue)) {
            if (log.isDebugEnabled()) {
                log.debug("Validation successful for column: '" + columnName +
                        "' expected value: " + controlValue + " - value OK");
            }
        } else {
            throw new ValidationException("Validation failed for column: '" +  columnName + "'"
                    + " found value: '"
                    + resultValue
                    + "' expected value: "
                    + ((controlValue.length()==0) ? NULL_VALUE : controlValue));
        }
View Full Code Here

TOP

Related Classes of com.consol.citrus.exceptions.ValidationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.