MockMvc adds quotes at the ends of string when passed in param()
in request builder like following
// initialization of mockMvc
mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
ObjectNode tweets = ((ObjectNode) result.getRequest().getAttribute("tweets"));
String query = tweets.get("query").toString();
String nextToken = tweets.get("meta").get("next_token").toString();
mockMvc.perform(MockMvcRequestBuilders.post("/next")
.param("query", query)
.param("next_token", nextToken)
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.isError", is("N")))
.andReturn();
if query is "#GoGreen"
and next_token is "wefw234234ewf234"
are received in controller is
query = "\"#GoGreen\""
and next_token = "\"wefw234234ewf234\""
@PostMapping("/next") @ResponseBody
public ResponseEntity<Object> nextPageTrendingTweets(@RequestParam("query") String query,
@RequestParam("next_token") String nextToken)
Maybe I'm missing something when initializing mockMvc
. I searched about this problem but couldn't find any solution.