How to use testFaultDetail method of com.consol.citrus.dsl.runner.AssertSoapFaultTestRunnerTest class

Best Citrus code snippet using com.consol.citrus.dsl.runner.AssertSoapFaultTestRunnerTest.testFaultDetail

Source:AssertSoapFaultTestRunnerTest.java Github

copy

Full Screen

...129 verify(soapFaultValidator).validateSoapFault(any(com.consol.citrus.ws.message.SoapFault.class), any(com.consol.citrus.ws.message.SoapFault.class),130 any(TestContext.class), any(ValidationContext.class));131 }132 @Test133 public void testFaultDetail() {134 reset(applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);135 when(soapMessage.getSoapBody()).thenReturn(soapBody);136 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);137 when(soapBody.getFault()).thenReturn(soapFault);138 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());139 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);140 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);141 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);142 when(soapFaultDetail.getDetailEntries()).thenReturn(Collections.singleton(soapFaultDetailElement).iterator());143 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><message>Something went wrong</message></ErrorDetail>"));144 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));145 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);146 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());147 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());148 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());149 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {150 @Override151 public void execute() {152 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())153 .faultString(INTERNAL_SERVER_ERROR)154 .faultDetail("<ErrorDetail><message>Something went wrong</message></ErrorDetail>")155 .when(new AbstractTestAction() {156 @Override157 public void doExecute(TestContext context) {158 throw new SoapFaultClientException(soapMessage);159 }160 });161 }162 };163 TestCase test = builder.getTestCase();164 Assert.assertEquals(test.getActionCount(), 1);165 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);166 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");167 168 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));169 170 Assert.assertEquals(container.getActionCount(), 1);171 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());172 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());173 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);174 Assert.assertEquals(container.getFaultDetails().size(), 1L);175 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><message>Something went wrong</message></ErrorDetail>");176 }177 178 @Test179 public void testMultipleFaultDetails() {180 reset(applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);181 when(soapMessage.getSoapBody()).thenReturn(soapBody);182 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);183 when(soapBody.getFault()).thenReturn(soapFault);184 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());185 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);186 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);187 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);188 when(soapFaultDetail.getDetailEntries()).thenReturn(Arrays.asList(soapFaultDetailElement, soapFaultDetailElement).iterator());189 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><code>1001</code></ErrorDetail>"))190 .thenReturn(new StringSource("<MessageDetail><message>Something went wrong</message></MessageDetail>"));191 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));192 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);193 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());194 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());195 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());196 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {197 @Override198 public void execute() {199 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())200 .faultString(INTERNAL_SERVER_ERROR)201 .faultDetail("<ErrorDetail><code>1001</code></ErrorDetail>")202 .faultDetail("<MessageDetail><message>Something went wrong</message></MessageDetail>")203 .when(new AbstractTestAction() {204 @Override205 public void doExecute(TestContext context) {206 throw new SoapFaultClientException(soapMessage);207 }208 });209 }210 };211 TestCase test = builder.getTestCase();212 Assert.assertEquals(test.getActionCount(), 1);213 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);214 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");215 216 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));217 218 Assert.assertEquals(container.getActionCount(), 1);219 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());220 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());221 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);222 Assert.assertEquals(container.getFaultDetails().size(), 2L);223 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><code>1001</code></ErrorDetail>");224 Assert.assertEquals(container.getFaultDetails().get(1), "<MessageDetail><message>Something went wrong</message></MessageDetail>");225 }226 227 @Test228 public void testFaultDetailResource() throws IOException {229 reset(resource, applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);230 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<ErrorDetail><message>Something went wrong</message></ErrorDetail>".getBytes()));231 when(soapMessage.getSoapBody()).thenReturn(soapBody);232 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);233 when(soapBody.getFault()).thenReturn(soapFault);234 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());235 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);236 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);237 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);238 when(soapFaultDetail.getDetailEntries()).thenReturn(Collections.singleton(soapFaultDetailElement).iterator());239 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><message>Something went wrong</message></ErrorDetail>"));240 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));241 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);242 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());243 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());244 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());245 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {246 @Override247 public void execute() {248 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())249 .faultString(INTERNAL_SERVER_ERROR)250 .faultDetailResource(resource)251 .when(new AbstractTestAction() {252 @Override253 public void doExecute(TestContext context) {254 throw new SoapFaultClientException(soapMessage);255 }256 });257 }258 };259 TestCase test = builder.getTestCase();260 Assert.assertEquals(test.getActionCount(), 1);261 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);262 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");263 264 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));265 266 Assert.assertEquals(container.getActionCount(), 1);267 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());268 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());269 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);270 Assert.assertEquals(container.getFaultDetails().size(), 1L);271 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><message>Something went wrong</message></ErrorDetail>");272 }273 @Test274 public void testFaultDetailResourcePath() {275 reset(applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);276 when(soapMessage.getSoapBody()).thenReturn(soapBody);277 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);278 when(soapBody.getFault()).thenReturn(soapFault);279 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());280 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);281 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);282 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);283 when(soapFaultDetail.getDetailEntries()).thenReturn(Collections.singleton(soapFaultDetailElement).iterator());284 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><message>Something went wrong</message></ErrorDetail>"));285 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));286 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);287 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());288 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());...

Full Screen

Full Screen

testFaultDetail

Using AI Code Generation

copy

Full Screen

1 public void testFaultDetail() {2 run(new AssertSoapFaultTestRunnerTest() {3 public void run() {4 testFaultDetail("detail", "faultDetail");5 }6 });7 }8 public void testFaultDetailWithJsonPath() {9 run(new AssertSoapFaultTestRunnerTest() {10 public void run() {11 testFaultDetail("detail", "$.faultDetail");12 }13 });14 }15 public void testFaultDetailWithXmlPath() {16 run(new AssertSoapFaultTestRunnerTest() {17 public void run() {18 testFaultDetail("detail", "/faultDetail");19 }20 });21 }22 public void testFaultDetailWithJsonPathValidation() {23 run(new AssertSoapFaultTestRunnerTest() {24 public void run() {25 testFaultDetail("detail", "$.faultDetail", "citrus:jsonPath('$.faultDetail')");26 }27 });28 }29 public void testFaultDetailWithXmlPathValidation() {30 run(new AssertSoapFaultTestRunnerTest() {31 public void run() {32 testFaultDetail("detail", "/faultDetail", "citrus:xmlPath('/faultDetail')");33 }34 });35 }36 public void testFaultDetailWithXPathValidation() {37 run(new AssertSoapFaultTestRunnerTest() {38 public void run() {39 testFaultDetail("detail", "/faultDetail", "citrus:xpath('/faultDetail')");40 }41 });

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