String body = mockResponse.getBody(); if(mockResponse.isUsingExpressions()){ final ExpressionArgumentMap pathParametersArgument = new ExpressionArgumentMap();
Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<Mock><name>${RANDOM_STRING()}</name><id>${RANDOM_LONG()}</id><createdBy>${RANDOM_STRING()}</createdBy>" + "<mockStatus>${RANDOM_INTEGER()}</mockStatus></Mock>", response200Xml.getBody()); Assert.assertEquals("{\"name\":\"${RANDOM_STRING()}\",\"id\":\"${RANDOM_LONG()}\"," + "\"createdBy\":\"${RANDOM_STRING()}\",\"mockStatus\":\"${RANDOM_INTEGER()}\"}", response200Json.getBody()); Assert.assertNull(invalidMockResponse.getBody()); Assert.assertNull(notFoundResponse.getBody()); Assert.assertNull(invalidMockResponse.getBody()); "<Mock><name>${RANDOM_STRING()}" + "</name><id>${RANDOM_LONG()}</id><createdBy>${RANDOM_STRING()}" + "</createdBy><mockStatus>${RANDOM_INTEGER()}</mockStatus></Mock>", response200Xml.getBody()); Assert.assertEquals("{\"name\":\"${RANDOM_STRING()}\",\"id\":\"${RANDOM_LONG()}\",\"createdBy\":\"" + "${RANDOM_STRING()}\",\"mockStatus\":\"${RANDOM_INTEGER()}\"}", response200Json.getBody()); Assert.assertNull(invalidMockResponse.getBody()); Assert.assertNull(notFoundResponse.getBody()); Assert.assertNull(invalidMockResponse.getBody()); Assert.assertNull(notFoundResponse.getBody());
/** * 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()); } }
Assert.assertNull(restMockResponse.getBody());