use of com.synopsys.integration.alert.api.channel.jira.distribution.custom.JiraCustomFieldResolver in project hub-alert by blackducksoftware.
the class JiraErrorMessageUtilityTest method verifyReporterRestExceptionTest.
@Test
void verifyReporterRestExceptionTest() throws IntegrationException, IOException {
JiraCustomFieldResolver jiraCustomFieldResolver = new JiraCustomFieldResolver(() -> List.of());
JiraErrorMessageUtility jiraErrorMessageUtility = new JiraErrorMessageUtility(new Gson(), jiraCustomFieldResolver);
IntegrationRestException integrationRestException = createRestException(JsonTestResource.REPORTER_ERROR);
String issueCreatorKey = "issueCreatorFieldKey";
String issueCreatorEmail = "issueCreatorEmail";
AlertException alertException = jiraErrorMessageUtility.improveRestException(integrationRestException, issueCreatorKey, issueCreatorEmail);
assertTrue(alertException instanceof AlertFieldException);
AlertFieldException alertFieldException = (AlertFieldException) alertException;
List<AlertFieldStatus> fieldErrors = alertFieldException.getFieldErrors();
assertEquals(1, fieldErrors.size());
AlertFieldStatus alertFieldStatus = fieldErrors.get(0);
assertEquals(issueCreatorKey, alertFieldStatus.getFieldName());
assertEquals(FieldStatusSeverity.ERROR, alertFieldStatus.getSeverity());
String fieldMessage = alertFieldStatus.getFieldMessage();
assertTrue(fieldMessage.contains(issueCreatorEmail));
assertTrue(fieldMessage.contains("It'sa me, Mario"));
assertFalse(fieldMessage.contains(" | Details: "));
}
use of com.synopsys.integration.alert.api.channel.jira.distribution.custom.JiraCustomFieldResolver in project hub-alert by blackducksoftware.
the class JiraErrorMessageUtilityTest method verifyFieldErrorsRestExceptionTest.
@Test
void verifyFieldErrorsRestExceptionTest() throws IntegrationException, IOException {
String customFieldKey = "customfield_1";
String customFieldName = "Custom Field 1 Name";
String nonExistentCustomName = "Field 33 Name";
Map<String, String> fieldIdsToNames = Map.of("customfield_6", "lol", "customfield_33", nonExistentCustomName, customFieldKey, customFieldName);
JiraCustomFieldResolver jiraCustomFieldResolver = new JiraCustomFieldResolver(() -> createCustomFieldResponseModels(fieldIdsToNames));
JiraErrorMessageUtility jiraErrorMessageUtility = new JiraErrorMessageUtility(new Gson(), jiraCustomFieldResolver);
IntegrationRestException integrationRestException = createRestException(JsonTestResource.ERROR_MESSAGES_ERROR);
String issueCreatorKey = "issueCreatorFieldKey";
String issueCreatorEmail = "issueCreatorEmail";
AlertException alertException = jiraErrorMessageUtility.improveRestException(integrationRestException, issueCreatorKey, issueCreatorEmail);
String message = alertException.getMessage();
assertTrue(message.contains(customFieldName));
assertTrue(message.contains("This field should have had another value"));
assertTrue(message.contains(customFieldKey));
assertFalse(message.contains(nonExistentCustomName));
}
Aggregations