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

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

Source:AssertSoapFaultTestRunnerTest.java Github

copy

Full Screen

...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

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