Best Citrus code snippet using com.consol.citrus.container.Assert.getAction
Source:TestActionConverterTest.java
...38 @Test(dataProvider = "converterData")39 public void testConvert(TestActionConverter actionConverter, ModelAndAssertion modelAndAssertion) throws Exception {40 TestActionModel result = actionConverter.convert(modelAndAssertion.getModel());41 modelAndAssertion.assertModel(result);42 Object modelConversion = actionConverter.convertModel(modelAndAssertion.getAction());43 Assert.assertEquals(modelConversion.getClass(), modelAndAssertion.getModel().getClass());44 modelAndAssertion.assertModel(modelConversion);45 }46 @DataProvider47 public Object[][] converterData() {48 return new Object[][] {49 new Object[] {new SendMessageActionConverter(), new ModelAndAssertion<SendModel, SendMessageAction>() {50 @Override51 public SendModel getModel() {52 SendModel model = new SendModel();53 model.setEndpoint("myEndpoint");54 return model;55 }56 @Override57 public SendMessageAction getAction() {58 return new SendMessageAction()59 .setEndpointUri("myEndpoint");60 }61 @Override62 public void assertModel(TestActionModel model) {63 Assert.assertEquals(model.getType(), "send");64 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("endpoint")).findFirst().orElse(new Property()).getValue(), "myEndpoint");65 }66 @Override67 public void assertModel(SendModel model) {68 Assert.assertEquals(model.getEndpoint(), "myEndpoint");69 }70 }},71 new Object[] {new ReceiveMessageActionConverter(), new ModelAndAssertion<ReceiveModel, ReceiveMessageAction>() {72 @Override73 public ReceiveModel getModel() {74 ReceiveModel model = new ReceiveModel();75 model.setEndpoint("myEndpoint");76 return model;77 }78 @Override79 public ReceiveMessageAction getAction() {80 return new ReceiveMessageAction()81 .setEndpointUri("myEndpoint");82 }83 @Override84 public void assertModel(TestActionModel model) {85 Assert.assertEquals(model.getType(), "receive");86 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("endpoint")).findFirst().orElse(new Property()).getValue(), "myEndpoint");87 }88 @Override89 public void assertModel(ReceiveModel model) {90 Assert.assertEquals(model.getEndpoint(), "myEndpoint");91 }92 }},93 new Object[] {new EchoActionConverter(), new ModelAndAssertion<EchoModel, EchoAction>() {94 @Override95 public EchoModel getModel() {96 EchoModel model = new EchoModel();97 model.setMessage("Hello Citrus!");98 return model;99 }100 @Override101 public EchoAction getAction() {102 return new EchoAction()103 .setMessage("Hello Citrus!");104 }105 @Override106 public void assertModel(TestActionModel model) {107 Assert.assertEquals(model.getType(), "echo");108 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("message")).findFirst().orElse(new Property()).getValue(), "Hello Citrus!");109 }110 @Override111 public void assertModel(EchoModel model) {112 Assert.assertEquals(model.getMessage(), "Hello Citrus!");113 }114 }},115 new Object[] {new SleepActionConverter(), new ModelAndAssertion<SleepModel, SleepAction>() {116 @Override117 public SleepModel getModel() {118 SleepModel model = new SleepModel();119 model.setMilliseconds("3500");120 return model;121 }122 @Override123 public SleepAction getAction() {124 return new SleepAction()125 .setMilliseconds("3500");126 }127 @Override128 public void assertModel(TestActionModel model) {129 Assert.assertEquals(model.getType(), "sleep");130 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("milliseconds")).findFirst().orElse(new Property()).getValue(), "3500");131 }132 @Override133 public void assertModel(SleepModel model) {134 Assert.assertEquals(model.getMilliseconds(), "3500");135 }136 }},137 new Object[] {new FailActionConverter(), new ModelAndAssertion<FailModel, FailAction>() {138 @Override139 public FailModel getModel() {140 FailModel model = new FailModel();141 model.setMessage("Should fail!");142 return model;143 }144 @Override145 public FailAction getAction() {146 return new FailAction()147 .setMessage("Should fail!");148 }149 @Override150 public void assertModel(TestActionModel model) {151 Assert.assertEquals(model.getType(), "fail");152 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("message")).findFirst().orElse(new Property()).getValue(), "Should fail!");153 }154 @Override155 public void assertModel(FailModel model) {156 Assert.assertEquals(model.getMessage(), "Should fail!");157 }158 }},159 new Object[] {new ParallelContainerConverter().setActionConverter(Arrays.asList(new EchoActionConverter(), new SleepActionConverter())), new ModelAndAssertion<ParallelModel, Parallel>() {160 @Override161 public ParallelModel getModel() {162 ParallelModel model = new ParallelModel();163 EchoModel nested = new EchoModel();164 nested.setMessage("Nested action");165 model.getActionsAndSendsAndReceives().add(nested);166 SleepModel nested2 = new SleepModel();167 nested2.setMilliseconds("1000");168 model.getActionsAndSendsAndReceives().add(nested2);169 return model;170 }171 @Override172 public Parallel getAction() {173 Parallel container = new Parallel();174 container.addTestAction(new EchoAction().setMessage("Nested action"));175 container.addTestAction(new SleepAction().setMilliseconds("1000"));176 return container;177 }178 @Override179 public void assertModel(TestActionModel model) {180 Assert.assertEquals(model.getType(), "parallel");181 Assert.assertEquals(model.getActions().size(), 2L);182 }183 @Override184 public void assertModel(ParallelModel model) {185 Assert.assertEquals(model.getActionsAndSendsAndReceives().size(), 2L);186 }187 }},188 new Object[] {new SequentialContainerConverter().setActionConverter(Collections.singletonList(new EchoActionConverter())), new ModelAndAssertion<SequentialModel, Sequence>() {189 @Override190 public SequentialModel getModel() {191 SequentialModel model = new SequentialModel();192 EchoModel nested = new EchoModel();193 nested.setMessage("Nested action");194 model.getActionsAndSendsAndReceives().add(nested);195 SleepModel nested2 = new SleepModel();196 nested2.setMilliseconds("1000");197 model.getActionsAndSendsAndReceives().add(nested2);198 return model;199 }200 @Override201 public Sequence getAction() {202 Sequence container = new Sequence();203 container.addTestAction(new EchoAction().setMessage("Nested action"));204 container.addTestAction(new SleepAction().setMilliseconds("1000"));205 return container;206 }207 @Override208 public void assertModel(TestActionModel model) {209 Assert.assertEquals(model.getType(), "sequential");210 Assert.assertEquals(model.getActions().size(), 2L);211 }212 @Override213 public void assertModel(SequentialModel model) {214 Assert.assertEquals(model.getActionsAndSendsAndReceives().size(), 2L);215 }216 }},217 new Object[] {new IterateContainerConverter().setActionConverter(Arrays.asList(new EchoActionConverter(), new SleepActionConverter())), new ModelAndAssertion<IterateModel, Iterate>() {218 @Override219 public IterateModel getModel() {220 IterateModel model = new IterateModel();221 EchoModel nested = new EchoModel();222 nested.setMessage("Nested action");223 model.getActionsAndSendsAndReceives().add(nested);224 SleepModel nested2 = new SleepModel();225 nested2.setMilliseconds("1000");226 model.getActionsAndSendsAndReceives().add(nested2);227 return model;228 }229 @Override230 public Iterate getAction() {231 Iterate container = new Iterate();232 container.addTestAction(new EchoAction().setMessage("Nested action"));233 container.addTestAction(new SleepAction().setMilliseconds("1000"));234 return container;235 }236 @Override237 public void assertModel(TestActionModel model) {238 Assert.assertEquals(model.getType(), "iterate");239 Assert.assertEquals(model.getActions().size(), 2L);240 }241 @Override242 public void assertModel(IterateModel model) {243 Assert.assertEquals(model.getActionsAndSendsAndReceives().size(), 2L);244 }245 }},246 new Object[] {new RepeatOnErrorContainerConverter().setActionConverter(Arrays.asList(new EchoActionConverter(), new SleepActionConverter())), new ModelAndAssertion<RepeatOnerrorUntilTrueModel, RepeatOnErrorUntilTrue>() {247 @Override248 public RepeatOnerrorUntilTrueModel getModel() {249 RepeatOnerrorUntilTrueModel model = new RepeatOnerrorUntilTrueModel();250 EchoModel nested = new EchoModel();251 nested.setMessage("Nested action");252 model.getActionsAndSendsAndReceives().add(nested);253 SleepModel nested2 = new SleepModel();254 nested2.setMilliseconds("1000");255 model.getActionsAndSendsAndReceives().add(nested2);256 return model;257 }258 @Override259 public RepeatOnErrorUntilTrue getAction() {260 RepeatOnErrorUntilTrue container = new RepeatOnErrorUntilTrue();261 container.addTestAction(new EchoAction().setMessage("Nested action"));262 container.addTestAction(new SleepAction().setMilliseconds("1000"));263 return container;264 }265 @Override266 public void assertModel(TestActionModel model) {267 Assert.assertEquals(model.getType(), "repeat-on-error");268 Assert.assertEquals(model.getActions().size(), 2L);269 }270 @Override271 public void assertModel(RepeatOnerrorUntilTrueModel model) {272 Assert.assertEquals(model.getActionsAndSendsAndReceives().size(), 2L);273 }274 }},275 new Object[] {new RepeatContainerConverter().setActionConverter(Arrays.asList(new EchoActionConverter(), new SleepActionConverter())), new ModelAndAssertion<RepeatUntilTrueModel, RepeatUntilTrue>() {276 @Override277 public RepeatUntilTrueModel getModel() {278 RepeatUntilTrueModel model = new RepeatUntilTrueModel();279 EchoModel nested = new EchoModel();280 nested.setMessage("Nested action");281 model.getActionsAndSendsAndReceives().add(nested);282 SleepModel nested2 = new SleepModel();283 nested2.setMilliseconds("1000");284 model.getActionsAndSendsAndReceives().add(nested2);285 return model;286 }287 @Override288 public RepeatUntilTrue getAction() {289 RepeatUntilTrue container = new RepeatUntilTrue();290 container.addTestAction(new EchoAction().setMessage("Nested action"));291 container.addTestAction(new SleepAction().setMilliseconds("1000"));292 return container;293 }294 @Override295 public void assertModel(TestActionModel model) {296 Assert.assertEquals(model.getType(), "repeat");297 Assert.assertEquals(model.getActions().size(), 2L);298 }299 @Override300 public void assertModel(RepeatUntilTrueModel model) {301 Assert.assertEquals(model.getActionsAndSendsAndReceives().size(), 2L);302 }303 }},304 new Object[] {new TimerContainerConverter().setActionConverter(Arrays.asList(new EchoActionConverter(), new SleepActionConverter())), new ModelAndAssertion<TimerModel, Timer>() {305 @Override306 public TimerModel getModel() {307 TimerModel model = new TimerModel();308 EchoModel nested = new EchoModel();309 nested.setMessage("Nested action");310 model.getActionsAndSendsAndReceives().add(nested);311 SleepModel nested2 = new SleepModel();312 nested2.setMilliseconds("1000");313 model.getActionsAndSendsAndReceives().add(nested2);314 return model;315 }316 @Override317 public Timer getAction() {318 Timer container = new Timer();319 container.addTestAction(new EchoAction().setMessage("Nested action"));320 container.addTestAction(new SleepAction().setMilliseconds("1000"));321 return container;322 }323 @Override324 public void assertModel(TestActionModel model) {325 Assert.assertEquals(model.getType(), "timer");326 Assert.assertEquals(model.getActions().size(), 2L);327 }328 @Override329 public void assertModel(TimerModel model) {330 Assert.assertEquals(model.getActionsAndSendsAndReceives().size(), 2L);331 }332 }},333 new Object[] {new ConditionalContainerConverter().setActionConverter(Arrays.asList(new EchoActionConverter(), new SleepActionConverter())), new ModelAndAssertion<ConditionalModel, Conditional>() {334 @Override335 public ConditionalModel getModel() {336 ConditionalModel model = new ConditionalModel();337 EchoModel nested = new EchoModel();338 nested.setMessage("Nested action");339 model.getActionsAndSendsAndReceives().add(nested);340 SleepModel nested2 = new SleepModel();341 nested2.setMilliseconds("1000");342 model.getActionsAndSendsAndReceives().add(nested2);343 return model;344 }345 @Override346 public Conditional getAction() {347 Conditional container = new Conditional();348 container.addTestAction(new EchoAction().setMessage("Nested action"));349 container.addTestAction(new SleepAction().setMilliseconds("1000"));350 return container;351 }352 @Override353 public void assertModel(TestActionModel model) {354 Assert.assertEquals(model.getType(), "conditional");355 Assert.assertEquals(model.getActions().size(), 2L);356 }357 @Override358 public void assertModel(ConditionalModel model) {359 Assert.assertEquals(model.getActionsAndSendsAndReceives().size(), 2L);360 }361 }},362 new Object[] {new CatchContainerConverter().setActionConverter(Arrays.asList(new FailActionConverter())), new ModelAndAssertion<CatchModel, Catch>() {363 @Override364 public CatchModel getModel() {365 CatchModel model = new CatchModel();366 FailModel nested = new FailModel();367 nested.setMessage("Should fail!");368 model.getActionsAndSendsAndReceives().add(nested);369 return model;370 }371 @Override372 public Catch getAction() {373 Catch container = new Catch();374 container.addTestAction(new FailAction().setMessage("Should fail!"));375 return container;376 }377 @Override378 public void assertModel(TestActionModel model) {379 Assert.assertEquals(model.getType(), "catch");380 Assert.assertEquals(model.getActions().size(), 1L);381 }382 @Override383 public void assertModel(CatchModel model) {384 Assert.assertEquals(model.getActionsAndSendsAndReceives().size(), 1L);385 }386 }},387 new Object[] {new AssertContainerConverter().setActionConverter(Collections.singletonList(new EchoActionConverter())), new ModelAndAssertion<AssertModel, com.consol.citrus.container.Assert>() {388 @Override389 public AssertModel getModel() {390 AssertModel model = new AssertModel();391 EchoModel nested = new EchoModel();392 nested.setMessage("Nested action");393 model.setWhen(new AssertModel.When());394 model.getWhen().setEcho(nested);395 return model;396 }397 @Override398 public com.consol.citrus.container.Assert getAction() {399 com.consol.citrus.container.Assert action = new com.consol.citrus.container.Assert();400 action.setAction(new EchoAction().setMessage("Should raise a fault!"));401 return action;402 }403 @Override404 public void assertModel(TestActionModel model) {405 Assert.assertEquals(model.getType(), "assert");406 Assert.assertEquals(model.getActions().size(), 1L);407 }408 @Override409 public void assertModel(AssertModel model) {410 Assert.assertNotNull(model.getWhen().getEcho());411 }412 }},413 new Object[] {new AssertSoapFaultContainerConverter().setActionConverter(Collections.singletonList(new EchoActionConverter())), new ModelAndAssertion<AssertFaultModel, AssertSoapFault>() {414 @Override415 public AssertFaultModel getModel() {416 AssertFaultModel model = new AssertFaultModel();417 EchoModel nested = new EchoModel();418 nested.setMessage("Nested action");419 model.setWhen(new AssertFaultModel.When());420 model.getWhen().setEcho(nested);421 return model;422 }423 @Override424 public AssertSoapFault getAction() {425 return new AssertSoapFault()426 .setAction(new EchoAction().setMessage("Should raise a fault!"));427 }428 @Override429 public void assertModel(TestActionModel model) {430 Assert.assertEquals(model.getType(), "assert-fault");431 Assert.assertEquals(model.getActions().size(), 1L);432 }433 @Override434 public void assertModel(AssertFaultModel model) {435 Assert.assertNotNull(model.getWhen().getEcho());436 Assert.assertEquals(model.getWhen().getEcho().getMessage(), "Should raise a fault!");437 }438 }},439 new Object[] {new SendRequestActionConverter(), new ModelAndAssertion<SendRequestModel, SendMessageAction>() {440 @Override441 public SendRequestModel getModel() {442 SendRequestModel model = new SendRequestModel();443 model.setClient("myEndpoint");444 ClientRequestType request = new ClientRequestType();445 request.setBody(new ClientRequestType.Body());446 request.getBody().setData("Hello Citrus!");447 model.setPOST(request);448 return model;449 }450 @Override451 public SendMessageAction getAction() {452 return new SendMessageAction()453 .setEndpointUri("myEndpoint");454 }455 @Override456 public void assertModel(TestActionModel model) {457 Assert.assertEquals(model.getType(), "http-client:send");458 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("endpoint")).findFirst().orElse(new Property()).getValue(), "myEndpoint");459 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("body")).findFirst().orElse(new Property()).getValue(), "Hello Citrus!");460 }461 @Override462 public void assertModel(SendRequestModel model) {463 Assert.assertEquals(model.getClient(), "myEndpoint");464 }465 }},466 new Object[] {new ReceiveResponseActionConverter(), new ModelAndAssertion<ReceiveResponseModel, ReceiveMessageAction>() {467 @Override468 public ReceiveResponseModel getModel() {469 ReceiveResponseModel model = new ReceiveResponseModel();470 model.setClient("myEndpoint");471 ReceiveResponseModel.Headers headers = new ReceiveResponseModel.Headers();472 headers.setStatus(HttpStatus.OK.toString());473 model.setHeaders(headers);474 return model;475 }476 @Override477 public ReceiveMessageAction getAction() {478 return new ReceiveMessageAction()479 .setEndpointUri("myEndpoint");480 }481 @Override482 public void assertModel(TestActionModel model) {483 Assert.assertEquals(model.getType(), "http-client:receive");484 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("endpoint")).findFirst().orElse(new Property()).getValue(), "myEndpoint");485 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("status")).findFirst().orElse(new Property()).getValue(), "200");486 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("version")).findFirst().orElse(new Property()).getValue(), "HTTP/1.1");487 }488 @Override489 public void assertModel(ReceiveResponseModel model) {490 Assert.assertEquals(model.getClient(), "myEndpoint");491 }492 }},493 new Object[] {new ReceiveRequestActionConverter(), new ModelAndAssertion<ReceiveRequestModel, ReceiveMessageAction>() {494 @Override495 public ReceiveRequestModel getModel() {496 ReceiveRequestModel model = new ReceiveRequestModel();497 model.setServer("myEndpoint");498 ServerRequestType request = new ServerRequestType();499 request.setBody(new ServerRequestType.Body());500 request.getBody().setData("Hello Citrus!");501 model.setPOST(request);502 return model;503 }504 @Override505 public ReceiveMessageAction getAction() {506 return new ReceiveMessageAction()507 .setEndpointUri("myEndpoint");508 }509 @Override510 public void assertModel(TestActionModel model) {511 Assert.assertEquals(model.getType(), "http-server:receive");512 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("endpoint")).findFirst().orElse(new Property()).getValue(), "myEndpoint");513 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("body")).findFirst().orElse(new Property()).getValue(), "Hello Citrus!");514 }515 @Override516 public void assertModel(ReceiveRequestModel model) {517 Assert.assertEquals(model.getServer(), "myEndpoint");518 }519 }},520 new Object[] {new SendResponseActionConverter(), new ModelAndAssertion<SendResponseModel, SendMessageAction>() {521 @Override522 public SendResponseModel getModel() {523 SendResponseModel model = new SendResponseModel();524 model.setServer("myEndpoint");525 ResponseHeadersType headers = new ResponseHeadersType();526 headers.setStatus(HttpStatus.OK.toString());527 model.setHeaders(headers);528 return model;529 }530 @Override531 public SendMessageAction getAction() {532 return new SendMessageAction()533 .setEndpointUri("myEndpoint");534 }535 @Override536 public void assertModel(TestActionModel model) {537 Assert.assertEquals(model.getType(), "http-server:send");538 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("endpoint")).findFirst().orElse(new Property()).getValue(), "myEndpoint");539 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("status")).findFirst().orElse(new Property()).getValue(), "200");540 Assert.assertEquals(model.getProperties().stream().filter(property -> property.getName().equals("version")).findFirst().orElse(new Property()).getValue(), "HTTP/1.1");541 }542 @Override543 public void assertModel(SendResponseModel model) {544 Assert.assertEquals(model.getServer(), "myEndpoint");545 }546 }},547 new Object[] {new ActionConverter("sample"), new ModelAndAssertion<ActionModel, EchoAction>() {548 @Override549 public ActionModel getModel() {550 return new ActionModel();551 }552 @Override553 public EchoAction getAction() {554 return new EchoAction()555 .setMessage("Hello Citrus!");556 }557 @Override558 public void assertModel(TestActionModel model) {559 Assert.assertEquals(model.getType(), "sample");560 }561 @Override562 public void assertModel(ActionModel model) {563 Assert.assertNotNull(model.getReference());564 }565 }},566 };567 }568 /**569 * Model assertion interface.570 */571 interface ModelAndAssertion<T, A extends TestAction> {572 void assertModel(T action);573 void assertModel(TestActionModel model);574 T getModel();575 A getAction();576 }577}...
Source:AssertExceptionTestRunnerTest.java
...32 assertException().when(fail("Error!"));33 }34 };35 TestCase test = builder.getTestCase();36 assertEquals(test.getActionCount(), 1);37 assertEquals(test.getActions().get(0).getClass(), Assert.class);38 assertEquals(test.getActions().get(0).getName(), "assert");39 Assert container = (Assert)(test.getTestAction(0));40 assertEquals(container.getActionCount(), 1);41 assertEquals(container.getAction().getClass(), FailAction.class);42 assertEquals(container.getException(), CitrusRuntimeException.class);43 }44 @Test45 public void testAssertBuilder() {46 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {47 @Override48 public void execute() {49 assertException().exception(CitrusRuntimeException.class)50 .message("Unknown variable 'foo'")51 .when(echo("${foo}"));52 }53 };54 TestCase test = builder.getTestCase();55 assertEquals(test.getActionCount(), 1);56 assertEquals(test.getActions().get(0).getClass(), Assert.class);57 assertEquals(test.getActions().get(0).getName(), "assert");58 59 Assert container = (Assert)(test.getTestAction(0));60 61 assertEquals(container.getActionCount(), 1);62 assertEquals(container.getAction().getClass(), EchoAction.class);63 assertEquals(container.getException(), CitrusRuntimeException.class);64 assertEquals(container.getMessage(), "Unknown variable 'foo'");65 assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");66 }67 @Test68 public void testAssertBuilderWithAnonymousAction() {69 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {70 @Override71 public void execute() {72 assertException().exception(CitrusRuntimeException.class)73 .message("Unknown variable 'foo'")74 .when(new AbstractTestAction() {75 @Override76 public void doExecute(TestContext context) {77 context.getVariable("foo");78 }79 });80 }81 };82 TestCase test = builder.getTestCase();83 assertEquals(test.getActionCount(), 1);84 assertEquals(test.getActions().get(0).getClass(), Assert.class);85 assertEquals(test.getActions().get(0).getName(), "assert");86 Assert container = (Assert)(test.getTestAction(0));87 assertEquals(container.getActionCount(), 1);88 assertTrue(container.getAction().getClass().isAnonymousClass());89 assertEquals(container.getException(), CitrusRuntimeException.class);90 assertEquals(container.getMessage(), "Unknown variable 'foo'");91 }92}...
Source:AssertTestDesignerTest.java
...37 }38 };39 builder.configure();40 TestCase test = builder.getTestCase();41 assertEquals(test.getActionCount(), 1);42 assertEquals(test.getActions().get(0).getClass(), Assert.class);43 assertEquals(test.getActions().get(0).getName(), "assert");44 Assert container = (Assert)(test.getTestAction(0));45 assertEquals(container.getActionCount(), 1);46 assertEquals(container.getAction().getClass(), EchoAction.class);47 assertEquals(container.getException(), CitrusRuntimeException.class);48 assertEquals(container.getMessage(), "Unknown variable 'foo'");49 assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");50 }51 @Test52 public void testAssertBuilderWithAnonymousAction() {53 MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {54 @Override55 public void configure() {56 assertException()57 .exception(CitrusRuntimeException.class)58 .message("Unknown variable 'foo'")59 .when(new AbstractTestAction() {60 @Override61 public void doExecute(TestContext context) {62 context.getVariable("foo");63 }64 });65 }66 };67 builder.configure();68 TestCase test = builder.getTestCase();69 assertEquals(test.getActionCount(), 1);70 assertEquals(test.getActions().get(0).getClass(), Assert.class);71 assertEquals(test.getActions().get(0).getName(), "assert");72 Assert container = (Assert)(test.getTestAction(0));73 assertEquals(container.getActionCount(), 1);74 assertTrue(container.getAction().getClass().isAnonymousClass());75 assertEquals(container.getException(), CitrusRuntimeException.class);76 assertEquals(container.getMessage(), "Unknown variable 'foo'");77 }78}...
getAction
Using AI Code Generation
1package com.consol.citrus.container;2import com.consol.citrus.actions.EchoAction;3import com.consol.citrus.testng.AbstractTestNGCitrusTest;4import org.testng.annotations.Test;5public class AssertTest extends AbstractTestNGCitrusTest {6public void testAssert() {7}8}9package com.consol.citrus.container;10import com.consol.citrus.actions.EchoAction;11import com.consol.citrus.testng.AbstractTestNGCitrusTest;12import org.testng.annotations.Test;13public class AssertTest extends AbstractTestNGCitrusTest {14public void testAssert() {15}16}17package com.consol.citrus.container;18import com.consol.citrus.actions.EchoAction;19import com.consol.citrus.testng.AbstractTestNGCitrusTest;20import org.testng.annotations.Test;21public class AssertTest extends AbstractTestNGCitrusTest {22public void testAssert() {
getAction
Using AI Code Generation
1package com.consol.citrus.container;2import com.consol.citrus.TestCase;3import com.consol.citrus.annotations.CitrusTest;4import com.consol.citrus.dsl.builder.AbstractTestBehaviorBuilder;5import com.consol.citrus.dsl.builder.AssertBuilder;6import com.consol.citrus.dsl.builder.HttpClientActionBuilder;7import com.consol.citrus.dsl.builder.HttpServerActionBuilder;8import com.consol.citrus.dsl.builder.SendMessageActionBuilder;9import com.consol.citrus.dsl.junit.JUnit4CitrusTestRunner;10import org.junit.Test;11import org.springframework.http.HttpStatus;12public class 4 extends JUnit4CitrusTestRunner {13 public void 4() {14 variable("name", "John Doe");15 variable("id", "123");16 http(httpServerActionBuilder -> httpServerActionBuilder.server("httpServer")17 .receive()18 .post()19 .payload("<testRequestMessage><text>Hello World!</text></testRequestMessage>"));20 http(httpClientActionBuilder -> httpClientActionBuilder.client("httpClient")21 .send()22 .post()23 .payload("<testRequestMessage><text>Hello World!</text></testRequestMessage>")24 .header("Operation", "greeting"));25 http(httpClientActionBuilder -> httpClientActionBuilder.client("httpClient")26 .receive()27 .response(HttpStatus.OK)28 .payload("<testResponseMessage><text>Hello " + "${name}" + "!</text></testResponseMessage>"));29 http(httpServerActionBuilder -> httpServerActionBuilder.server("httpServer")30 .send()31 .response(HttpStatus.OK)32 .payload("<testResponseMessage><text>Hello " + "${name}" + "!</text></testResponseMessage>"));33 echo("4");34 send(sendMessageActionBuilder -> sendMessageActionBuilder.endpoint("foo")35 .message("<testRequestMessage><text>Hello World!</text></testRequestMessage>"));36 receive(receiveMessageActionBuilder -> receiveMessageActionBuilder.endpoint("foo")37 .message("<testResponseMessage><text>Hello World!</text></testResponseMessage>"));38 soap(soapActionBuilder -> soapActionBuilder.client("soapClient")39 .send()40 .soapAction("greeting")41 .payload("<testRequestMessage><text>Hello World!</text></testRequestMessage>"));42 soap(soapActionBuilder -> soapActionBuilder.server("soapServer")
getAction
Using AI Code Generation
1public class 4 extends TestNGCitrusTestDesigner {2 public void 4() {3 variable("var1", "value1");4 variable("var2", "value2");5 variable("var3", "value3");6 variable("var4", "value4");7 variable("var5", "value5");8 variable("var6", "value6");9 variable("var7", "value7");10 variable("var8", "value8");11 variable("var9", "value9");12 variable("var10", "value10");13 variable("var11", "value11");14 variable("var12", "value12");15 variable("var13", "value13");16 variable("var14", "value14");17 variable("var15", "value15");18 variable("var16", "value16");19 variable("var17", "value17");20 variable("var18", "value18");21 variable("var19", "value19");22 variable("var20", "value20");23 variable("var21", "value21");24 variable("var22", "value22");25 variable("var23", "value23");26 variable("var24", "value24");27 variable("var25", "value25");28 variable("var26", "value26");29 variable("var27", "value27");30 variable("var28", "value28");31 variable("var29", "value29");32 variable("var30", "value30");33 variable("var31", "value31");34 variable("var32", "value32");35 variable("var33", "value33");36 variable("var34", "value34");37 variable("var35", "value35");38 variable("var36", "value36");39 variable("var37", "value37");40 variable("var38", "value38");41 variable("var39", "value39");42 variable("var40", "value40");43 variable("var41", "value41");44 variable("var42", "value42");45 variable("var43", "value43");46 variable("var44", "value44");47 variable("var45", "value45");48 variable("var46", "value46");49 variable("var47", "value47");50 variable("var48
getAction
Using AI Code Generation
1public void test1() {2 variable("test1", "test1");3 variable("test2", "test2");4 variable("test3", "test3");5 variable("test4", "test4");6 variable("test5", "test5");7 variable("test6", "test6");8 variable("test7", "test7");9 variable("test8", "test8");10 variable("test9", "test9");11 variable("test10", "test10");12 variable("test11", "test11");13 variable("test12", "test12");14 variable("test13", "test13");15 variable("test14", "test14");16 variable("test15", "test15");17 variable("test16", "test16");18 variable("test17", "test17");19 variable("test18", "test18");20 variable("test19", "test19");21 variable("test20", "test20");22 variable("test21", "test21");23 variable("test22", "test22");24 variable("test23", "test23");25 variable("test24", "test24");26 variable("test25", "test25");27 variable("test26", "test26");28 variable("test27", "test27");29 variable("test28", "test28");30 variable("test29", "test29");31 variable("test30", "test30");32 variable("test31", "test31");33 variable("test32", "test32");34 variable("test33", "test33");35 variable("test34", "test34");36 variable("test35", "test35");37 variable("test36", "test36");38 variable("test37", "test37");39 variable("test38", "test38");40 variable("test39", "test39");41 variable("test40", "test40");42 variable("test41", "test41");43 variable("test42", "test42");44 variable("test43", "test43");45 variable("test44", "test44");46 variable("test45", "test45");47 variable("test46", "test46");48 variable("test47", "test47");49 variable("test48", "test48");50 variable("test49", "test49");
getAction
Using AI Code Generation
1package com.consol.citrus.container;2import com.consol.citrus.TestAction;3import com.consol.citrus.dsl.builder.AssertBuilder;4import com.consol.citrus.dsl.builder.BuilderSupport;5import com.consol.citrus.dsl.builder.DelegatingTestActionBuilder;6import com.consol.citrus.dsl.builder.ReceiveMessageBuilder;7import com.consol.citrus.dsl.builder.SendMessageBuilder;8import com.consol.citrus.dsl.builder.VariableBuilder;9import com.consol.citrus.message.MessageType;10import com.consol.citrus.testng.AbstractTestNGUnitTest;11import org.testng.annotations.Test;12import java.util.ArrayList;13import java.util.Arrays;14import java.util.List;15import static com.consol.citrus.actions.CreateVariablesAction.Builder.createVariable;16import static com.consol.citrus.actions.EchoAction.Builder.echo;17import static com.consol.citrus.actions.FailAction.Builder.fail;18import static com.consol.citrus.actions.PurgeEndpointAction.Builder.purge;19import static com.consol.citrus.actions.ReceiveTimeoutAction.Builder.receiveTimeout;20import static com.consol.citrus.actions.SendMessageAction.Builder.send;21import static com.consol.citrus.actions.SleepAction.Builder.sleep;22import static com.consol.citrus.actions.StopTimeAction.Builder.stopTime;23import static com.consol.citrus.actions.TraceVariablesAction.Builder.trace;24import static com.consol.citrus.actions.ValidateVariablesAction.Builder.validate;25import static com.consol.citrus.container.Assert.Builder.assertException;26import static com.consol.citrus.container.Assert.Builder.assertSoapFault;27import static com.consol.citrus.container.Assert.Builder.assertSoapFaultWithXPath;28import static com.consol.citrus.container.Assert.Builder.condition;29import static com.consol.citrus.container.Assert.Builder.xPath;30import static com.consol.citrus.container.FinallySequence.Builder.doFinally;31import static com.consol.citrus.container.Iterate.Builder.iterate;32import static com.consol.citrus.container.Parallel.Builder.parallel;33import static com.consol.citrus.container.Sequence.Builder.sequential;34import static com.consol.citrus.container.TestCase.Builder.testCase;35import static com.consol.citrus.container.TestSuite.Builder.testSuite;36import static com.consol.citrus.container.Wait.Builder.waitFor;37import static com.consol.citrus.container.Wait.Builder.waitForBuilder;38import static com.consol.cit
getAction
Using AI Code Generation
1public class AssertTest extends TestNGCitrusTestRunner {2 public void assertTest() {3 variable("value", "Hello Citrus!");4 echo("Variable value: ${value}");5 assertException().when(() -> {6 echo("Variable value: ${value}");
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!