@Test
public void action_restart_exception() throws Exception {

    Mockito.doThrow(new IllegalStateException("Restart failed"))
            .when(messageOperationService).restartMessage(eq(42L), eq(true));
    final URIBuilder uriBuilder = createGetUrl(ROOT_URI + "/42/action");
    JsonObject request = createJson()
            .add("type", "RESTART")
            .add("data", createJson()
                    .add("totalRestart", "true"))
            .build();
    // performs POST: /api/messages/42/action
    mockMvc.perform(post(toUrl(uriBuilder))
            .content(request.toString())
            .contentType(MediaType.APPLICATION_JSON)
            .accept(MediaType.APPLICATION_JSON)
            .with(SecurityMockMvcRequestPostProcessors.authentication(mockAuthentication("ADMIN"))))
            .andExpect(status().isConflict())
            .andExpect(jsonPath("result", is("ERROR")))
            ;
    Mockito.verify(messageOperationService, times(1)).restartMessage(eq(42L), eq(true));
}