use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class GlobalSchedulingConfigControllerTestIT method testRunAccumulator.
@Test
@WithMockUser(roles = "ADMIN")
public void testRunAccumulator() throws Exception {
globalEntityRepository.deleteAll();
final String accumulatorRunRestUrl = restUrl + "/accumulator/run";
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(accumulatorRunRestUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class ControllerTest method testDeleteConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testDeleteConfig() throws Exception {
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.delete(restUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isMethodNotAllowed());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class ControllerTest method testPutConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testPutConfig() throws Exception {
entityRepository.deleteAll();
final E savedEntity = entityRepository.save(entity);
final CommonDistributionConfigEntity commonEntity = commonDistributionRepository.save(distributionMockUtil.createEntity());
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.put(restUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
restModel.setDistributionConfigId(String.valueOf(savedEntity.getId()));
restModel.setId(String.valueOf(commonEntity.getId()));
request.content(gson.toJson(restModel));
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isAccepted());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class ControllerTest method testPostConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testPostConfig() throws Exception {
entityRepository.deleteAll();
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(restUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
request.content(gson.toJson(restModel));
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isCreated());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class ControllerTest method testGetConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testGetConfig() throws Exception {
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.get(restUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
Aggregations