ControlMessageValidationContext validationContext;
PayloadTemplateMessageBuilder messageBuilder;
GroovyScriptMessageBuilder groovyMessageBuilder;
// 1st action
ReceiveMessageAction action = getNextTestActionFromTest();
Assert.assertTrue(action.getMessageSelector().isEmpty());
Assert.assertNull(action.getMessageSelectorString());
Assert.assertEquals(action.getEndpoint(), beanDefinitionContext.getBean("myMessageEndpoint", Endpoint.class));
Assert.assertNull(action.getEndpointUri());
Assert.assertEquals(action.getValidationContexts().size(), 2);
Assert.assertTrue(action.getValidationContexts().get(0) instanceof ControlMessageValidationContext);
validationContext = (ControlMessageValidationContext)action.getValidationContexts().get(0);
Assert.assertTrue(validationContext.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);
messageBuilder = (PayloadTemplateMessageBuilder)validationContext.getMessageBuilder();
Assert.assertNull(messageBuilder.getPayloadResourcePath());
Assert.assertNotNull(messageBuilder.getPayloadData());
Assert.assertEquals(messageBuilder.getPayloadData().trim(), "<TestMessage>Hello Citrus</TestMessage>");
Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 1);
Assert.assertEquals(messageBuilder.getMessageHeaders().get("operation"), "Test");
Assert.assertEquals(messageBuilder.getMessageInterceptors().size(), 0);
Assert.assertNull(action.getDataDictionary());
// 2nd action
action = getNextTestActionFromTest();
Assert.assertEquals(action.getMessageSelector().size(), 1);
Assert.assertEquals(action.getMessageSelector().get("operation"), "Test");
Assert.assertNull(action.getMessageSelectorString());
Assert.assertEquals(action.getEndpoint(), beanDefinitionContext.getBean("myMessageEndpoint", Endpoint.class));
Assert.assertNull(action.getEndpointUri());
Assert.assertEquals(action.getValidationContexts().size(), 2);
Assert.assertTrue(action.getValidationContexts().get(0) instanceof ControlMessageValidationContext);
validationContext = (ControlMessageValidationContext)action.getValidationContexts().get(0);
Assert.assertTrue(validationContext.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);
messageBuilder = (PayloadTemplateMessageBuilder)validationContext.getMessageBuilder();
Assert.assertNotNull(messageBuilder.getPayloadResourcePath());
Assert.assertEquals(messageBuilder.getPayloadResourcePath(), "classpath:com/consol/citrus/actions/test-request-payload.xml");
Assert.assertNull(messageBuilder.getPayloadData());
Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0);
Assert.assertEquals(messageBuilder.getMessageInterceptors().size(), 0);
// 3rd action
action = getNextTestActionFromTest();
Assert.assertTrue(action.getMessageSelector().isEmpty());
Assert.assertEquals(action.getMessageSelectorString(), "operation = 'Test'");
Assert.assertEquals(action.getEndpoint(), beanDefinitionContext.getBean("myMessageEndpoint", Endpoint.class));
Assert.assertNull(action.getEndpointUri());
// 4th action
action = getNextTestActionFromTest();
Assert.assertTrue(action.getMessageSelector().isEmpty());
Assert.assertNull(action.getMessageSelectorString());
Assert.assertEquals(action.getEndpoint(), beanDefinitionContext.getBean("myMessageEndpoint", Endpoint.class));
Assert.assertNull(action.getEndpointUri());
Assert.assertEquals(action.getValidationContexts().size(), 2);
Assert.assertTrue(action.getValidationContexts().get(0) instanceof ControlMessageValidationContext);
validationContext = (ControlMessageValidationContext)action.getValidationContexts().get(0);
Assert.assertTrue(validationContext.getMessageBuilder() instanceof GroovyScriptMessageBuilder);
groovyMessageBuilder = (GroovyScriptMessageBuilder)validationContext.getMessageBuilder();
Assert.assertNull(groovyMessageBuilder.getScriptResourcePath());
Assert.assertNotNull(groovyMessageBuilder.getScriptData());
Assert.assertEquals(groovyMessageBuilder.getScriptData().trim(), "println '<TestMessage>Hello Citrus</TestMessage>'");
Assert.assertEquals(groovyMessageBuilder.getMessageHeaders().size(), 2);
Assert.assertEquals(groovyMessageBuilder.getMessageHeaders().get("header1"), "Test");
Assert.assertEquals(groovyMessageBuilder.getMessageHeaders().get("header2"), "Test");
// 5th action
action = getNextTestActionFromTest();
Assert.assertTrue(action.getMessageSelector().isEmpty());
Assert.assertNull(action.getMessageSelectorString());
Assert.assertEquals(action.getEndpoint(), beanDefinitionContext.getBean("myMessageEndpoint", Endpoint.class));
Assert.assertNull(action.getEndpointUri());
Assert.assertEquals(action.getValidationContexts().size(), 2);
Assert.assertTrue(action.getValidationContexts().get(0) instanceof ControlMessageValidationContext);
validationContext = (ControlMessageValidationContext)action.getValidationContexts().get(0);
Assert.assertTrue(validationContext.getMessageBuilder() instanceof GroovyScriptMessageBuilder);
groovyMessageBuilder = (GroovyScriptMessageBuilder)validationContext.getMessageBuilder();
Assert.assertNotNull(groovyMessageBuilder.getScriptResourcePath());
Assert.assertEquals(groovyMessageBuilder.getScriptResourcePath(), "classpath:com/consol/citrus/script/example.groovy");
Assert.assertNull(groovyMessageBuilder.getScriptData());
// 6th action
action = getNextTestActionFromTest();
Assert.assertEquals(action.getVariableExtractors().size(), 2);
Assert.assertTrue(action.getVariableExtractors().get(0) instanceof MessageHeaderVariableExtractor);
MessageHeaderVariableExtractor headerVariableExtractor = (MessageHeaderVariableExtractor)action.getVariableExtractors().get(0);
Assert.assertTrue(action.getVariableExtractors().get(1) instanceof XpathPayloadVariableExtractor);
XpathPayloadVariableExtractor variableExtractor = (XpathPayloadVariableExtractor)action.getVariableExtractors().get(1);
Assert.assertEquals(variableExtractor.getNamespaces().size(), 0L);
Assert.assertEquals(headerVariableExtractor.getHeaderMappings().size(), 1);
Assert.assertEquals(headerVariableExtractor.getHeaderMappings().get("operation"), "operation");
Assert.assertEquals(variableExtractor.getxPathExpressions().size(), 1);
Assert.assertEquals(variableExtractor.getxPathExpressions().get("/TestMessage/text()"), "text");
Assert.assertNotNull(action.getDataDictionary());
// 7th action
action = getNextTestActionFromTest();
Assert.assertEquals(action.getValidationContexts().size(), 2);
Assert.assertTrue(action.getValidationContexts().get(0) instanceof XmlMessageValidationContext);
XmlMessageValidationContext xmlValidationContext = (XmlMessageValidationContext)action.getValidationContexts().get(0);
Assert.assertTrue(xmlValidationContext.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);
messageBuilder = (PayloadTemplateMessageBuilder)xmlValidationContext.getMessageBuilder();
Assert.assertNull(messageBuilder.getPayloadResourcePath());
Assert.assertNotNull(messageBuilder.getPayloadData());
Assert.assertEquals(messageBuilder.getPayloadData().trim(), "<ns:TestMessage xmlns:ns=\"http://www.consol.com\">Hello Citrus</ns:TestMessage>");
Assert.assertEquals(messageBuilder.getMessageInterceptors().size(), 1);
Assert.assertTrue(messageBuilder.getMessageInterceptors().get(0) instanceof XpathMessageConstructionInterceptor);
XpathMessageConstructionInterceptor messageConstructionInterceptor = (XpathMessageConstructionInterceptor)messageBuilder.getMessageInterceptors().get(0);
Assert.assertEquals(messageConstructionInterceptor.getXPathExpressions().size(), 1);
Assert.assertEquals(messageConstructionInterceptor.getXPathExpressions().get("/ns:TestMessage/"), "newValue");
Assert.assertEquals(xmlValidationContext.isSchemaValidationEnabled(), false);
Assert.assertEquals(xmlValidationContext.getPathValidationExpressions().size(), 0L);
Assert.assertEquals(xmlValidationContext.getIgnoreExpressions().size(), 1);
Assert.assertEquals(xmlValidationContext.getIgnoreExpressions().iterator().next(), "/ns:TestMessage/ns:ignore");
Assert.assertEquals(xmlValidationContext.getNamespaces().size(), 1);
Assert.assertEquals(xmlValidationContext.getNamespaces().get("ns"), "http://www.consol.com");
// 8th action
action = getNextTestActionFromTest();
Assert.assertEquals(action.getValidationContexts().size(), 2);
Assert.assertTrue(action.getValidationContexts().get(0) instanceof XmlMessageValidationContext);
xmlValidationContext = (XmlMessageValidationContext)action.getValidationContexts().get(0);
Assert.assertNull(action.getEndpoint());
Assert.assertEquals(action.getEndpointUri(), "channel:myMessageEndpoint");
Assert.assertEquals(xmlValidationContext.isSchemaValidationEnabled(), true);
Assert.assertEquals(xmlValidationContext.getPathValidationExpressions().size(), 2);
Assert.assertEquals(xmlValidationContext.getPathValidationExpressions().get("/TestMessage/text"), "Hello Citrus");