Package com.consol.citrus.validation.script

Examples of com.consol.citrus.validation.script.ScriptValidationContext


    /**
     * Creates new script validation context.
     */
    private void initializeScriptValidationContext() {
        if (scriptValidationContext == null) {
            scriptValidationContext = new ScriptValidationContext(messageType.toString());

            action.getValidationContexts().add(scriptValidationContext);
        }
    }
View Full Code Here


     * Validate SQL result set via validation script, for instance Groovy.
     * @param script
     * @param type
     */
    public ExecuteSQLQueryActionDefinition validateScript(String script, String type) {
        ScriptValidationContext scriptValidationContext = new ScriptValidationContext(type);
        scriptValidationContext.setValidationScript(script);
        action.setScriptValidationContext(scriptValidationContext);
        return this;
    }
View Full Code Here

     * Validate SQL result set via validation script, for instance Groovy.
     * @param scriptResource
     * @param type
     */
    public ExecuteSQLQueryActionDefinition validateScript(Resource scriptResource, String type) {
        ScriptValidationContext scriptValidationContext = new ScriptValidationContext(type);
        try {
            scriptValidationContext.setValidationScript(FileUtils.readToString(scriptResource));
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to read script resource", e);
        }
        action.setScriptValidationContext(scriptValidationContext);
        return this;
View Full Code Here

       
        Assert.assertEquals(action.getEndpoint(), messageEndpoint);
        Assert.assertEquals(action.getMessageType(), MessageType.JSON.name());
        Assert.assertEquals(action.getValidator(), validator);
       
        ScriptValidationContext validationContext = (ScriptValidationContext) action.getValidationContexts().get(0);
       
        Assert.assertEquals(validationContext.getScriptType(), ScriptTypes.GROOVY);
        Assert.assertEquals(validationContext.getValidationScript(), "assert true");
        Assert.assertNull(validationContext.getValidationScriptResourcePath());
       
        verify(applicationContextMock);
    }
View Full Code Here

       
        Assert.assertEquals(action.getEndpoint(), messageEndpoint);
        Assert.assertEquals(action.getMessageType(), MessageType.JSON.name());
        Assert.assertEquals(action.getValidator(), validator);
       
        ScriptValidationContext validationContext = (ScriptValidationContext) action.getValidationContexts().get(0);
       
        Assert.assertEquals(validationContext.getScriptType(), ScriptTypes.GROOVY);
        Assert.assertEquals(validationContext.getValidationScript(), "");
        Assert.assertEquals(validationContext.getValidationScriptResourcePath(), "/path/to/file/File.groovy");
       
        verify(applicationContextMock, resource, resourceFile);
    }
View Full Code Here

        Assert.assertEquals(action.getMessageType(), MessageType.JSON.name());
        Assert.assertEquals(action.getValidator(), validator);
       
        Assert.assertEquals(action.getValidationContexts().size(), 2L);
       
        ScriptValidationContext validationContext = (ScriptValidationContext) action.getValidationContexts().get(0);
       
        Assert.assertEquals(validationContext.getScriptType(), ScriptTypes.GROOVY);
        Assert.assertEquals(validationContext.getValidationScript(), "assert true");
        Assert.assertNull(validationContext.getValidationScriptResourcePath());
       
        ControlMessageValidationContext headerValidationContext = (ControlMessageValidationContext) action.getValidationContexts().get(1);
       
        Assert.assertTrue(headerValidationContext.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);
        Assert.assertNull(((PayloadTemplateMessageBuilder)headerValidationContext.getMessageBuilder()).getPayloadData());
View Full Code Here

        Assert.assertEquals(matchingValidators.get(1).getClass(), GroovyScriptMessageValidator.class);

        Assert.assertNotNull(matchingValidators.get(0).findValidationContext(validationContexts));
        Assert.assertNull(matchingValidators.get(1).findValidationContext(validationContexts));

        validationContexts.add(new ScriptValidationContext(MessageType.PLAINTEXT.name()));
        matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.PLAINTEXT.name(), new DefaultMessage(""), validationContexts);

        Assert.assertNotNull(matchingValidators);
        Assert.assertEquals(matchingValidators.size(), 2L);
        Assert.assertEquals(matchingValidators.get(0).getClass(), PlainTextMessageValidator.class);
View Full Code Here

     * @return
     */
    private ScriptValidationContext getScriptValidationContext(Element scriptElement) {
        String type = scriptElement.getAttribute("type");
       
        ScriptValidationContext validationContext = new ScriptValidationContext(type);
        String filePath = scriptElement.getAttribute("file");
        if (StringUtils.hasText(filePath)) {
            validationContext.setValidationScriptResourcePath(filePath);
        } else {
            validationContext.setValidationScript(DomUtils.getTextValue(scriptElement));
        }
       
        return validationContext;
    }
View Full Code Here

        replay(jdbcTemplate);
       
        List<String> stmts = Collections.singletonList(sql);
        executeSQLQueryAction.setStatements(stmts);
       
        ScriptValidationContext scriptValidationContext = new ScriptValidationContext(ScriptTypes.GROOVY);
        scriptValidationContext.setValidationScript("assert rows.size() == 1\n" +
                "assert rows[0].ORDERTYPE == 'small'\n" +
                "assert rows[0] == [ORDERTYPE:'small', STATUS:'in_progress']");
        executeSQLQueryAction.setScriptValidationContext(scriptValidationContext);
       
        executeSQLQueryAction.execute(context);
View Full Code Here

        List<String> stmts = new ArrayList<String>();
        stmts.add(sql1);
        stmts.add(sql2);
        executeSQLQueryAction.setStatements(stmts);
       
        ScriptValidationContext scriptValidationContext = new ScriptValidationContext(ScriptTypes.GROOVY);
        scriptValidationContext.setValidationScript("assert rows.size() == 4\n" +
                "assert rows[0].ORDERTYPE == 'small'\n" +
                "assert rows[0] == [ORDERTYPE:'small', STATUS:'in_progress']\n" +
                "assert rows[1].ID == '1'\n" +
                "assert rows[3].NAME == 'error3'\n");
        executeSQLQueryAction.setScriptValidationContext(scriptValidationContext);
View Full Code Here

TOP

Related Classes of com.consol.citrus.validation.script.ScriptValidationContext

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.