use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalTestActionTest method testPermissionForbidden.
@Test
void testPermissionForbidden() {
AuthorizationManager authorizationManager = createAuthorizationManager(0);
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerTestActionFactory jiraServerTestActionFactory = Mockito.mock(JiraServerTestActionFactory.class);
JiraServerGlobalTestAction jiraServerGlobalTestAction = new JiraServerGlobalTestAction(authorizationManager, validator, jiraServerTestActionFactory);
ActionResponse<ValidationResponseModel> validationResponseModel = jiraServerGlobalTestAction.testWithPermissionCheck(jiraServerGlobalConfigModel);
assertTrue(validationResponseModel.isError());
assertEquals(HttpStatus.FORBIDDEN, validationResponseModel.getHttpStatus());
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JiraServerInstallPluginAction method createBadRequestIntegrationException.
private ActionResponse<ValidationResponseModel> createBadRequestIntegrationException(IntegrationException error) {
logger.error("There was an issue connecting to Jira server", error);
ValidationResponseModel validationResponseModel = ValidationResponseModel.generalError("The following error occurred when connecting to Jira server: " + error.getMessage());
return new ActionResponse<>(HttpStatus.BAD_REQUEST, validationResponseModel);
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationValidatorTest method verifyPasswordIsSavedAndMissingFromModel.
@Test
void verifyPasswordIsSavedAndMissingFromModel() {
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerGlobalConfigModel model = new JiraServerGlobalConfigModel(ID, NAME, CREATED_AT, LAST_UPDATED, URL, USER_NAME, null, Boolean.TRUE, Boolean.FALSE);
ValidationResponseModel validationResponseModel = validator.validate(model);
Collection<AlertFieldStatus> alertFieldStatuses = validationResponseModel.getErrors().values();
assertEquals(0, alertFieldStatuses.size(), "There were errors in the configuration when none were expected.");
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationValidatorTest method verifyEmptyConfig.
@Test
void verifyEmptyConfig() {
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerGlobalConfigModel model = new JiraServerGlobalConfigModel();
ValidationResponseModel validationResponseModel = validator.validate(model);
Collection<AlertFieldStatus> alertFieldStatuses = validationResponseModel.getErrors().values();
assertEquals(4, alertFieldStatuses.size(), "There were errors in the configuration when none were expected.");
for (AlertFieldStatus status : alertFieldStatuses) {
assertEquals(ConfigurationFieldValidator.REQUIRED_FIELD_MISSING_MESSAGE, status.getFieldMessage(), "Validation had unexpected field message.");
}
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationValidatorTest method verifyMalformedUrl.
@Test
void verifyMalformedUrl() {
String badUrl = "notAValidUrl";
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerGlobalConfigModel model = new JiraServerGlobalConfigModel(ID, NAME, CREATED_AT, LAST_UPDATED, badUrl, USER_NAME, PASSWORD, Boolean.FALSE, Boolean.FALSE);
ValidationResponseModel validationResponseModel = validator.validate(model);
Collection<AlertFieldStatus> alertFieldStatuses = validationResponseModel.getErrors().values();
assertEquals(1, alertFieldStatuses.size(), "There were errors in the configuration when none were expected.");
for (AlertFieldStatus status : alertFieldStatuses) {
assertEquals("url", status.getFieldName(), "Validation reported an error for an unexpected field.");
}
}
Aggregations