use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class ControllerTest method testTestConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testTestConfig() throws Exception {
entityRepository.deleteAll();
final E savedEntity = entityRepository.save(entity);
final CommonDistributionConfigEntity commonEntity = commonDistributionRepository.save(distributionMockUtil.createEntity());
final String testRestUrl = restUrl + "/test";
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(testRestUrl).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().isOk());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class GlobalControllerTest method testDeleteConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testDeleteConfig() throws Exception {
globalEntityRepository.deleteAll();
final GE savedEntity = globalEntityRepository.save(entity);
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.delete(restUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
restModel.setId(String.valueOf(savedEntity.getId()));
request.content(gson.toJson(restModel));
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isAccepted());
}
Aggregations