use of com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor 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.database.accessor.JiraServerGlobalConfigAccessor 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());
}
use of com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor in project hub-alert by blackducksoftware.
the class JiraServerGlobalCrudActionsTest method createTest.
@Test
void createTest() throws AlertConfigurationException {
JiraServerGlobalConfigModel jiraServerGlobalConfigModel = createJiraServerGlobalConfigModel(id);
JiraServerGlobalConfigAccessor configAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
Mockito.when(configAccessor.createConfiguration(Mockito.any())).thenReturn(jiraServerGlobalConfigModel);
JiraServerGlobalCrudActions crudActions = new JiraServerGlobalCrudActions(authorizationManager, configAccessor, validator);
ActionResponse<JiraServerGlobalConfigModel> actionResponse = crudActions.create(jiraServerGlobalConfigModel);
assertTrue(actionResponse.isSuccessful());
assertTrue(actionResponse.hasContent());
assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
assertModelObfuscated(actionResponse);
}
use of com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor in project hub-alert by blackducksoftware.
the class JiraServerGlobalCrudActionsTest method getPagedTest.
@Test
void getPagedTest() {
JiraServerGlobalConfigModel jiraServerGlobalConfigModel = createJiraServerGlobalConfigModel(id);
AlertPagedModel<JiraServerGlobalConfigModel> alertPagedModel = new AlertPagedModel<>(1, AlertPagedModel.DEFAULT_PAGE_NUMBER, AlertPagedModel.DEFAULT_PAGE_SIZE, List.of(jiraServerGlobalConfigModel));
JiraServerGlobalConfigAccessor configAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
Mockito.when(configAccessor.getConfigurationPage(AlertPagedModel.DEFAULT_PAGE_NUMBER, AlertPagedModel.DEFAULT_PAGE_SIZE)).thenReturn(alertPagedModel);
JiraServerGlobalCrudActions crudActions = new JiraServerGlobalCrudActions(authorizationManager, configAccessor, validator);
ActionResponse<AlertPagedModel<JiraServerGlobalConfigModel>> actionResponse = crudActions.getPaged(AlertPagedModel.DEFAULT_PAGE_NUMBER, AlertPagedModel.DEFAULT_PAGE_SIZE);
assertTrue(actionResponse.isSuccessful());
assertTrue(actionResponse.hasContent());
assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
assertTrue(actionResponse.getContent().isPresent());
AlertPagedModel<JiraServerGlobalConfigModel> pagedModel = actionResponse.getContent().get();
assertEquals(1, pagedModel.getModels().size());
assertModelObfuscated(pagedModel.getModels().get(0));
}
use of com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor in project hub-alert by blackducksoftware.
the class JiraServerGlobalCrudActionsTest method createDuplicateTest.
@Test
void createDuplicateTest() throws AlertConfigurationException {
JiraServerGlobalConfigModel jiraServerGlobalConfigModel = createJiraServerGlobalConfigModel(id);
JiraServerGlobalConfigAccessor configAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
Mockito.when(configAccessor.existsConfigurationByName(Mockito.any())).thenReturn(true);
Mockito.when(configAccessor.createConfiguration(Mockito.any())).thenReturn(jiraServerGlobalConfigModel);
JiraServerGlobalCrudActions crudActions = new JiraServerGlobalCrudActions(authorizationManager, configAccessor, validator);
ActionResponse<JiraServerGlobalConfigModel> actionResponse = crudActions.create(jiraServerGlobalConfigModel);
assertTrue(actionResponse.isError());
assertFalse(actionResponse.hasContent());
assertEquals(HttpStatus.BAD_REQUEST, actionResponse.getHttpStatus());
}
Aggregations