How to use testAssertSoapFaultBuilder method of com.consol.citrus.dsl.design.AssertSoapFaultTestDesignerTest class

Best Citrus code snippet using com.consol.citrus.dsl.design.AssertSoapFaultTestDesignerTest.testAssertSoapFaultBuilder

Source:AssertSoapFaultTestDesignerTest.java Github

copy

Full Screen

...39 private Resource resource = Mockito.mock(Resource.class);40 private SoapFaultValidator soapFaultValidator = Mockito.mock(SoapFaultValidator.class);41 private ReferenceResolver referenceResolver = Mockito.mock(ReferenceResolver.class);42 @Test43 public void testAssertSoapFaultBuilder() {44 reset(referenceResolver);45 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);46 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);47 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());48 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());49 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());50 context.setReferenceResolver(referenceResolver);51 MockTestDesigner builder = new MockTestDesigner(context) {52 @Override53 public void configure() {54 assertSoapFault()55 .faultCode(SOAP_ENV_SERVER_ERROR)56 .faultString(INTERNAL_SERVER_ERROR)57 .when(echo("${foo}"));58 }59 };60 builder.configure();61 TestCase test = builder.getTestCase();62 Assert.assertEquals(test.getActionCount(), 1);63 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);64 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");65 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));66 Assert.assertEquals(container.getActionCount(), 1);67 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);68 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);69 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);70 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");71 }72 @Test73 public void testFaultDetail() {74 reset(referenceResolver);75 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);76 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);77 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());78 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());79 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());80 context.setReferenceResolver(referenceResolver);81 MockTestDesigner builder = new MockTestDesigner(context) {82 @Override83 public void configure() {84 assertSoapFault()85 .faultCode(SOAP_ENV_SERVER_ERROR)86 .faultString(INTERNAL_SERVER_ERROR)87 .faultDetail("<ErrorDetail><message>FooBar</message></ErrorDetail>")88 .when(echo("${foo}"));89 }90 };91 builder.configure();92 TestCase test = builder.getTestCase();93 Assert.assertEquals(test.getActionCount(), 1);94 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);95 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");96 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));97 Assert.assertEquals(container.getActionCount(), 1);98 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);99 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);100 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);101 Assert.assertEquals(container.getFaultDetails().size(), 1L);102 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><message>FooBar</message></ErrorDetail>");103 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");104 }105 @Test106 public void testMultipleFaultDetails() {107 reset(referenceResolver);108 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);109 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);110 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());111 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());112 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());113 context.setReferenceResolver(referenceResolver);114 MockTestDesigner builder = new MockTestDesigner(context) {115 @Override116 public void configure() {117 assertSoapFault()118 .faultCode(SOAP_ENV_SERVER_ERROR)119 .faultString(INTERNAL_SERVER_ERROR)120 .faultDetail("<ErrorDetail><code>1001</code></ErrorDetail>")121 .faultDetail("<MessageDetail><message>FooBar</message></MessageDetail>")122 .when(echo("${foo}"));123 }124 };125 builder.configure();126 TestCase test = builder.getTestCase();127 Assert.assertEquals(test.getActionCount(), 1);128 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);129 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");130 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));131 Assert.assertEquals(container.getActionCount(), 1);132 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);133 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);134 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);135 Assert.assertEquals(container.getFaultDetails().size(), 2L);136 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><code>1001</code></ErrorDetail>");137 Assert.assertEquals(container.getFaultDetails().get(1), "<MessageDetail><message>FooBar</message></MessageDetail>");138 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");139 }140 @Test141 public void testFaultDetailResource() throws IOException {142 reset(resource);143 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<ErrorDetail><message>FooBar</message></ErrorDetail>".getBytes()));144 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);145 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);146 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());147 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());148 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());149 context.setReferenceResolver(referenceResolver);150 MockTestDesigner builder = new MockTestDesigner(context) {151 @Override152 public void configure() {153 assertSoapFault()154 .faultCode(SOAP_ENV_SERVER_ERROR)155 .faultString(INTERNAL_SERVER_ERROR)156 .faultDetailResource(resource)157 .when(echo("${foo}"));158 }159 };160 builder.configure();161 TestCase test = builder.getTestCase();162 Assert.assertEquals(test.getActionCount(), 1);163 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);164 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");165 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));166 Assert.assertEquals(container.getActionCount(), 1);167 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);168 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);169 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);170 Assert.assertEquals(container.getFaultDetails().size(), 1L);171 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><message>FooBar</message></ErrorDetail>");172 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");173 }174 @Test175 public void testFaultDetailResourcePath() {176 reset(referenceResolver);177 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);178 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);179 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());180 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());181 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());182 context.setReferenceResolver(referenceResolver);183 MockTestDesigner builder = new MockTestDesigner(context) {184 @Override185 public void configure() {186 assertSoapFault()187 .faultCode(SOAP_ENV_SERVER_ERROR)188 .faultString(INTERNAL_SERVER_ERROR)189 .faultDetailResource("com/consol/citrus/soap/fault.xml")190 .when(echo("${foo}"));191 }192 };193 builder.configure();194 TestCase test = builder.getTestCase();195 Assert.assertEquals(test.getActionCount(), 1);196 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);197 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");198 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));199 Assert.assertEquals(container.getActionCount(), 1);200 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);201 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);202 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);203 Assert.assertEquals(container.getFaultDetails().size(), 0L);204 Assert.assertEquals(container.getFaultDetailResourcePaths().size(), 1L);205 Assert.assertEquals(container.getFaultDetailResourcePaths().get(0), "com/consol/citrus/soap/fault.xml");206 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");207 }208 @Test209 public void testMultipleFaultDetailsInlineAndResource() throws IOException {210 reset(resource);211 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<MessageDetail><message>FooBar</message></MessageDetail>".getBytes()));212 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);213 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);214 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());215 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());216 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());217 context.setReferenceResolver(referenceResolver);218 MockTestDesigner builder = new MockTestDesigner(context) {219 @Override220 public void configure() {221 assertSoapFault()222 .faultCode(SOAP_ENV_SERVER_ERROR)223 .faultString(INTERNAL_SERVER_ERROR)224 .faultDetail("<ErrorDetail><code>1001</code></ErrorDetail>")225 .faultDetailResource(resource)226 .when(echo("${foo}"));227 }228 };229 builder.configure();230 TestCase test = builder.getTestCase();231 Assert.assertEquals(test.getActionCount(), 1);232 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);233 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");234 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));235 Assert.assertEquals(container.getActionCount(), 1);236 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);237 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);238 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);239 Assert.assertEquals(container.getFaultDetails().size(), 2L);240 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><code>1001</code></ErrorDetail>");241 Assert.assertEquals(container.getFaultDetails().get(1), "<MessageDetail><message>FooBar</message></MessageDetail>");242 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");243 }244 @Test245 public void testAssertSoapFaultBuilderWithValidator() {246 reset(referenceResolver);247 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);248 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);249 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());250 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());251 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());252 context.setReferenceResolver(referenceResolver);253 MockTestDesigner builder = new MockTestDesigner(context) {254 @Override255 public void configure() {256 assertSoapFault()257 .faultCode(SOAP_ENV_SERVER_ERROR)258 .faultString(INTERNAL_SERVER_ERROR)259 .validator(soapFaultValidator)260 .when(echo("${foo}"));261 }262 };263 builder.configure();264 TestCase test = builder.getTestCase();265 Assert.assertEquals(test.getActionCount(), 1);266 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);267 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");268 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));269 Assert.assertEquals(container.getActionCount(), 1);270 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);271 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);272 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);273 Assert.assertEquals(container.getValidator(), soapFaultValidator);274 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");275 }276 @Test277 public void testAssertSoapFaultBuilderWithActor() {278 reset(referenceResolver);279 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);280 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);281 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());282 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());283 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());284 context.setReferenceResolver(referenceResolver);285 MockTestDesigner builder = new MockTestDesigner(context) {286 @Override287 public void configure() {288 assertSoapFault()289 .faultCode(SOAP_ENV_SERVER_ERROR)290 .faultString(INTERNAL_SERVER_ERROR)291 .faultActor("MyActor")...

Full Screen

Full Screen

testAssertSoapFaultBuilder

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 AssertSoapFaultTestDesignerTest extends TestNGCitrusTestDesigner {5public void testAssertSoapFaultBuilder() {6run(assertSoapFault()7 .faultCode("Server")8 .faultString("Fault string")9 .faultActor("Fault actor")10 .faultDetail("<detail/>")11 .ignoreFaultCode()12 .ignoreFaultString()13 .ignoreFaultActor()14 .ignoreFaultDetail()15 .ignoreMessage());16}17}18package com.consol.citrus.dsl.design;19import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;20import org.testng.annotations.Test;21public class AssertSoapFaultTestDesignerTest extends TestNGCitrusTestDesigner {22public void testAssertSoapFaultBuilder() {23run(assertSoapFault()24 .faultCode("Server")25 .faultString("Fault string")26 .faultActor("Fault actor")27 .faultDetail("<detail/>")28 .ignoreFaultCode()29 .ignoreFaultString()30 .ignoreFaultActor()31 .ignoreFaultDetail()32 .ignoreMessage());33}34}

Full Screen

Full Screen

testAssertSoapFaultBuilder

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.design;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.testng.AbstractTestNGUnitTest;4import org.testng.annotations.Test;5import static com.consol.citrus.actions.EchoAction.Builder.echo;6import static com.consol.citrus.dsl.design.TestDesigner.Builder.createDesigner;7import static com.consol.citrus.dsl.design.TestDesigner.Builder.createDesignerWithTestRunner;8public class AssertSoapFaultTestDesignerTest extends AbstractTestNGUnitTest {9 public void testAssertSoapFaultBuilder() {10 createDesigner(applicationContext)11 .assertSoapFault()12 .faultCode("Client")13 .faultString("Invalid message")14 .faultDetail("<detail><message>Invalid message</message></detail>")15 .message(echo("Invalid message"))16 .build();17 createDesignerWithTestRunner(applicationContext, new TestRunner())18 .assertSoapFault()19 .faultCode("Client")20 .faultString("Invalid message")21 .faultDetail("<detail><message>Invalid message</message></detail>")22 .message(echo("Invalid message"))23 .build();24 }25}26package com.consol.citrus.dsl.design;27import com.consol.citrus.dsl.runner.TestRunner;28import com.consol.citrus.testng.AbstractTestNGUnitTest;29import org.testng.annotations.Test;30import static com.consol.citrus.actions.EchoAction.Builder.echo;31import static com.consol.citrus.dsl.design.TestDesigner.Builder.createDesigner;32import static com.consol.citrus.dsl.design.TestDesigner.Builder.createDesignerWithTestRunner;33public class AssertSoapFaultTestDesignerTest extends AbstractTestNGUnitTest {34 public void testAssertSoapFaultBuilder() {35 createDesigner(applicationContext)36 .assertSoapFault()37 .faultCode("Client")38 .faultString("Invalid message")39 .faultDetail("<detail><message>Invalid message</message></detail>")40 .message(echo("Invalid message"))41 .build();42 createDesignerWithTestRunner(applicationContext, new TestRunner())43 .assertSoapFault()44 .faultCode("Client")45 .faultString("

Full Screen

Full Screen

testAssertSoapFaultBuilder

Using AI Code Generation

copy

Full Screen

1public void testAssertSoapFaultBuilder() {2 MockEndpoint mockEndpoint = getMockEndpoint("mock:result");3 mockEndpoint.expectedMessageCount(1);4 run(new TestRunner() {5 public void execute() {6 assertSoapFault()7 .faultString("Client error")8 .faultDetail("<detail><message>Client error</message></detail>")9 .when(new TestAction() {10 public void doExecute(TestContext context) {11 send("direct:start")12 .payload("<TestRequestMessage>" +13 .header("operation", "sayHelloFault")14 .header("Content-Type", "text/xml");15 }16 });17 receive("mock:result")18 .payload("<TestResponseMessage>" +19 "</TestResponseMessage>");20 }21 });22 mockEndpoint.assertIsSatisfied();23}

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