use of com.synopsys.integration.alert.channel.jira.server.database.job.custom_field.JiraServerJobCustomFieldEntity 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.channel.jira.server.database.job.custom_field.JiraServerJobCustomFieldEntity 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);
}
use of com.synopsys.integration.alert.channel.jira.server.database.job.custom_field.JiraServerJobCustomFieldEntity in project hub-alert by blackducksoftware.
the class JiraServerJobDetailsAccessorTest method saveJobDetailsTest.
@Test
void saveJobDetailsTest() {
UUID jobId = UUID.randomUUID();
List<JiraServerJobCustomFieldEntity> customFields = createCustomFieldEntities(jobId);
JiraServerJobDetailsEntity jiraJobDetailsEntity = createDetailsEntity(jobId);
jiraJobDetailsEntity.setJobCustomFields(customFields);
JiraServerJobDetailsModel jiraJobDetailsModel = createDetailsModel(jiraJobDetailsEntity);
Mockito.when(jiraServerJobCustomFieldRepository.saveAll(Mockito.any())).thenReturn(customFields);
Mockito.when(jiraServerJobCustomFieldRepository.findByJobId(jobId)).thenReturn(customFields);
Mockito.when(jobDetailsRepository.findById(jobId)).thenReturn(Optional.of(jiraJobDetailsEntity));
Mockito.when(jobDetailsRepository.save(Mockito.any())).thenReturn(jiraJobDetailsEntity);
JiraServerJobDetailsModel newJiraJobDetails = jobDetailsAccessor.saveJobDetails(jobId, jiraJobDetailsModel);
assertEquals(jobId, newJiraJobDetails.getJobId());
assertNotNull(newJiraJobDetails.getCustomFields());
assertEquals(1, newJiraJobDetails.getCustomFields().size());
}
Aggregations