use of com.synopsys.integration.alert.common.persistence.model.job.details.JiraJobCustomFieldModel in project hub-alert by blackducksoftware.
the class StaticJobAccessor method convertToDistributionJobModel.
@Deprecated
private DistributionJobModel convertToDistributionJobModel(DistributionJobEntity jobEntity) {
UUID jobId = jobEntity.getJobId();
DistributionJobDetailsModel distributionJobDetailsModel = null;
ChannelKey channelKey = ChannelKeys.getChannelKey(jobEntity.getChannelDescriptorName());
if (ChannelKeys.AZURE_BOARDS.equals(channelKey)) {
AzureBoardsJobDetailsEntity jobDetails = jobEntity.getAzureBoardsJobDetails();
distributionJobDetailsModel = new AzureBoardsJobDetailsModel(jobId, jobDetails.getAddComments(), jobDetails.getProjectNameOrId(), jobDetails.getWorkItemType(), jobDetails.getWorkItemCompletedState(), jobDetails.getWorkItemReopenState());
} else if (ChannelKeys.JIRA_CLOUD.equals(channelKey)) {
JiraCloudJobDetailsEntity jobDetails = jobEntity.getJiraCloudJobDetails();
List<JiraJobCustomFieldModel> customFields = jobDetails.getJobCustomFields().stream().map(entity -> new JiraJobCustomFieldModel(entity.getFieldName(), entity.getFieldValue())).collect(Collectors.toList());
distributionJobDetailsModel = new JiraCloudJobDetailsModel(jobId, jobDetails.getAddComments(), jobDetails.getIssueCreatorEmail(), jobDetails.getProjectNameOrKey(), jobDetails.getIssueType(), jobDetails.getResolveTransition(), jobDetails.getReopenTransition(), customFields, jobDetails.getIssueSummary());
} else if (ChannelKeys.MS_TEAMS.equals(channelKey)) {
MSTeamsJobDetailsEntity jobDetails = jobEntity.getMsTeamsJobDetails();
distributionJobDetailsModel = new MSTeamsJobDetailsModel(jobId, jobDetails.getWebhook());
} else if (ChannelKeys.SLACK.equals(channelKey)) {
SlackJobDetailsEntity slackJobDetails = jobEntity.getSlackJobDetails();
distributionJobDetailsModel = new SlackJobDetailsModel(jobId, slackJobDetails.getWebhook(), slackJobDetails.getChannelName(), slackJobDetails.getChannelUsername());
}
return convertToDistributionJobModel(jobEntity, distributionJobDetailsModel);
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.JiraJobCustomFieldModel in project hub-alert by blackducksoftware.
the class JiraServerExternalConnectionTest method createDistributionDetails.
private JiraServerJobDetailsModel createDistributionDetails() {
UUID uuid = UUID.randomUUID();
List<JiraJobCustomFieldModel> customFields = new ArrayList<>();
// This test requires that the JIRA server has 2 components associated with the project: "component1" and "component2"
customFields.add(new JiraJobCustomFieldModel("Component/s", "component1 component2"));
return new JiraServerJobDetailsModel(uuid, Boolean.parseBoolean(testProperties.getProperty(TestPropertyKey.TEST_JIRA_SERVER_ADD_COMMENTS)), testProperties.getOptionalProperty(TestPropertyKey.TEST_JIRA_SERVER_ISSUE_CREATOR).orElse(null), testProperties.getProperty(TestPropertyKey.TEST_JIRA_SERVER_PROJECT_NAME), testProperties.getProperty(TestPropertyKey.TEST_JIRA_SERVER_ISSUE_TYPE), testProperties.getProperty(TestPropertyKey.TEST_JIRA_SERVER_RESOLVE_TRANSITION), testProperties.getProperty(TestPropertyKey.TEST_JIRA_SERVER_REOPEN_TRANSITION), customFields, "");
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.JiraJobCustomFieldModel in project hub-alert by blackducksoftware.
the class JiraFieldMappingValidator method validateFieldMappings.
public Optional<AlertFieldStatus> validateFieldMappings(String fieldMappingFieldKey, FieldValueModel fieldMappingField) {
List<JiraJobCustomFieldModel> customFields = fieldMappingField.getValues().stream().map(fieldMappingString -> gson.fromJson(fieldMappingString, JiraJobCustomFieldModel.class)).collect(Collectors.toList());
Set<String> fieldNames = new HashSet<>();
List<String> duplicateNameList = new ArrayList<>();
for (JiraJobCustomFieldModel jiraJobCustomFieldModel : customFields) {
String currentFieldName = jiraJobCustomFieldModel.getFieldName();
if (fieldNames.contains(currentFieldName)) {
duplicateNameList.add(currentFieldName);
}
fieldNames.add(currentFieldName);
}
if (!duplicateNameList.isEmpty()) {
String duplicateNames = StringUtils.join(duplicateNameList, ", ");
String errorMessage = String.format("Duplicate field name(s): %s", duplicateNames);
AlertFieldStatus fieldMappingError = AlertFieldStatus.error(fieldMappingFieldKey, errorMessage);
return Optional.of(fieldMappingError);
}
return Optional.empty();
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.JiraJobCustomFieldModel in project hub-alert by blackducksoftware.
the class JiraJobDetailsExtractorTest method extractFieldMappingsTest.
@Test
public void extractFieldMappingsTest() {
String testFieldName = "field.name";
String testFieldValue = "some random value";
JiraJobCustomFieldModel testCustomField = new JiraJobCustomFieldModel(testFieldName, testFieldValue);
ConfigurationFieldModel testFieldModel = ConfigurationFieldModel.create(testFieldName);
String testCustomFieldJson = GSON.toJson(testCustomField);
testFieldModel.setFieldValue(testCustomFieldJson);
JiraJobDetailsExtractor jobDetailsExtractor = createJobDetailsExtractor();
List<JiraJobCustomFieldModel> fieldMappings = jobDetailsExtractor.extractJiraFieldMappings(testFieldName, Map.of(testFieldName, testFieldModel));
assertEquals(1, fieldMappings.size());
JiraJobCustomFieldModel extractedFieldMapping = fieldMappings.get(0);
assertEquals(testCustomField, extractedFieldMapping);
}
Aggregations