use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigControllerTestIT method verifyUpdateEndpointTest.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void verifyUpdateEndpointTest() throws Exception {
JiraServerGlobalConfigModel configModel = createConfigModel(UUID.randomUUID());
JiraServerGlobalConfigModel jiraServerGlobalConfigModel = saveConfigModel(configModel);
String urlPath = REQUEST_URL + "/" + jiraServerGlobalConfigModel.getId();
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.put(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
request.content(gson.toJson(jiraServerGlobalConfigModel));
request.contentType(MEDIA_TYPE);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent());
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigControllerTestIT method verifyTestEndpointTest.
@Disabled("Test action not yet implemented")
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void verifyTestEndpointTest() throws Exception {
String urlPath = REQUEST_URL + "/test";
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
UUID uuid = UUID.randomUUID();
JiraServerGlobalConfigModel configModel = createConfigModel(uuid);
request.content(gson.toJson(configModel));
request.contentType(MEDIA_TYPE);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigControllerTestIT method verifyDisablePluginEndpointTest.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void verifyDisablePluginEndpointTest() throws Exception {
String urlPath = REQUEST_URL + "/install-plugin";
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
UUID uuid = UUID.randomUUID();
// Need to just verify the endpoint exists and not actually connect to Jira
JiraServerGlobalConfigModel configModel = createConfigModel(uuid, "badUrl");
request.content(gson.toJson(configModel));
request.contentType(MEDIA_TYPE);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalCrudActionsTest method updateTest.
@Test
void updateTest() throws AlertConfigurationException {
JiraServerGlobalConfigModel jiraServerGlobalConfigModel = createJiraServerGlobalConfigModel(id);
JiraServerGlobalConfigAccessor configAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
Mockito.when(configAccessor.existsConfigurationById(id)).thenReturn(true);
Mockito.when(configAccessor.updateConfiguration(Mockito.eq(id), Mockito.any())).thenReturn(jiraServerGlobalConfigModel);
JiraServerGlobalCrudActions crudActions = new JiraServerGlobalCrudActions(authorizationManager, configAccessor, validator);
ActionResponse<JiraServerGlobalConfigModel> actionResponse = crudActions.update(id, jiraServerGlobalConfigModel);
assertTrue(actionResponse.isSuccessful());
assertTrue(actionResponse.hasContent());
assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
assertModelObfuscated(actionResponse);
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalCrudActionsTest method deleteTest.
@Test
void deleteTest() {
JiraServerGlobalConfigAccessor configAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
Mockito.when(configAccessor.existsConfigurationById(id)).thenReturn(true);
JiraServerGlobalCrudActions crudActions = new JiraServerGlobalCrudActions(authorizationManager, configAccessor, validator);
ActionResponse<JiraServerGlobalConfigModel> actionResponse = crudActions.delete(id);
Mockito.verify(configAccessor).deleteConfiguration(id);
assertTrue(actionResponse.isSuccessful());
assertFalse(actionResponse.hasContent());
assertEquals(HttpStatus.NO_CONTENT, actionResponse.getHttpStatus());
}
Aggregations