if(mockResponses.isEmpty()){ throw new SoapException("No mocked response created for operation " + soapOperation.getName()); } else if(soapOperation.getResponseStrategy().equals(SoapResponseStrategy.RANDOM)){ final Integer responseIndex = RANDOM.nextInt(mockResponses.size()); mockResponse = mockResponses.get(responseIndex); } else if(soapOperation.getResponseStrategy().equals(SoapResponseStrategy.SEQUENCE)){ Integer currentSequenceNumber = soapOperation.getCurrentResponseSequenceIndex(); if(currentSequenceNumber >= mockResponses.size()){ .currentResponseSequenceIndex(currentSequenceNumber + 1) .build()); } else if (soapOperation.getResponseStrategy().equals(SoapResponseStrategy.XPATH_INPUT)) { for (SoapMockResponse testedMockResponse : mockResponses) { for(SoapXPathExpression xPathExpression : testedMockResponse.getXpathExpressions()){
Assert.assertEquals(operation.getStatus(), returnedSoapOperation.getStatus()); Assert.assertEquals(operation.getForwardedEndpoint(), returnedSoapOperation.getForwardedEndpoint()); Assert.assertEquals(operation.getResponseStrategy(), returnedSoapOperation.getResponseStrategy()); Assert.assertEquals(operation.getSimulateNetworkDelay(), returnedSoapOperation.getSimulateNetworkDelay()); Assert.assertEquals(operation.getNetworkDelay(), returnedSoapOperation.getNetworkDelay());
private void verify(final SoapPort soapPort, final String name, final SoapVersion soapVersion){ Assert.assertEquals(name + ".Endpoint", soapPort.getName()); Assert.assertEquals(name + ".Endpoint", soapPort.getUri()); Assert.assertEquals(1, soapPort.getOperations().size()); SoapOperation soapOperation = soapPort.getOperations().get(0); Assert.assertEquals(name, soapOperation.getName()); Assert.assertEquals(SoapResponseStrategy.RANDOM, soapOperation.getResponseStrategy()); Assert.assertEquals(SoapOperationStatus.MOCKED, soapOperation.getStatus()); Assert.assertEquals(soapVersion, soapOperation.getSoapVersion()); Assert.assertEquals(HttpMethod.POST, soapOperation.getHttpMethod()); SoapOperationIdentifier operationIdentifier = soapOperation.getOperationIdentifier(); Assert.assertNotNull(operationIdentifier); Assert.assertEquals("Request", operationIdentifier.getName()); Assert.assertEquals("http://Services/ServiceExample/ServiceExample/1/Schema", operationIdentifier.getNamespace()); }
/** * The process message is responsible for processing an incoming serviceTask and generate * a response based on the incoming serviceTask input * @param serviceTask The serviceTask that will be processed by the service * @return A result based on the processed incoming serviceTask * @see ServiceTask * @see ServiceResult */ @Override public ServiceResult<UpdateSoapOperationOutput> process(final ServiceTask<UpdateSoapOperationInput> serviceTask) { final UpdateSoapOperationInput input = serviceTask.getInput(); final SoapOperation updated = input.getOperation(); final SoapOperation soapOperation = this.operationRepository.findOne(input.getOperationId()); soapOperation.setStatus(updated.getStatus()); soapOperation.setForwardedEndpoint(updated.getForwardedEndpoint()); soapOperation.setResponseStrategy(updated.getResponseStrategy()); soapOperation.setSimulateNetworkDelay(updated.getSimulateNetworkDelay()); soapOperation.setNetworkDelay(updated.getNetworkDelay()); soapOperation.setDefaultMockResponseId(updated.getDefaultMockResponseId()); soapOperation.setMockOnFailure(updated.getMockOnFailure()); soapOperation.setIdentifyStrategy(updated.getIdentifyStrategy()); final SoapOperation updatedSoapOperation = this.operationRepository.update(input.getOperationId(), soapOperation); return createServiceResult(UpdateSoapOperationOutput.builder() .operation(updatedSoapOperation) .build()); } }