final String projectId = this.portRepository.getProjectId(portId); final SearchResult searchResult = new SearchResult(); searchResult.setTitle(mockResponse.getName()); searchResult.setLink(SOAP + SLASH + PROJECT + SLASH + projectId + SLASH + PORT + SLASH + portId + SLASH + OPERATION + SLASH + mockResponse.getOperationId() +
SoapMockResponse soapMockResponse = readSoapMockResponseOutput.getMockResponse(); soapMockResponse.setId(null); soapMockResponse.setName(String.format("%s %s", copyOfLabel, soapMockResponse.getName())); serviceProcessor.process(CreateSoapMockResponseInput.builder() .projectId(soapProjectId)
for(SoapMockResponse mockResponse : mockResponses){ if(mockResponse.getId().equals(soapOperation.getDefaultMockResponseId())){ soapOperation.setDefaultResponseName(mockResponse.getName()); defaultXpathMockResponseFound = true; break;
@Test public void testSearch() { soapMockResponseMongoRepository.save(createSoapMockResponse("aaXYZbb")); soapMockResponseMongoRepository.save(createSoapMockResponse("aaXYZ")); soapMockResponseMongoRepository.save(createSoapMockResponse("aaxyz")); soapMockResponseMongoRepository.save(createSoapMockResponse("xyz")); soapMockResponseMongoRepository.save(createSoapMockResponse("aaefg")); SearchQuery query = new SearchQuery(); query.setQuery("xyz"); List<SoapMockResponse> searchResults = soapMockResponseMongoRepository.search(query); assertThat(searchResults).hasSize(4); assertThat(searchResults).noneMatch(it -> it.getName().equals("aaefg")); }
response.setMockResponseName(mockResponse.getName()); response.setHttpHeaders(mockResponse.getHttpHeaders()); response.setHttpStatusCode(mockResponse.getHttpStatusCode());
Mockito.verify(mockResponseRepository, Mockito.times(1)).update(mockResponse.getId(), mockResponse); Assert.assertEquals(mockResponse.getId(), returnedSoapMockResponse.getId()); Assert.assertEquals(mockResponse.getName(), returnedSoapMockResponse.getName()); Assert.assertEquals(mockResponse.getStatus(), returnedSoapMockResponse.getStatus()); Assert.assertEquals(mockResponse.getBody(), returnedSoapMockResponse.getBody());
@Test public void testProcessWithDefaultXPathResponse(){ final SoapOperation operation = SoapOperationGenerator.generateSoapOperation(); final SoapMockResponse mockResponse = SoapMockResponseGenerator.generateSoapMockResponse(); final String projectId = "SOAP PROJECT"; final String portId = "SOAP PORT"; operation.setDefaultMockResponseId(mockResponse.getId()); final ReadSoapOperationInput input = ReadSoapOperationInput.builder() .projectId(projectId) .portId(portId) .operationId(operation.getId()) .build(); final ServiceTask<ReadSoapOperationInput> serviceTask = new ServiceTask<ReadSoapOperationInput>(input); Mockito.when(operationRepository.findOne(operation.getId())).thenReturn(operation); Mockito.when(mockResponseRepository.findWithOperationId(operation.getId())).thenReturn(Arrays.asList(mockResponse)); final ServiceResult<ReadSoapOperationOutput> result = service.process(serviceTask); Mockito.verify(operationRepository, Mockito.times(1)).findOne(operation.getId()); Mockito.verify(mockResponseRepository, Mockito.times(1)).findWithOperationId(operation.getId()); Assert.assertNotNull(result.getOutput()); Assert.assertEquals(operation, result.getOutput().getOperation()); Assert.assertEquals(mockResponse.getName(), operation.getDefaultResponseName()); }
/** * 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<UpdateSoapMockResponseOutput> process(final ServiceTask<UpdateSoapMockResponseInput> serviceTask) { final UpdateSoapMockResponseInput input = serviceTask.getInput(); final SoapMockResponse updated = input.getMockResponse(); final SoapMockResponse mockResponse = this.mockResponseRepository.findOne(input.getMockResponseId()); mockResponse.setName(updated.getName()); mockResponse.setBody(updated.getBody()); mockResponse.setHttpStatusCode(updated.getHttpStatusCode()); mockResponse.setStatus(updated.getStatus()); mockResponse.setHttpHeaders(updated.getHttpHeaders()); mockResponse.setUsingExpressions(updated.isUsingExpressions()); mockResponse.setXpathExpressions(updated.getXpathExpressions()); final SoapMockResponse updatedSoapMockResponse = mockResponseRepository.update(input.getMockResponseId(), mockResponse); return createServiceResult(UpdateSoapMockResponseOutput.builder() .mockResponse(updatedSoapMockResponse) .build()); } }