0
我休息控制器像波紋管:Junit的傳遞多個參數來休息服務
@RequestMapping(value = "/create", method = RequestMethod.POST)
public
@ResponseBody
GlobalResponse createDeal(@RequestBody Deal deal,@RequestBody Owner owner) {
// code here
}
我使用JUnit和的Mockito爲我的測試:
@Test
public void createDeal() throws Exception{
this.mockMvc.perform(post("/v1/Deal/create").content("\"deal\":{\"dealNumber\":\"DA001\"},\"owner\":{\"id\":1}").contentType(MediaType.APPLICATION_JSON)).andDo(print());
}
我不能過去多個參數控制服務,我該如何避免這種情況?
爲什麼不直接提供'Deal'和'Owner'實例來測試'createDeal(..)'方法? – isah
我沒有找到你,你能解釋一下嗎? –