0
私はこれをテストしなければなりません。spring-mvc-testでパラメータを渡すには?
/** Displays the balance us page. */
@RequestMapping(value = "/profile/balance")
public ModelAndView balance(Principal principal) {
ModelAndView model = new ModelAndView("balance");
String username = principal.getName();
User user = userService.findUserByUsername(username);
model.addObject("moneyEarned", user.getMoneyEarned());
model.addObject("moneySpent", user.getMoneySpent());
return model;
}
私のテストはそのようです。
@Test
public void getProfileBalance() throws Exception {
this.mockMvc.perform(get("/profile/balance")
.andExpect(status().isOk())
.andExpect(view().name("balance"));
}
どのように私はそのプリンシパルインスタンスを渡すことができたのか分かりません。 どうすればいいですか?
を使用することができます – Mattia