use of com.synopsys.integration.alert.common.persistence.model.job.details.AzureBoardsJobDetailsModel 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.AzureBoardsJobDetailsModel in project hub-alert by blackducksoftware.
the class StaticJobAccessorTestIT method verifyAzureSavesTest.
@Test
@Transactional
public void verifyAzureSavesTest() {
AzureBoardsJobDetailsModel azureBoardsJobDetailsModel = new AzureBoardsJobDetailsModel(UUID.randomUUID(), true, "projectNameOrId", "workItemType", "workItemCompletedState", "workItemReopenState");
DistributionJobRequestModel jobRequestModel = createJobRequestModel(azureBoardsJobDetailsModel, new AzureBoardsChannelKey());
createAndAssertJob(jobRequestModel);
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.AzureBoardsJobDetailsModel in project hub-alert by blackducksoftware.
the class StaticJobAccessorTest method createAzureBoardsJobTest.
@Test
void createAzureBoardsJobTest() {
UUID jobId = UUID.randomUUID();
AzureBoardsJobDetailsModel azureBoardsJobDetailsModel = new AzureBoardsJobDetailsModel(jobId, false, null, null, null, null);
DistributionJobRequestModel distributionJobRequestModel = createDistributionJobEntity(ChannelKeys.AZURE_BOARDS.getUniversalKey(), azureBoardsJobDetailsModel);
AzureBoardsJobDetailsEntity azureBoardsJobDetailsEntity = new AzureBoardsJobDetailsEntity(null, false, null, null, null, null);
DistributionJobEntity distributionJobEntity = createDistributionJobEntity(jobId, distributionJobRequestModel);
distributionJobEntity.setAzureBoardsJobDetails(azureBoardsJobDetailsEntity);
BlackDuckJobDetailsEntity blackDuckJobDetailsEntity = createBlackDuckJobDetailsEntity(jobId, distributionJobRequestModel);
Mockito.when(azureBoardsJobDetailsAccessor.saveAzureBoardsJobDetails(Mockito.any(), Mockito.any())).thenReturn(azureBoardsJobDetailsEntity);
Mockito.when(blackDuckJobDetailsAccessor.saveBlackDuckJobDetails(Mockito.any(), Mockito.any())).thenReturn(blackDuckJobDetailsEntity);
Mockito.when(distributionJobRepository.save(Mockito.any())).thenReturn(distributionJobEntity);
DistributionJobModel createdJob = jobAccessor.createJob(distributionJobRequestModel);
assertEquals(jobId, createdJob.getJobId());
assertEquals(jobName, createdJob.getName());
}
Aggregations