@PreAuthorize("hasAuthority('MODIFIER') or hasAuthority('ADMIN')") @RequestMapping(value = "/{restProjectId}/application/{restApplicationId}/resource/{restResourceId}/method/{restMethodId}/update", method = RequestMethod.GET) public ModelAndView defaultPage(@PathVariable final String restProjectId, @PathVariable final String restApplicationId, @PathVariable final String restResourceId, @PathVariable final String restMethodId) { final ReadRestMethodOutput output = serviceProcessor.process(ReadRestMethodInput.builder() .restProjectId(restProjectId) .restApplicationId(restApplicationId) .restResourceId(restResourceId) .restMethodId(restMethodId) .build()); final ModelAndView model = createPartialModelAndView(PAGE); model.addObject(REST_METHOD, output.getRestMethod()); model.addObject(REST_PROJECT_ID, restProjectId); model.addObject(REST_APPLICATION_ID, restApplicationId); model.addObject(REST_RESOURCE_ID, restResourceId); model.addObject(REST_METHOD_ID, restResourceId); model.addObject(REST_METHOD_TYPES, HttpMethod.values()); model.addObject(REST_METHOD_STATUSES, getRestMethodStatuses()); model.addObject(REST_RESPONSE_STRATEGIES, RestResponseStrategy.values()); return model; }
if(mockResponses.isEmpty()){ throw new RestException("No mocked response created for operation " + restMethod.getName()); } else if(restMethod.getResponseStrategy().equals(RestResponseStrategy.RANDOM)){ final Integer responseIndex = RANDOM.nextInt(mockResponses.size()); mockResponse = mockResponses.get(responseIndex); } else if(restMethod.getResponseStrategy().equals(RestResponseStrategy.SEQUENCE)){ Integer currentSequenceNumber = restMethod.getCurrentResponseSequenceIndex(); if(currentSequenceNumber >= mockResponses.size()){ .currentRestMockResponseSequenceIndex(currentSequenceNumber + 1) .build()); } else if(restMethod.getResponseStrategy().equals(RestResponseStrategy.QUERY_MATCH)){ mockResponse = mockResponses.stream() .filter(tmp -> RestParameterQueryValidator.validate(tmp.getParameterQueries(), pathParameters)) mockResponse = this.getDefaultMockResponse(restMethod, mockResponses).orElse(null); } else if(restMethod.getResponseStrategy().equals(RestResponseStrategy.XPATH)){ for (RestMockResponse testedMockResponse : mockResponses) { for(RestXPathExpression xPathExpression : testedMockResponse.getXpathExpressions()){ } else if(restMethod.getResponseStrategy().equals(RestResponseStrategy.JSON_PATH)){ for (RestMockResponse testedMockResponse : mockResponses) { for(RestJsonPathExpression jsonPathExpression : testedMockResponse.getJsonPathExpressions()){