use of com.synopsys.integration.alert.common.persistence.model.job.details.JiraServerJobDetailsModel in project hub-alert by blackducksoftware.
the class StaticJobAccessorTestIT method verifyJiraServerSavesTest.
@Test
public void verifyJiraServerSavesTest() {
JiraServerJobDetailsModel jiraServerJobDetailsModel = new JiraServerJobDetailsModel(UUID.randomUUID(), true, "issueCreatorUsername", "projectNameOrKey", "issueType", "resolveTransition", "reopenTransition", List.of(), "issueSummary");
DistributionJobRequestModel jobRequestModel = createJobRequestModel(jiraServerJobDetailsModel, new JiraServerChannelKey());
createAndAssertJob(jobRequestModel);
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.JiraServerJobDetailsModel in project hub-alert by blackducksoftware.
the class StaticJobAccessorTest method createJiraServerJobTest.
@Test
void createJiraServerJobTest() {
UUID jobId = UUID.randomUUID();
JiraServerJobDetailsModel jiraServerJobDetailsModel = new JiraServerJobDetailsModel(jobId, false, null, null, null, null, null, List.of(), "issueSummary");
DistributionJobRequestModel distributionJobRequestModel = createDistributionJobEntity(ChannelKeys.JIRA_SERVER.getUniversalKey(), jiraServerJobDetailsModel);
JiraServerJobDetailsEntity jiraServerJobDetailsEntity = new JiraServerJobDetailsEntity(null, false, null, null, null, null, null, null);
jiraServerJobDetailsEntity.setJobCustomFields(List.of());
DistributionJobEntity distributionJobEntity = createDistributionJobEntity(jobId, distributionJobRequestModel);
distributionJobEntity.setJiraServerJobDetails(jiraServerJobDetailsEntity);
BlackDuckJobDetailsEntity blackDuckJobDetailsEntity = createBlackDuckJobDetailsEntity(jobId, distributionJobRequestModel);
Mockito.when(jiraServerJobDetailsAccessor.saveJobDetails(Mockito.any(), Mockito.any())).thenReturn(jiraServerJobDetailsModel);
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());
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.JiraServerJobDetailsModel in project hub-alert by blackducksoftware.
the class JiraServerSummaryFieldLengthTestIT method createJiraServerMessageSender.
private static IssueTrackerMessageSender<String> createJiraServerMessageSender() throws AlertException {
TestProperties testProperties = new TestProperties();
Gson gson = new GsonBuilder().create();
IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
JiraServerMessageSenderFactory jiraServerMessageSenderFactory = new JiraServerMessageSenderFactory(gson, ChannelKeys.JIRA_SERVER, createJiraServerPropertiesFactory(testProperties), new IssueTrackerCallbackInfoCreator(), issueCategoryRetriever);
JiraServerJobDetailsModel jiraServerJobDetails = createJiraServerJobDetails(testProperties);
return jiraServerMessageSenderFactory.createMessageSender(jiraServerJobDetails);
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.JiraServerJobDetailsModel in project hub-alert by blackducksoftware.
the class JiraServerJobDetailsAccessorTest method retrieveDetailsTest.
@Test
void retrieveDetailsTest() {
UUID jobId = UUID.randomUUID();
List<JiraServerJobCustomFieldEntity> customFields = createCustomFieldEntities(jobId);
JiraServerJobDetailsEntity jiraJobDetailsEntity = createDetailsEntity(jobId);
jiraJobDetailsEntity.setJobCustomFields(customFields);
Mockito.when(jobDetailsRepository.findById(jobId)).thenReturn(Optional.of(jiraJobDetailsEntity));
Mockito.when(jiraServerJobCustomFieldRepository.findByJobId(jobId)).thenReturn(customFields);
JiraServerJobDetailsModel foundJobDetailsModel = jobDetailsAccessor.retrieveDetails(jobId).orElse(null);
assertNotNull(foundJobDetailsModel);
assertEquals(jobId, foundJobDetailsModel.getJobId());
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.JiraServerJobDetailsModel in project hub-alert by blackducksoftware.
the class DefaultJiraServerJobDetailsAccessor method saveConcreteJobDetails.
@Override
@Transactional(propagation = Propagation.REQUIRED)
public JiraServerJobDetailsModel saveConcreteJobDetails(UUID jobId, JiraServerJobDetailsModel jobDetails) {
JiraServerJobDetailsEntity jiraServerJobDetailsToSave = new JiraServerJobDetailsEntity(jobId, jobDetails.isAddComments(), jobDetails.getIssueCreatorUsername(), jobDetails.getProjectNameOrKey(), jobDetails.getIssueType(), jobDetails.getResolveTransition(), jobDetails.getReopenTransition(), jobDetails.getIssueSummary());
JiraServerJobDetailsEntity savedJobDetails = jiraServerJobDetailsRepository.save(jiraServerJobDetailsToSave);
jiraServerJobCustomFieldRepository.bulkDeleteByJobId(jobId);
List<JiraServerJobCustomFieldEntity> customFieldsToSave = jobDetails.getCustomFields().stream().map(model -> new JiraServerJobCustomFieldEntity(savedJobDetails.getJobId(), model.getFieldName(), model.getFieldValue())).collect(Collectors.toList());
List<JiraServerJobCustomFieldEntity> savedJobCustomFields = jiraServerJobCustomFieldRepository.saveAll(customFieldsToSave);
savedJobDetails.setJobCustomFields(savedJobCustomFields);
return convertToModel(savedJobDetails);
}
Aggregations