Search in sources :

Example 1 with JiraServerGlobalConfigModel

use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.

the class JiraServerGlobalCrudActionsTestIT method updateNotFoundTest.

@Test
void updateNotFoundTest() {
    JiraServerGlobalCrudActions crudActions = new JiraServerGlobalCrudActions(authorizationManager, configAccessor, validator);
    JiraServerGlobalConfigModel jiraServerGlobalConfigModel = createBasicJiraModel();
    ActionResponse<JiraServerGlobalConfigModel> actionResponse = crudActions.update(UUID.randomUUID(), jiraServerGlobalConfigModel);
    assertTrue(actionResponse.isError());
    assertFalse(actionResponse.hasContent());
    assertEquals(HttpStatus.NOT_FOUND, actionResponse.getHttpStatus());
}
Also used : JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with JiraServerGlobalConfigModel

use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.

the class JiraServerGlobalCrudActionsTestIT method createDuplicateNameTest.

@Test
void createDuplicateNameTest() {
    JiraServerGlobalCrudActions crudActions = new JiraServerGlobalCrudActions(authorizationManager, configAccessor, validator);
    JiraServerGlobalConfigModel jiraServerGlobalConfigModel = createBasicJiraModel();
    ActionResponse<JiraServerGlobalConfigModel> actionResponse = crudActions.create(jiraServerGlobalConfigModel);
    assertTrue(actionResponse.isSuccessful());
    assertTrue(actionResponse.hasContent());
    assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
    ActionResponse<JiraServerGlobalConfigModel> actionResponseDuplicate = crudActions.create(jiraServerGlobalConfigModel);
    assertTrue(actionResponseDuplicate.isError());
    assertFalse(actionResponseDuplicate.hasContent());
    assertEquals(HttpStatus.BAD_REQUEST, actionResponseDuplicate.getHttpStatus());
}
Also used : JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with JiraServerGlobalConfigModel

use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.

the class JiraServerGlobalCrudActionsTestIT method deleteTest.

@Test
void deleteTest() {
    JiraServerGlobalCrudActions crudActions = new JiraServerGlobalCrudActions(authorizationManager, configAccessor, validator);
    JiraServerGlobalConfigModel jiraServerGlobalConfigModel = createBasicJiraModel();
    ActionResponse<JiraServerGlobalConfigModel> createActionResponse = crudActions.create(jiraServerGlobalConfigModel);
    assertTrue(createActionResponse.isSuccessful());
    assertTrue(createActionResponse.getContent().isPresent());
    UUID uuid = UUID.fromString(createActionResponse.getContent().get().getId());
    ActionResponse<JiraServerGlobalConfigModel> actionResponse = crudActions.delete(uuid);
    assertTrue(actionResponse.isSuccessful());
    assertFalse(actionResponse.hasContent());
    assertEquals(HttpStatus.NO_CONTENT, actionResponse.getHttpStatus());
    ActionResponse<JiraServerGlobalConfigModel> getActionResponse = crudActions.getOne(uuid);
    assertTrue(getActionResponse.isError());
    assertEquals(HttpStatus.NOT_FOUND, getActionResponse.getHttpStatus());
}
Also used : JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) UUID(java.util.UUID) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with JiraServerGlobalConfigModel

use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.

the class JiraServerGlobalConfigControllerTestIT method verifyValidateEndpointTest.

@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void verifyValidateEndpointTest() throws Exception {
    String urlPath = REQUEST_URL + "/validate";
    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());
}
Also used : MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) UUID(java.util.UUID) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 5 with JiraServerGlobalConfigModel

use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.

the class JiraServerGlobalConfigControllerTestIT method verifyDeleteEndpointTest.

@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void verifyDeleteEndpointTest() throws Exception {
    JiraServerGlobalConfigModel jiraServerGlobalConfigModel = saveConfigModel(createConfigModel(UUID.randomUUID()));
    String urlPath = REQUEST_URL + "/" + jiraServerGlobalConfigModel.getId();
    MockHttpServletRequestBuilder request = MockMvcRequestBuilders.delete(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
    mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent());
}
Also used : JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

JiraServerGlobalConfigModel (com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel)44 Test (org.junit.jupiter.api.Test)40 UUID (java.util.UUID)17 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)14 JiraServerConfigurationEntity (com.synopsys.integration.alert.channel.jira.server.database.configuration.JiraServerConfigurationEntity)10 WithMockUser (org.springframework.security.test.context.support.WithMockUser)7 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)7 JiraServerGlobalConfigAccessor (com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor)6 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)5 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)5 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)4 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)4 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)3 EnvironmentProcessingResult (com.synopsys.integration.alert.environment.EnvironmentProcessingResult)2 PageImpl (org.springframework.data.domain.PageImpl)2 PageRequest (org.springframework.data.domain.PageRequest)2 JiraServerEnvironmentVariableHandlerFactory (com.synopsys.integration.alert.channel.jira.server.environment.JiraServerEnvironmentVariableHandlerFactory)1 JiraServerGlobalConfigurationValidator (com.synopsys.integration.alert.channel.jira.server.validator.JiraServerGlobalConfigurationValidator)1 IssueTrackerException (com.synopsys.integration.alert.common.channel.issuetracker.exception.IssueTrackerException)1 ConfigurationTestResult (com.synopsys.integration.alert.common.message.model.ConfigurationTestResult)1