Existe uma maneira de usar as asserções do AssertJ com o Spring MVC Test?
Uso o AssertJ há algum tempo em meus projetos. Recentemente, comecei a usar o Spring MVC Test para testar os controladores Spring MVC.
Mas não estou aprendendo como usar o AssertJ com ele. Todos os exemplos que vejo online usam Hamcrest com Spring MVC Test.
Abaixo está um exemplo usando a API Hamcrest.
mockMvc
.perform(get("/user?operation=userList"))
.andExpect(status().isOk())
.andExpect(model().attribute(UserController.MODEL_ATTRIBUTE_USER_LIST, userList))
.andExpect(view().name(UserController.VIEW_USER_LIST))
.andExpect(model().attribute(UserController.MODEL_ATTRIBUTE_USER_LIST, hasSize(2)))
.andExpect(model().attribute(UserController.MODEL_ATTRIBUTE_USER_LIST, hasItem(
allOf(
hasProperty("id", is(1L)),
hasProperty("description", is("Lorem ipsum")),
hasProperty("title", is("Foo"))
)
)))
.andExpect(model().attribute(UserController.MODEL_ATTRIBUTE_USER_LIST, hasItem(
allOf(
hasProperty("id", is(2L)),
hasProperty("description", is("Lorem ipsum")),
hasProperty("title", is("Bar"))
)
)));