use of org.springframework.test.web.server.MvcResult in project motech by motech.
the class BootstrapControllerTest method shouldAddErrorOnSaveAndReturnTheSameBootstrapStartupView.
@Test
public void shouldAddErrorOnSaveAndReturnTheSameBootstrapStartupView() throws Exception {
when(messageBrokerTestService.pingBroker("tcp://localhost:61616")).thenReturn(true);
when(localeResolver.resolveLocale(any(HttpServletRequest.class))).thenReturn(Locale.ENGLISH);
when(messageSource.getMessage("server.error.bootstrap.save", null, Locale.ENGLISH)).thenReturn("errMsg");
doThrow(new MotechConfigurationException("Test Exception")).when(OsgiListener.class);
OsgiListener.saveBootstrapConfig(any(BootstrapConfig.class));
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/bootstrap/").param("sqlUrl", "jdbc:mysql://www.someurl.com:3306/").param("sqlDriver", "com.mysql.jdbc.Driver").param("sqlUsername", "some_username").param("sqlPassword", "some_password").param("configSource", "UI").param("queueUrl", "tcp://localhost:61616")).andExpect(MockMvcResultMatchers.status().isOk()).andReturn();
ModelAndView actualView = mvcResult.getModelAndView();
assertThat(actualView.getViewName(), is("bootstrapconfig"));
assertThat((String) ((List) actualView.getModel().get("errors")).get(0), is("errMsg"));
}
Aggregations