@Test public void queryProblems() throws Exception { ResultMatcher ok = MockMvcResultMatchers.status().isOk(); MockHttpServletRequestBuilder content = MockMvcRequestBuilders.post("/queryProblems") .contentType(MediaType.APPLICATION_JSON).content("{\n" + " \"poolId\": \"4468c74d-759e-4d78-8c43-e1c5405f193b\",\n" + " \"token\": \"06e599f3-78db-4c71-b4fa-2b496beab1f6\",\n" + " \"querry\": {\n" + " \"operator\": \"==\",\n" + " \"argument1\":\"problemId\",\n" + " \"argument2\": \"1000222\"\n" + " \n" + " },\n" + " \"random\": false,\n" + " \"deep\": false,\n" + " \"ordering\": {\n" + " \"sorttype\": \"desc\",\n" + " \"field\": \"create_time\"\n" + " },\n" + " \"pagination\": {\n" + " \"page\": 1,\n" + " \"size\": 10,\n" + " \"total\": 0\n" + " }\n" + "}"); this.mockMvc.perform(content) .andExpect(ok) .andDo(MockMvcResultHandlers.print()) .andExpect(jsonPath("$.status").value("ok")); MockHttpServletRequestBuilder content2 = MockMvcRequestBuilders.post("/queryProblems") .contentType(MediaType.APPLICATION_JSON).content("{\n" + " \"poolId\": \"4468c74d-759e-4d78-8c43-e1c5405f193b\",\n" + " \"token\": \"06e599f3-78db-4c71-b4fa-2b496beab1f6\",\n" + " \"querry\": {\n" + " \"operator\": \"or\",\n" + " \"argument1\":{\n" + " \"operator\": \"==\",\n" + " \"argument1\":\"problemId\",\n" + " \"argument2\": \"1000233\"\n" + " },\n" + " \"argument2\": {\n" + " \"operator\": \"contains\",\n" + " \"argument1\":\"tags\",\n" + " \"argument2\": [\"高二\",\"编程\"]\n" + " }\n" + "\n" + " },\n" + " \"random\": false,\n" + " \"deep\": false,\n" + " \"ordering\": {\n" + " \"sorttype\": \"desc\",\n" + " \"field\": \"create_time\"\n" + " },\n" + " \"pagination\": {\n" + " \"page\": 1,\n" + " \"size\": 10,\n" + " \"total\": 0\n" + " }\n" + "}"); this.mockMvc.perform(content2) .andExpect(ok) .andDo(MockMvcResultHandlers.print()) .andExpect(jsonPath("$.status").value("ok")); }
public ResponseEntity<QuerryResult> queryProblems(@ApiParam(value = "") @Valid @RequestBody QuerryInfo body) { String accept = request.getHeader("Accept"); QuerryResult querryResult = new QuerryResult(); try { querryResult = problemService.queryProblem(body); } catch (ParserErrorException e) { e.printStackTrace(); log.error(e.getMessage()); querryResult.setStatus(StatusCode.ERROR); HashMap<String, Object> stringStringHashMap = new HashMap<>(); stringStringHashMap.put("message", e.getMessage()); querryResult.addResultsItem(stringStringHashMap); return new ResponseEntity<>(querryResult, HttpStatus.BAD_REQUEST); } return new ResponseEntity<QuerryResult>(querryResult, HttpStatus.OK); }
QueryProblemsApiController implements QueryProblemsApi { public ResponseEntity<QuerryResult> queryProblems(@ApiParam(value = "") @Valid @RequestBody QuerryInfo body) { String accept = request.getHeader("Accept"); QuerryResult querryResult = new QuerryResult(); try { querryResult = problemService.queryProblem(body); } catch (ParserErrorException e) { e.printStackTrace(); log.error(e.getMessage()); querryResult.setStatus(StatusCode.ERROR); HashMap<String, Object> stringStringHashMap = new HashMap<>(); stringStringHashMap.put("message", e.getMessage()); querryResult.addResultsItem(stringStringHashMap); return new ResponseEntity<>(querryResult, HttpStatus.BAD_REQUEST); } return new ResponseEntity<QuerryResult>(querryResult, HttpStatus.OK); } }
QueryProblemsApiController implements QueryProblemsApi { public ResponseEntity<QuerryResult> queryProblems(@ApiParam(value = "") @Valid @RequestBody QuerryInfo body) { String accept = request.getHeader("Accept"); QuerryResult querryResult = new QuerryResult(); try { querryResult = problemService.queryProblem(body); } catch (ParserErrorException e) { e.printStackTrace(); log.error(e.getMessage()); querryResult.setStatus(StatusCode.ERROR); HashMap<String, Object> stringStringHashMap = new HashMap<>(); stringStringHashMap.put("message", e.getMessage()); querryResult.addResultsItem(stringStringHashMap); return new ResponseEntity<>(querryResult, HttpStatus.BAD_REQUEST); } return new ResponseEntity<QuerryResult>(querryResult, HttpStatus.OK); } @org.springframework.beans.factory.annotation.Autowired  QueryProblemsApiController(ObjectMapper objectMapper, HttpServletRequest request); }
QueryProblemsApiController implements QueryProblemsApi { public ResponseEntity<QuerryResult> queryProblems(@ApiParam(value = "") @Valid @RequestBody QuerryInfo body) { String accept = request.getHeader("Accept"); QuerryResult querryResult = new QuerryResult(); try { querryResult = problemService.queryProblem(body); } catch (ParserErrorException e) { e.printStackTrace(); log.error(e.getMessage()); querryResult.setStatus(StatusCode.ERROR); HashMap<String, Object> stringStringHashMap = new HashMap<>(); stringStringHashMap.put("message", e.getMessage()); querryResult.addResultsItem(stringStringHashMap); return new ResponseEntity<>(querryResult, HttpStatus.BAD_REQUEST); } return new ResponseEntity<QuerryResult>(querryResult, HttpStatus.OK); } @org.springframework.beans.factory.annotation.Autowired  QueryProblemsApiController(ObjectMapper objectMapper, HttpServletRequest request); ResponseEntity<QuerryResult> queryProblems(@ApiParam(value = "") @Valid @RequestBody QuerryInfo body); }
QueryProblemsApiController implements QueryProblemsApi { public ResponseEntity<QuerryResult> queryProblems(@ApiParam(value = "") @Valid @RequestBody QuerryInfo body) { String accept = request.getHeader("Accept"); QuerryResult querryResult = new QuerryResult(); try { querryResult = problemService.queryProblem(body); } catch (ParserErrorException e) { e.printStackTrace(); log.error(e.getMessage()); querryResult.setStatus(StatusCode.ERROR); HashMap<String, Object> stringStringHashMap = new HashMap<>(); stringStringHashMap.put("message", e.getMessage()); querryResult.addResultsItem(stringStringHashMap); return new ResponseEntity<>(querryResult, HttpStatus.BAD_REQUEST); } return new ResponseEntity<QuerryResult>(querryResult, HttpStatus.OK); } @org.springframework.beans.factory.annotation.Autowired  QueryProblemsApiController(ObjectMapper objectMapper, HttpServletRequest request); ResponseEntity<QuerryResult> queryProblems(@ApiParam(value = "") @Valid @RequestBody QuerryInfo body);  }