response.setBody(body); response.setMockResponseName(mockResponse.getName()); response.setHttpStatusCode(mockResponse.getHttpStatusCode()); response.setHttpHeaders(mockResponse.getHttpHeaders()); response.setContentEncodings(mockResponse.getContentEncodings());
Assert.assertEquals(Integer.valueOf(200), response200Xml.getHttpStatusCode()); Assert.assertEquals(RestMockResponseStatus.ENABLED, response200Xml.getStatus()); Assert.assertTrue(response200Xml.isUsingExpressions()); Assert.assertEquals(Integer.valueOf(200), response200Json.getHttpStatusCode()); Assert.assertEquals(RestMockResponseStatus.ENABLED, response200Json.getStatus()); Assert.assertTrue(response200Json.isUsingExpressions()); Assert.assertEquals(Integer.valueOf(400), invalidMockResponse.getHttpStatusCode()); Assert.assertEquals(RestMockResponseStatus.DISABLED, invalidMockResponse.getStatus()); Assert.assertTrue(invalidMockResponse.isUsingExpressions()); Assert.assertEquals(Integer.valueOf(404), notFoundResponse.getHttpStatusCode()); Assert.assertEquals(RestMockResponseStatus.DISABLED, notFoundResponse.getStatus()); Assert.assertTrue(notFoundResponse.isUsingExpressions()); Assert.assertEquals(Integer.valueOf(400), invalidMockResponse.getHttpStatusCode()); Assert.assertEquals(RestMockResponseStatus.DISABLED, invalidMockResponse.getStatus()); Assert.assertTrue(invalidMockResponse.isUsingExpressions()); Assert.assertEquals(Integer.valueOf(200), response200Xml.getHttpStatusCode()); Assert.assertEquals(RestMockResponseStatus.ENABLED, response200Xml.getStatus()); Assert.assertTrue(response200Xml.isUsingExpressions()); Assert.assertEquals(Integer.valueOf(200), response200Json.getHttpStatusCode()); Assert.assertEquals(RestMockResponseStatus.ENABLED, response200Json.getStatus()); Assert.assertTrue(response200Json.isUsingExpressions()); Assert.assertEquals(Integer.valueOf(400), invalidMockResponse.getHttpStatusCode());
/** * 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<UpdateRestMockResponseOutput> process(final ServiceTask<UpdateRestMockResponseInput> serviceTask) { final UpdateRestMockResponseInput input = serviceTask.getInput(); final RestMockResponse existing = this.mockResponseRepository.findOne(input.getRestMockResponseId()); final RestMockResponse updatedRestMockResponse = input.getRestMockResponse(); existing.setName(updatedRestMockResponse.getName()); existing.setBody(updatedRestMockResponse.getBody()); existing.setHttpStatusCode(updatedRestMockResponse.getHttpStatusCode()); existing.setHttpHeaders(updatedRestMockResponse.getHttpHeaders()); existing.setStatus(updatedRestMockResponse.getStatus()); existing.setUsingExpressions(updatedRestMockResponse.isUsingExpressions()); existing.setParameterQueries(updatedRestMockResponse.getParameterQueries()); existing.setXpathExpressions(updatedRestMockResponse.getXpathExpressions()); existing.setJsonPathExpressions(updatedRestMockResponse.getJsonPathExpressions()); this.mockResponseRepository.update(input.getRestMockResponseId(), existing); return createServiceResult(UpdateRestMockResponseOutput.builder() .updatedRestMockResponse(updatedRestMockResponse) .build()); } }
RestMockResponse restMockResponse = restMethod.getMockResponses().get(0); Assert.assertEquals(AUTO_GENERATED_MOCK_RESPONSE_DEFAULT_NAME, restMockResponse.getName()); Assert.assertEquals(Integer.valueOf(DEFAULT_RESPONSE_CODE), restMockResponse.getHttpStatusCode()); Assert.assertEquals(RestMockResponseStatus.ENABLED, restMockResponse.getStatus()); Assert.assertTrue(restMockResponse.getContentEncodings().isEmpty());