Search in sources :

Example 1 with RbvVerificationException

use of com.axway.ats.rbv.model.RbvVerificationException in project ats-framework by Axway.

the class VerificationSkeleton method verify.

/**
     * Verify that all rules match using the given expected result
     * 
     * @param expectedResult the expected result
     * @param endOnFirstMatch end on first match or keep testing until all polling attempts are exhausted
     * @param endOnFirstFailure end or first failure or keep testing until all polling attempts are exhausted
     * 
     * @return the matched meta data
     * @throws RbvException on error doing the verifications
     */
protected List<MetaData> verify(boolean expectedResult, boolean endOnFirstMatch, boolean endOnFirstFailure) throws RbvException {
    try {
        this.executor.setRootRule(this.rootRule);
        applyConfigurationSettings();
        Monitor monitor = new Monitor(getMonitorName(), this.folder, this.executor, new PollingParameters(pollingInitialDelay, pollingInterval, pollingAttempts), expectedResult, endOnFirstMatch, endOnFirstFailure);
        ArrayList<Monitor> monitors = new ArrayList<Monitor>();
        monitors.add(monitor);
        SimpleMonitorListener monitorListener = new SimpleMonitorListener(monitors);
        boolean evaluationPassed = monitorListener.evaluateMonitors(pollingTimeout);
        String lastRuleName = monitor.getLastRuleName();
        String classSimpleName = getClass().getSimpleName();
        if ("FileSystemVerification".equals(classSimpleName) && !expectedResult) {
            lastRuleName = "File do exist!";
        } else if (lastRuleName != null) {
            lastRuleName = "Rule failed '" + lastRuleName + "'!";
        } else {
            if ("DbVerification".equals(classSimpleName)) {
                lastRuleName = "Database connection problem!";
            } else if ("FileSystemVerification".equals(classSimpleName) && expectedResult) {
                lastRuleName = "File does not exist!";
            } else {
                lastRuleName = "Server connection problem!";
            }
        }
        if (evaluationPassed == false) {
            throw new RbvVerificationException("Verification failed. " + lastRuleName);
        }
        return monitor.getAllMatchedMetaData();
    } catch (ConfigurationException ce) {
        throw new RbvException("RBV configuration error", ce);
    }
}
Also used : Monitor(com.axway.ats.rbv.Monitor) RbvVerificationException(com.axway.ats.rbv.model.RbvVerificationException) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) ConfigurationException(com.axway.ats.config.exceptions.ConfigurationException) RbvException(com.axway.ats.rbv.model.RbvException) ArrayList(java.util.ArrayList) PollingParameters(com.axway.ats.rbv.PollingParameters)

Aggregations

ConfigurationException (com.axway.ats.config.exceptions.ConfigurationException)1 Monitor (com.axway.ats.rbv.Monitor)1 PollingParameters (com.axway.ats.rbv.PollingParameters)1 SimpleMonitorListener (com.axway.ats.rbv.SimpleMonitorListener)1 RbvException (com.axway.ats.rbv.model.RbvException)1 RbvVerificationException (com.axway.ats.rbv.model.RbvVerificationException)1 ArrayList (java.util.ArrayList)1