How to use setMessageBuilder method of com.consol.citrus.actions.SendMessageAction class

Best Citrus code snippet using com.consol.citrus.actions.SendMessageAction.setMessageBuilder

Source:SendMessageActionTest.java Github

copy

Full Screen

...58 59 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();60 messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");61 62 sendAction.setMessageBuilder(messageBuilder);63 64 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");65 reset(endpoint, producer, endpointConfiguration);66 when(endpoint.createProducer()).thenReturn(producer);67 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);68 doAnswer(new Answer() {69 @Override70 public Object answer(InvocationOnMock invocation) throws Throwable {71 DomXmlMessageValidator validator = new DomXmlMessageValidator();72 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();73 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);74 return null;75 }76 }).when(producer).send(any(Message.class), any(TestContext.class));77 when(endpoint.getActor()).thenReturn(null);78 79 sendAction.execute(context);80 }81 82 @Test83 @SuppressWarnings("rawtypes")84 public void testSendMessageWithMessagePayloadResource() {85 SendMessageAction sendAction = new SendMessageAction();86 sendAction.setEndpoint(endpoint);87 88 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();89 messageBuilder.setPayloadResourcePath("classpath:com/consol/citrus/actions/test-request-payload.xml");90 91 sendAction.setMessageBuilder(messageBuilder);92 93 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");94 reset(endpoint, producer, endpointConfiguration);95 when(endpoint.createProducer()).thenReturn(producer);96 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);97 doAnswer(new Answer() {98 @Override99 public Object answer(InvocationOnMock invocation) throws Throwable {100 DomXmlMessageValidator validator = new DomXmlMessageValidator();101 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();102 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);103 return null;104 }105 }).when(producer).send(any(Message.class), any(TestContext.class));106 when(endpoint.getActor()).thenReturn(null);107 108 sendAction.execute(context);109 }110 111 @Test112 @SuppressWarnings("rawtypes")113 public void testSendMessageWithMessageBuilderScriptData() {114 SendMessageAction sendAction = new SendMessageAction();115 sendAction.setEndpoint(endpoint);116 StringBuilder sb = new StringBuilder();117 sb.append("markupBuilder.TestRequest(){\n");118 sb.append("Message('Hello World!')\n");119 sb.append("}");120 121 GroovyScriptMessageBuilder scriptMessageBuidler = new GroovyScriptMessageBuilder();122 scriptMessageBuidler.setScriptData(sb.toString());123 124 sendAction.setMessageBuilder(scriptMessageBuidler);125 126 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");127 reset(endpoint, producer, endpointConfiguration);128 when(endpoint.createProducer()).thenReturn(producer);129 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);130 doAnswer(new Answer() {131 @Override132 public Object answer(InvocationOnMock invocation) throws Throwable {133 DomXmlMessageValidator validator = new DomXmlMessageValidator();134 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();135 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);136 return null;137 }138 }).when(producer).send(any(Message.class), any(TestContext.class));139 when(endpoint.getActor()).thenReturn(null);140 141 sendAction.execute(context);142 }143 144 @Test145 @SuppressWarnings("rawtypes")146 public void testSendMessageWithMessageBuilderScriptDataVariableSupport() {147 context.setVariable("text", "Hello World!");148 149 SendMessageAction sendAction = new SendMessageAction();150 sendAction.setEndpoint(endpoint);151 StringBuilder sb = new StringBuilder();152 sb.append("markupBuilder.TestRequest(){\n");153 sb.append("Message('${text}')\n");154 sb.append("}");155 156 GroovyScriptMessageBuilder scriptMessageBuidler = new GroovyScriptMessageBuilder();157 scriptMessageBuidler.setScriptData(sb.toString());158 159 sendAction.setMessageBuilder(scriptMessageBuidler);160 161 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");162 reset(endpoint, producer, endpointConfiguration);163 when(endpoint.createProducer()).thenReturn(producer);164 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);165 doAnswer(new Answer() {166 @Override167 public Object answer(InvocationOnMock invocation) throws Throwable {168 DomXmlMessageValidator validator = new DomXmlMessageValidator();169 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();170 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);171 return null;172 }173 }).when(producer).send(any(Message.class), any(TestContext.class));174 when(endpoint.getActor()).thenReturn(null);175 176 sendAction.execute(context);177 }178 179 @Test180 @SuppressWarnings("rawtypes")181 public void testSendMessageWithMessageBuilderScriptResource() {182 SendMessageAction sendAction = new SendMessageAction();183 sendAction.setEndpoint(endpoint);184 185 GroovyScriptMessageBuilder scriptMessageBuidler = new GroovyScriptMessageBuilder();186 scriptMessageBuidler.setScriptResourcePath("classpath:com/consol/citrus/actions/test-request-payload.groovy");187 188 sendAction.setMessageBuilder(scriptMessageBuidler);189 190 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");191 reset(endpoint, producer, endpointConfiguration);192 when(endpoint.createProducer()).thenReturn(producer);193 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);194 doAnswer(new Answer() {195 @Override196 public Object answer(InvocationOnMock invocation) throws Throwable {197 DomXmlMessageValidator validator = new DomXmlMessageValidator();198 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();199 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);200 return null;201 }202 }).when(producer).send(any(Message.class), any(TestContext.class));203 when(endpoint.getActor()).thenReturn(null);204 205 sendAction.execute(context);206 }207 208 @Test209 @SuppressWarnings("rawtypes")210 public void testSendMessageWithMessagePayloadDataVariablesSupport() {211 SendMessageAction sendAction = new SendMessageAction();212 sendAction.setEndpoint(endpoint);213 214 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();215 messageBuilder.setPayloadData("<TestRequest><Message>${myText}</Message></TestRequest>");216 217 sendAction.setMessageBuilder(messageBuilder);218 219 context.setVariable("myText", "Hello World!");220 221 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");222 reset(endpoint, producer, endpointConfiguration);223 when(endpoint.createProducer()).thenReturn(producer);224 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);225 doAnswer(new Answer() {226 @Override227 public Object answer(InvocationOnMock invocation) throws Throwable {228 DomXmlMessageValidator validator = new DomXmlMessageValidator();229 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();230 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);231 return null;232 }233 }).when(producer).send(any(Message.class), any(TestContext.class));234 when(endpoint.getActor()).thenReturn(null);235 236 sendAction.execute(context);237 }238 239 @Test240 @SuppressWarnings("rawtypes")241 public void testSendMessageWithMessagePayloadResourceVariablesSupport() {242 SendMessageAction sendAction = new SendMessageAction();243 sendAction.setEndpoint(endpoint);244 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();245 messageBuilder.setPayloadResourcePath("classpath:com/consol/citrus/actions/test-request-payload-with-variables.xml");246 247 sendAction.setMessageBuilder(messageBuilder);248 249 context.setVariable("myText", "Hello World!");250 251 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");252 reset(endpoint, producer, endpointConfiguration);253 when(endpoint.createProducer()).thenReturn(producer);254 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);255 doAnswer(new Answer() {256 @Override257 public Object answer(InvocationOnMock invocation) throws Throwable {258 DomXmlMessageValidator validator = new DomXmlMessageValidator();259 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();260 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);261 return null;262 }263 }).when(producer).send(any(Message.class), any(TestContext.class));264 when(endpoint.getActor()).thenReturn(null);265 266 sendAction.execute(context);267 }268 269 @Test270 @SuppressWarnings("rawtypes")271 public void testSendMessageWithMessagePayloadResourceFunctionsSupport() {272 SendMessageAction sendAction = new SendMessageAction();273 sendAction.setEndpoint(endpoint);274 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();275 messageBuilder.setPayloadResourcePath("classpath:com/consol/citrus/actions/test-request-payload-with-functions.xml");276 277 sendAction.setMessageBuilder(messageBuilder);278 279 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");280 reset(endpoint, producer, endpointConfiguration);281 when(endpoint.createProducer()).thenReturn(producer);282 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);283 doAnswer(new Answer() {284 @Override285 public Object answer(InvocationOnMock invocation) throws Throwable {286 DomXmlMessageValidator validator = new DomXmlMessageValidator();287 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();288 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);289 return null;290 }291 }).when(producer).send(any(Message.class), any(TestContext.class));292 when(endpoint.getActor()).thenReturn(null);293 294 sendAction.execute(context);295 }296 297 @Test298 @SuppressWarnings("rawtypes")299 public void testSendMessageOverwriteMessageElementsXPath() {300 SendMessageAction sendAction = new SendMessageAction();301 sendAction.setEndpoint(endpoint);302 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();303 messageBuilder.setPayloadData("<TestRequest><Message>?</Message></TestRequest>");304 305 Map<String, String> overwriteElements = new HashMap<String, String>();306 overwriteElements.put("/TestRequest/Message", "Hello World!");307 308 XpathMessageConstructionInterceptor interceptor = new XpathMessageConstructionInterceptor(overwriteElements);309 messageBuilder.add(interceptor);310 311 sendAction.setMessageBuilder(messageBuilder);312 313 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");314 reset(endpoint, producer, endpointConfiguration);315 when(endpoint.createProducer()).thenReturn(producer);316 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);317 doAnswer(new Answer() {318 @Override319 public Object answer(InvocationOnMock invocation) throws Throwable {320 DomXmlMessageValidator validator = new DomXmlMessageValidator();321 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();322 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);323 return null;324 }325 }).when(producer).send(any(Message.class), any(TestContext.class));326 when(endpoint.getActor()).thenReturn(null);327 328 sendAction.execute(context);329 }330 @Test331 @SuppressWarnings("rawtypes")332 public void testSendMessageOverwriteMessageElementsJsonPath() {333 SendMessageAction sendAction = new SendMessageAction();334 sendAction.setMessageType(MessageType.JSON.toString());335 sendAction.setEndpoint(endpoint);336 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();337 messageBuilder.setPayloadData("{ \"TestRequest\": { \"Message\": \"?\" }}");338 Map<String, String> overwriteElements = new HashMap<String, String>();339 overwriteElements.put("$.TestRequest.Message", "Hello World!");340 JsonPathMessageConstructionInterceptor interceptor = new JsonPathMessageConstructionInterceptor(overwriteElements);341 messageBuilder.add(interceptor);342 sendAction.setMessageBuilder(messageBuilder);343 final Message controlMessage = new DefaultMessage("{ \"TestRequest\": { \"Message\": \"Hello World!\" }}");344 reset(endpoint, producer, endpointConfiguration);345 when(endpoint.createProducer()).thenReturn(producer);346 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);347 doAnswer(new Answer() {348 @Override349 public Object answer(InvocationOnMock invocation) throws Throwable {350 JsonTextMessageValidator validator = new JsonTextMessageValidator();351 JsonMessageValidationContext validationContext = new JsonMessageValidationContext();352 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);353 return null;354 }355 }).when(producer).send(any(Message.class), any(TestContext.class));356 when(endpoint.getActor()).thenReturn(null);357 sendAction.execute(context);358 }359 360 @Test361 @SuppressWarnings("rawtypes")362 public void testSendMessageOverwriteMessageElementsDotNotation() {363 SendMessageAction sendAction = new SendMessageAction();364 sendAction.setEndpoint(endpoint);365 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();366 messageBuilder.setPayloadData("<TestRequest><Message>?</Message></TestRequest>");367 368 Map<String, String> overwriteElements = new HashMap<String, String>();369 overwriteElements.put("TestRequest.Message", "Hello World!");370 371 XpathMessageConstructionInterceptor interceptor = new XpathMessageConstructionInterceptor(overwriteElements);372 messageBuilder.add(interceptor);373 374 sendAction.setMessageBuilder(messageBuilder);375 376 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");377 reset(endpoint, producer, endpointConfiguration);378 when(endpoint.createProducer()).thenReturn(producer);379 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);380 doAnswer(new Answer() {381 @Override382 public Object answer(InvocationOnMock invocation) throws Throwable {383 DomXmlMessageValidator validator = new DomXmlMessageValidator();384 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();385 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);386 return null;387 }388 }).when(producer).send(any(Message.class), any(TestContext.class));389 when(endpoint.getActor()).thenReturn(null);390 391 sendAction.execute(context);392 }393 394 @Test395 @SuppressWarnings("rawtypes")396 public void testSendMessageOverwriteMessageElementsXPathWithNamespace() {397 SendMessageAction sendAction = new SendMessageAction();398 sendAction.setEndpoint(endpoint);399 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();400 messageBuilder.setPayloadData("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +401 "<ns0:Message>?</ns0:Message></ns0:TestRequest>");402 403 Map<String, String> overwriteElements = new HashMap<String, String>();404 overwriteElements.put("/ns0:TestRequest/ns0:Message", "Hello World!");405 XpathMessageConstructionInterceptor interceptor = new XpathMessageConstructionInterceptor(overwriteElements);406 messageBuilder.add(interceptor);407 408 sendAction.setMessageBuilder(messageBuilder);409 410 final Message controlMessage = new DefaultMessage("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\"><ns0:Message>Hello World!</ns0:Message></ns0:TestRequest>");411 reset(endpoint, producer, endpointConfiguration);412 when(endpoint.createProducer()).thenReturn(producer);413 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);414 doAnswer(new Answer() {415 @Override416 public Object answer(InvocationOnMock invocation) throws Throwable {417 DomXmlMessageValidator validator = new DomXmlMessageValidator();418 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();419 validationContext.setSchemaValidation(false);420 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);421 return null;422 }423 }).when(producer).send(any(Message.class), any(TestContext.class));424 when(endpoint.getActor()).thenReturn(null);425 426 sendAction.execute(context);427 }428 429 @Test430 @SuppressWarnings("rawtypes")431 public void testSendMessageOverwriteMessageElementsXPathWithDefaultNamespace() {432 SendMessageAction sendAction = new SendMessageAction();433 sendAction.setEndpoint(endpoint);434 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();435 messageBuilder.setPayloadData("<TestRequest xmlns=\"http://citrusframework.org/unittest\">" +436 "<Message>?</Message></TestRequest>");437 438 Map<String, String> overwriteElements = new HashMap<String, String>();439 overwriteElements.put("/:TestRequest/:Message", "Hello World!");440 XpathMessageConstructionInterceptor interceptor = new XpathMessageConstructionInterceptor(overwriteElements);441 messageBuilder.add(interceptor);442 443 sendAction.setMessageBuilder(messageBuilder);444 445 final Message controlMessage = new DefaultMessage("<TestRequest xmlns=\"http://citrusframework.org/unittest\"><Message>Hello World!</Message></TestRequest>");446 reset(endpoint, producer, endpointConfiguration);447 when(endpoint.createProducer()).thenReturn(producer);448 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);449 doAnswer(new Answer() {450 @Override451 public Object answer(InvocationOnMock invocation) throws Throwable {452 DomXmlMessageValidator validator = new DomXmlMessageValidator();453 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();454 validationContext.setSchemaValidation(false);455 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);456 return null;457 }458 }).when(producer).send(any(Message.class), any(TestContext.class));459 when(endpoint.getActor()).thenReturn(null);460 461 sendAction.execute(context);462 }463 464 @Test465 @SuppressWarnings("rawtypes")466 public void testSendMessageWithMessageHeaders() {467 SendMessageAction sendAction = new SendMessageAction();468 sendAction.setEndpoint(endpoint);469 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();470 messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");471 472 final Map<String, Object> controlHeaders = new HashMap<String, Object>();473 controlHeaders.put("Operation", "sayHello");474 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>", controlHeaders);475 final Map<String, Object> headers = new HashMap<String, Object>();476 headers.put("Operation", "sayHello");477 messageBuilder.setMessageHeaders(headers);478 479 sendAction.setMessageBuilder(messageBuilder);480 reset(endpoint, producer, endpointConfiguration);481 when(endpoint.createProducer()).thenReturn(producer);482 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);483 doAnswer(new Answer() {484 @Override485 public Object answer(InvocationOnMock invocation) throws Throwable {486 DomXmlMessageValidator validator = new DomXmlMessageValidator();487 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();488 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);489 return null;490 }491 }).when(producer).send(any(Message.class), any(TestContext.class));492 when(endpoint.getActor()).thenReturn(null);493 494 sendAction.execute(context);495 }496 497 @Test498 @SuppressWarnings("rawtypes")499 public void testSendMessageWithHeaderValuesVariableSupport() {500 SendMessageAction sendAction = new SendMessageAction();501 sendAction.setEndpoint(endpoint);502 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();503 messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");504 505 context.setVariable("myOperation", "sayHello");506 507 final Map<String, Object> controlHeaders = new HashMap<String, Object>();508 controlHeaders.put("Operation", "sayHello");509 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>", controlHeaders);510 final Map<String, Object> headers = new HashMap<String, Object>();511 headers.put("Operation", "${myOperation}");512 messageBuilder.setMessageHeaders(headers);513 514 sendAction.setMessageBuilder(messageBuilder);515 reset(endpoint, producer, endpointConfiguration);516 when(endpoint.createProducer()).thenReturn(producer);517 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);518 doAnswer(new Answer() {519 @Override520 public Object answer(InvocationOnMock invocation) throws Throwable {521 DomXmlMessageValidator validator = new DomXmlMessageValidator();522 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();523 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);524 return null;525 }526 }).when(producer).send(any(Message.class), any(TestContext.class));527 when(endpoint.getActor()).thenReturn(null);528 529 sendAction.execute(context);530 }531 532 @Test533 public void testSendMessageWithUnknwonVariableInMessagePayload() {534 SendMessageAction sendAction = new SendMessageAction();535 sendAction.setEndpoint(endpoint);536 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();537 messageBuilder.setPayloadData("<TestRequest><Message>${myText}</Message></TestRequest>");538 539 sendAction.setMessageBuilder(messageBuilder);540 reset(endpoint, producer, endpointConfiguration);541 when(endpoint.createProducer()).thenReturn(producer);542 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);543 when(endpoint.getActor()).thenReturn(null);544 545 try {546 sendAction.execute(context);547 } catch(CitrusRuntimeException e) {548 Assert.assertEquals(e.getMessage(), "Unknown variable 'myText'");549 return;550 }551 552 Assert.fail("Missing " + CitrusRuntimeException.class + " with unknown variable error message");553 }554 555 @Test556 public void testSendMessageWithUnknwonVariableInHeaders() {557 SendMessageAction sendAction = new SendMessageAction();558 sendAction.setEndpoint(endpoint);559 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();560 messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");561 562 final Map<String, Object> headers = new HashMap<String, Object>();563 headers.put("Operation", "${myOperation}");564 messageBuilder.setMessageHeaders(headers);565 566 sendAction.setMessageBuilder(messageBuilder);567 reset(endpoint, producer, endpointConfiguration);568 when(endpoint.createProducer()).thenReturn(producer);569 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);570 when(endpoint.getActor()).thenReturn(null);571 572 try {573 sendAction.execute(context);574 } catch(CitrusRuntimeException e) {575 Assert.assertEquals(e.getMessage(), "Unknown variable 'myOperation'");576 return;577 }578 579 Assert.fail("Missing " + CitrusRuntimeException.class + " with unknown variable error message");580 }581 582 @Test583 @SuppressWarnings("rawtypes")584 public void testSendMessageWithExtractHeaderValues() {585 SendMessageAction sendAction = new SendMessageAction();586 sendAction.setEndpoint(endpoint);587 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();588 messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");589 590 final Map<String, Object> controlHeaders = new HashMap<String, Object>();591 controlHeaders.put("Operation", "sayHello");592 final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>", controlHeaders);593 final Map<String, Object> headers = new HashMap<String, Object>();594 headers.put("Operation", "sayHello");595 messageBuilder.setMessageHeaders(headers);596 597 sendAction.setMessageBuilder(messageBuilder);598 599 Map<String, String> extractVars = new HashMap<String, String>();600 extractVars.put("Operation", "myOperation");601 extractVars.put(MessageHeaders.ID, "correlationId");602 603 List<VariableExtractor> variableExtractors = new ArrayList<VariableExtractor>();604 MessageHeaderVariableExtractor variableExtractor = new MessageHeaderVariableExtractor();605 variableExtractor.setHeaderMappings(extractVars);606 607 variableExtractors.add(variableExtractor);608 sendAction.setVariableExtractors(variableExtractors);609 reset(endpoint, producer, endpointConfiguration);610 when(endpoint.createProducer()).thenReturn(producer);611 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);612 doAnswer(new Answer() {613 @Override614 public Object answer(InvocationOnMock invocation) throws Throwable {615 DomXmlMessageValidator validator = new DomXmlMessageValidator();616 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();617 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);618 return null;619 }620 }).when(producer).send(any(Message.class), any(TestContext.class));621 when(endpoint.getActor()).thenReturn(null);622 623 sendAction.execute(context);624 625 Assert.assertNotNull(context.getVariable("myOperation"));626 Assert.assertNotNull(context.getVariable("correlationId"));627 }628 629 @Test630 @SuppressWarnings("rawtypes")631 public void testMissingMessagePayload() {632 SendMessageAction sendAction = new SendMessageAction();633 sendAction.setEndpoint(endpoint);634 reset(endpoint, producer, endpointConfiguration);635 when(endpoint.createProducer()).thenReturn(producer);636 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);637 doAnswer(new Answer() {638 @Override639 public Object answer(InvocationOnMock invocation) throws Throwable {640 DomXmlMessageValidator validator = new DomXmlMessageValidator();641 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();642 validator.validateMessage(((Message)invocation.getArguments()[0]), new DefaultMessage(""), context, validationContext);643 return null;644 }645 }).when(producer).send(any(Message.class), any(TestContext.class));646 when(endpoint.getActor()).thenReturn(null);647 648 sendAction.execute(context);649 }650 651 @Test652 @SuppressWarnings("rawtypes")653 public void testSendMessageWithXmlDeclaration() {654 SendMessageAction sendAction = new SendMessageAction();655 sendAction.setEndpoint(endpoint);656 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();657 messageBuilder.setPayloadData("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestRequest><Message>Hello World!</Message></TestRequest>");658 659 sendAction.setMessageBuilder(messageBuilder);660 661 final Message controlMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestRequest><Message>Hello World!</Message></TestRequest>");662 reset(endpoint, producer, endpointConfiguration);663 when(endpoint.createProducer()).thenReturn(producer);664 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);665 doAnswer(new Answer() {666 @Override667 public Object answer(InvocationOnMock invocation) throws Throwable {668 DomXmlMessageValidator validator = new DomXmlMessageValidator();669 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();670 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);671 return null;672 }673 }).when(producer).send(any(Message.class), any(TestContext.class));674 when(endpoint.getActor()).thenReturn(null);675 676 sendAction.execute(context);677 }678 679 @Test680 @SuppressWarnings("rawtypes")681 public void testSendMessageWithUTF16Encoding() {682 SendMessageAction sendAction = new SendMessageAction();683 sendAction.setEndpoint(endpoint);684 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();685 messageBuilder.setPayloadData("<?xml version=\"1.0\" encoding=\"UTF-16\"?><TestRequest><Message>Hello World!</Message></TestRequest>");686 687 sendAction.setMessageBuilder(messageBuilder);688 689 final Message controlMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-16\"?><TestRequest><Message>Hello World!</Message></TestRequest>");690 reset(endpoint, producer, endpointConfiguration);691 when(endpoint.createProducer()).thenReturn(producer);692 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);693 doAnswer(new Answer() {694 @Override695 public Object answer(InvocationOnMock invocation) throws Throwable {696 DomXmlMessageValidator validator = new DomXmlMessageValidator();697 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();698 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);699 return null;700 }701 }).when(producer).send(any(Message.class), any(TestContext.class));702 when(endpoint.getActor()).thenReturn(null);703 704 sendAction.execute(context);705 }706 707 @Test708 @SuppressWarnings("rawtypes")709 public void testSendMessageWithISOEncoding() {710 SendMessageAction sendAction = new SendMessageAction();711 sendAction.setEndpoint(endpoint);712 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();713 messageBuilder.setPayloadData("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><TestRequest><Message>Hello World!</Message></TestRequest>");714 715 sendAction.setMessageBuilder(messageBuilder);716 717 final Message controlMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><TestRequest><Message>Hello World!</Message></TestRequest>");718 reset(endpoint, producer, endpointConfiguration);719 when(endpoint.createProducer()).thenReturn(producer);720 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);721 doAnswer(new Answer() {722 @Override723 public Object answer(InvocationOnMock invocation) throws Throwable {724 DomXmlMessageValidator validator = new DomXmlMessageValidator();725 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();726 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);727 return null;728 }729 }).when(producer).send(any(Message.class), any(TestContext.class));730 when(endpoint.getActor()).thenReturn(null);731 732 sendAction.execute(context);733 }734 735 @Test736 @SuppressWarnings("rawtypes")737 public void testSendMessageWithUnsupportedEncoding() {738 SendMessageAction sendAction = new SendMessageAction();739 sendAction.setEndpoint(endpoint);740 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();741 messageBuilder.setPayloadData("<?xml version=\"1.0\" encoding=\"MyUnsupportedEncoding\"?><TestRequest><Message>Hello World!</Message></TestRequest>");742 743 sendAction.setMessageBuilder(messageBuilder);744 reset(endpoint, producer, endpointConfiguration);745 when(endpoint.createProducer()).thenReturn(producer);746 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);747 when(endpoint.getActor()).thenReturn(null);748 try {749 sendAction.execute(context);750 } catch (CitrusRuntimeException e) {751 Assert.assertTrue(e.getCause() instanceof UnsupportedEncodingException);752 }753 verify(producer).send(any(Message.class), any(TestContext.class));754 }755 @Test756 @SuppressWarnings("rawtypes")757 public void testSendMessageWithMessagePayloadResourceISOEncoding() {758 SendMessageAction sendAction = new SendMessageAction();759 sendAction.setEndpoint(endpoint);760 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();761 messageBuilder.setPayloadResourcePath("classpath:com/consol/citrus/actions/test-request-iso-encoding.xml");762 763 sendAction.setMessageBuilder(messageBuilder);764 765 final Message controlMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><TestRequest><Message>Hello World!</Message></TestRequest>");766 reset(endpoint, producer, endpointConfiguration);767 when(endpoint.createProducer()).thenReturn(producer);768 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);769 doAnswer(new Answer() {770 @Override771 public Object answer(InvocationOnMock invocation) throws Throwable {772 DomXmlMessageValidator validator = new DomXmlMessageValidator();773 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();774 validator.validateMessage(((Message)invocation.getArguments()[0]), controlMessage, context, validationContext);775 return null;776 }777 }).when(producer).send(any(Message.class), any(TestContext.class));778 when(endpoint.getActor()).thenReturn(null);779 780 sendAction.execute(context);781 }782 783 @Test784 public void testDisabledSendMessage() {785 TestCase testCase = new TestCase();786 SendMessageAction sendAction = new SendMessageAction();787 sendAction.setEndpoint(endpoint);788 789 TestActor disabledActor = new TestActor();790 disabledActor.setDisabled(true);791 sendAction.setActor(disabledActor);792 793 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();794 messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");795 796 sendAction.setMessageBuilder(messageBuilder);797 reset(endpoint, producer, endpointConfiguration);798 when(endpoint.createProducer()).thenReturn(producer);799 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);800 when(endpoint.getActor()).thenReturn(null);801 testCase.addTestAction(sendAction);802 testCase.execute(context);803 }804 805 @Test806 public void testDisabledSendMessageByEndpointActor() {807 TestCase testCase = new TestCase();808 SendMessageAction sendAction = new SendMessageAction();809 sendAction.setEndpoint(endpoint);810 811 TestActor disabledActor = new TestActor();812 disabledActor.setDisabled(true);813 814 PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();815 messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");816 817 sendAction.setMessageBuilder(messageBuilder);818 reset(endpoint, producer, endpointConfiguration);819 when(endpoint.createProducer()).thenReturn(producer);820 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);821 when(endpoint.getActor()).thenReturn(disabledActor);822 testCase.addTestAction(sendAction);823 testCase.execute(context);824 }825 826}...

Full Screen

Full Screen

Source:SendMessageAction.java Github

copy

Full Screen

...172 /**173 * Sets the message builder implementation.174 * @param messageBuilder the messageBuilder to set175 */176 public SendMessageAction setMessageBuilder(MessageContentBuilder messageBuilder) {177 this.messageBuilder = messageBuilder;178 return this;179 }180 /**181 * The variable extractors for this message sending action.182 * @param variableExtractors the variableExtractors to set183 */184 public SendMessageAction setVariableExtractors(List<VariableExtractor> variableExtractors) {185 this.variableExtractors = variableExtractors;186 return this;187 }188 /**189 * Get the variable extractors.190 * @return the variableExtractors...

Full Screen

Full Screen

Source:HttpServerResponseActionBuilder.java Github

copy

Full Screen

...47 */48 private void initMessage(HttpMessage message) {49 StaticMessageContentBuilder staticMessageContentBuilder = StaticMessageContentBuilder.withMessage(message);50 staticMessageContentBuilder.setMessageHeaders(message.getHeaders());51 getAction().setMessageBuilder(new HttpMessageContentBuilder(message, staticMessageContentBuilder));52 }53 @Override54 protected void setPayload(String payload) {55 httpMessage.setPayload(payload);56 }57 @Override58 public HttpServerResponseActionBuilder name(String name) {59 httpMessage.setName(name);60 return super.name(name);61 }62 63 /**64 * Sets the response status.65 * @param status...

Full Screen

Full Screen

setMessageBuilder

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.design;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class SendMessageActionJavaITest extends TestNGCitrusTestDesigner {5 public void sendMessageActionJavaITest() {6 variable("payload", "Hello World!");7 http(httpActionBuilder -> httpActionBuilder8 .client("httpClient")9 .send()10 .post()11 .fork(true)12 .payload("<testMessage>${payload}</testMessage>")13 );14 http(httpActionBuilder -> httpActionBuilder15 .client("httpClient")16 .receive()17 .response(HttpStatus.OK)18 .messageType(MessageType.PLAINTEXT)19 .payload("Hello World!")20 );21 }22}23package com.consol.citrus.dsl.design;24import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;25import org.testng.annotations.Test;26public class SendMessageActionJavaITest extends TestNGCitrusTestDesigner {27 public void sendMessageActionJavaITest() {28 variable("payload", "Hello World!");29 http(httpActionBuilder -> httpActionBuilder30 .client("httpClient")31 .send()32 .post()33 .fork(true)34 .payload("<testMessage>${payload}</testMessage>")35 );36 http(httpActionBuilder -> httpActionBuilder37 .client("httpClient")38 .receive()39 .response(HttpStatus.OK)40 .messageType(MessageType.PLAINTEXT)41 .payload("Hello World!")42 );43 }44}45package com.consol.citrus.dsl.design;46import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;47import org.testng.annotations.Test;48public class SendMessageActionJavaITest extends TestNGCitrusTestDesigner {49 public void sendMessageActionJavaITest() {50 variable("payload", "Hello World!");51 http(httpActionBuilder -> httpActionBuilder52 .client("httpClient")53 .send()54 .post()55 .fork(true)56 .payload("<testMessage>${payload}</testMessage>")57 );58 http(httpActionBuilder -> httpActionBuilder59 .client("httpClient")60 .receive()61 .response(HttpStatus.OK)62 .messageType(MessageType.PLAINTEXT)63 .payload("Hello World!")64 );65 }66}

Full Screen

Full Screen

setMessageBuilder

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.design;2import com.consol.citrus.dsl.builder.SendMessageActionBuilder;3import com.consol.citrus.message.MessageType;4import org.springframework.http.HttpStatus;5import org.springframework.http.MediaType;6import org.springframework.web.bind.annotation.RequestMethod;7public class SendMessageActionBuilderSample {8 public static void main(String[] args) {9 SendMessageActionBuilder sendMessageActionBuilder = new SendMessageActionBuilder();10 .messageType(MessageType.JSON)11 .messageBuilder(messageBuilder -> messageBuilder12 .payload("{\"name\": \"citrus\"}")13 .header("Accept", MediaType.APPLICATION_JSON_VALUE))14 .extractFromHeader("Location", "location")15 .extractFromHeader("Content-Type", "contentType")16 .validateHeader("Location", "citrus:startsWith('http')")17 .validateHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE)18 .extractFromPayload("$.name", "name")19 .validatePayload("$.name", "citrus")20 .send()21 .receive()22 .messageType(MessageType.JSON)23 .messageBuilder(messageBuilder -> messageBuilder24 .payload("{\"name\": \"citrus\"}")25 .header("Accept", MediaType.APPLICATION_JSON_VALUE))26 .extractFromHeader("Location", "location")27 .extractFromHeader("Content-Type", "contentType")28 .validateHeader("Location", "citrus:startsWith('http')")29 .validateHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE)30 .extractFromPayload("$.name", "name")31 .validatePayload("$.name", "citrus")32 .send()33 .receive()34 .messageType(MessageType.JSON)35 .messageBuilder(messageBuilder -> messageBuilder36 .payload("{\"name\": \"citrus\"}")37 .header("Accept", MediaType.APPLICATION_JSON_VALUE))38 .extractFromHeader("Location", "location")39 .extractFromHeader("Content-Type", "contentType")40 .validateHeader("Location", "citrus:startsWith('http')")41 .validateHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE)42 .extractFromPayload("$.name", "name")43 .validatePayload("$.name", "citrus")44 .send()45 .receive()

Full Screen

Full Screen

setMessageBuilder

Using AI Code Generation

copy

Full Screen

1public class 4 extends TestActionBuilder {2 public TestAction build() {3 SendMessageAction sendMessageAction = new SendMessageAction();4 sendMessageAction.setMessageBuilder(new DefaultMessageBuilder());5 return sendMessageAction;6 }7}8public class 5 extends TestActionBuilder {9 public TestAction build() {10 SendMessageAction sendMessageAction = new SendMessageAction();11 sendMessageAction.setPayloadData("payload");12 return sendMessageAction;13 }14}15public class 6 extends TestActionBuilder {16 public TestAction build() {17 SendMessageAction sendMessageAction = new SendMessageAction();18 sendMessageAction.setPayloadResourcePath("payloadResourcePath");19 return sendMessageAction;20 }21}22public class 7 extends TestActionBuilder {23 public TestAction build() {24 SendMessageAction sendMessageAction = new SendMessageAction();25 sendMessageAction.setPayloadResource(new ClassPathResource("path"));26 return sendMessageAction;27 }28}29public class 8 extends TestActionBuilder {30 public TestAction build() {31 SendMessageAction sendMessageAction = new SendMessageAction();32 sendMessageAction.setPayloadFactory(new DefaultPayloadTemplateProcessor());33 return sendMessageAction;34 }35}36public class 9 extends TestActionBuilder {37 public TestAction build() {38 SendMessageAction sendMessageAction = new SendMessageAction();39 sendMessageAction.setPayloadFactory(new DefaultPayloadTemplateProcessor());40 return sendMessageAction;41 }42}43public class 10 extends TestActionBuilder {44 public TestAction build() {45 SendMessageAction sendMessageAction = new SendMessageAction();46 sendMessageAction.setPayloadFactory(new DefaultPayloadTemplateProcessor());47 return sendMessageAction;48 }49}

Full Screen

Full Screen

setMessageBuilder

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.endpoint;2import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;3import org.testng.annotations.Test;4public class SetMessageBuilderTest extends TestNGCitrusTestRunner {5 public void setMessageBuilderTest() {6 variable("name", "John");7 variable("age", "25");8 http()9 .client("httpClient")10 .send()11 .post("/greet")12 .setMessageBuilder()13 "<Message>Hello ${name}!</Message>" +14 "<Age>${age}</Age>" +15 "</ns0:GreetRequest>");16 http()17 .client("httpClient")18 .receive()19 .response(HttpStatus.OK)20 "<Message>Hello ${name}!</Message>" +21 "</ns0:GreetResponse>");22 }23}

Full Screen

Full Screen

setMessageBuilder

Using AI Code Generation

copy

Full Screen

1public class 4 {2 public static void main(String[] args) {3 SendMessageActionBuilder builder = new SendMessageActionBuilder();4 builder.setMessageBuilder(new DefaultMessageBuilder("Hello"));5 }6}

Full Screen

Full Screen

setMessageBuilder

Using AI Code Generation

copy

Full Screen

1public class 4 extends TestActionBuilder {2 public 4() {3 setName("4");4 setMessageBuilder(new DefaultMessageBuilder("4"));5 }6}7public class 5 extends TestActionBuilder {8 public 5() {9 setName("5");10 setMessageBuilder(new DefaultMessageBuilder("5"));11 }12}13public class 6 extends TestActionBuilder {14 public 6() {15 setName("6");16 setMessageBuilder(new DefaultMessageBuilder("6"));17 }18}19public class 7 extends TestActionBuilder {20 public 7() {21 setName("7");22 setMessageBuilder(new DefaultMessageBuilder("7"));23 }24}25public class 8 extends TestActionBuilder {26 public 8() {27 setName("8");28 setMessageBuilder(new DefaultMessageBuilder("8"));29 }30}31public class 9 extends TestActionBuilder {32 public 9() {33 setName("9");34 setMessageBuilder(new DefaultMessageBuilder("9"));35 }36}37public class 10 extends TestActionBuilder {38 public 10() {39 setName("10");40 setMessageBuilder(new DefaultMessageBuilder("10"));41 }42}43public class 11 extends TestActionBuilder {44 public 11() {45 setName("11");46 setMessageBuilder(new DefaultMessageBuilder("11"));47 }48}49public class 12 extends TestActionBuilder {50 public 12() {51 setName("12");52 setMessageBuilder(new DefaultMessage

Full Screen

Full Screen

setMessageBuilder

Using AI Code Generation

copy

Full Screen

1public class 4() {2 public void 4() {3 description("This test does the following: ");4 variable("name", "Citrus");5 variable("greeting", "Hello");6 send("sender")7 .message()8 .body("<greetingMessage><text>Hello Citrus</text></greetingMessage>")9 .header("operation", "greeting")10 .header("id", "1234");11 receive("receiver")12 .message()13 .body("<greetingMessageResponse><text>Hello Citrus</text></greetingMessageResponse>")14 .header("operation", "greeting")15 .header("id", "1234");16 }17}18public class 5() {19 public void 5() {20 description("This test does the following: ");21 variable("name", "Citrus");22 variable("greeting", "Hello");23 send("sender")24 .message()25 .body("<greetingMessage><text>Hello Citrus</text></greetingMessage>")26 .header("operation", "greeting")27 .header("id", "1234");28 receive("receiver")29 .message()30 .body("<greetingMessageResponse><text>Hello Citrus</text></greetingMessageResponse>")31 .header("operation", "greeting")32 .header("id", "1234");33 }34}35public class 6() {36 public void 6() {37 description("This test does the following: ");38 variable("name", "Citrus");39 variable("greeting", "Hello");40 send("sender")41 .message()42 .body("<greetingMessage><text>Hello Citrus</text></greetingMessage>")43 .header("operation", "greeting")44 .header("id", "1234");45 receive("receiver")

Full Screen

Full Screen

setMessageBuilder

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.design;2import com.consol.citrus.dsl.builder.BuilderSupport;3import com.consol.citrus.dsl.builder.SendMessageActionBuilder;4import com.consol.citrus.message.MessageType;5import com.consol.citrus.dsl.builder.BuilderSupport;6import com.consol.citrus.dsl.builder.SendMessageActionBuilder;7import com.consol.citrus.message.MessageType;8import com.consol.citrus.dsl.builder.BuilderSupport;9import com.consol.citrus.dsl.builder.SendMessageActionBuilder;10import com.consol.citrus.message.MessageType;11import com.consol.citrus.dsl.builder.BuilderSupport;12import com.consol.citrus.dsl.builder.SendMessageActionBuilder;13import com.consol.citrus.message.MessageType;14public class SendMessageActionBuilder extends AbstractTestActionBuilder<SendMessageAction> {15 private final SendMessageAction action = new SendMessageAction();16 public SendMessageActionBuilder(SendMessageAction action) {17 super(action);18 }19 public static SendMessageActionBuilder send() {20 return new SendMessageActionBuilder(new SendMessageAction());21 }22 public SendMessageActionBuilder endpoint(String endpoint) {23 action.setEndpoint(endpoint);24 return this;25 }26 public SendMessageActionBuilder endpoint(MessageEndpoint endpoint) {27 action.setEndpoint(endpoint);28 return this;29 }30 public SendMessageActionBuilder payload(String payload) {31 action.setPayload(payload);32 return this;33 }34 public SendMessageActionBuilder payload(byte[] payload) {35 action.setPayload(payload);36 return this;37 }

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful