use of com.synopsys.integration.alert.common.persistence.model.job.details.EmailJobDetailsModel in project hub-alert by blackducksoftware.
the class StaticJobAccessorTestIT method verifyEmailSavesTest.
@Test
public void verifyEmailSavesTest() {
EmailJobDetailsModel emailJobDetailsModel = new EmailJobDetailsModel(UUID.randomUUID(), "subjectLine", false, false, "attachmentFileType", List.of());
DistributionJobRequestModel jobRequestModel = createJobRequestModel(emailJobDetailsModel, new EmailChannelKey());
createAndAssertJob(jobRequestModel);
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.EmailJobDetailsModel in project hub-alert by blackducksoftware.
the class StaticJobAccessorTest method createEmailJobTest.
@Test
void createEmailJobTest() {
UUID jobId = UUID.randomUUID();
EmailJobDetailsModel emailJobDetailsModel = new EmailJobDetailsModel(jobId, null, false, false, null, List.of());
DistributionJobRequestModel distributionJobRequestModel = createDistributionJobEntity(ChannelKeys.EMAIL.getUniversalKey(), emailJobDetailsModel);
EmailJobDetailsEntity emailJobDetailsEntity = new EmailJobDetailsEntity(null, null, false, false, null);
emailJobDetailsEntity.setEmailJobAdditionalEmailAddresses(List.of());
DistributionJobEntity distributionJobEntity = createDistributionJobEntity(jobId, distributionJobRequestModel);
distributionJobEntity.setEmailJobDetails(emailJobDetailsEntity);
BlackDuckJobDetailsEntity blackDuckJobDetailsEntity = createBlackDuckJobDetailsEntity(jobId, distributionJobRequestModel);
Mockito.when(emailJobDetailsAccessor.saveJobDetails(Mockito.any(), Mockito.any())).thenReturn(emailJobDetailsModel);
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.EmailJobDetailsModel in project hub-alert by blackducksoftware.
the class EmailDistributionTestAction method resolveTestDistributionDetails.
@Override
protected EmailJobDetailsModel resolveTestDistributionDetails(DistributionJobModel testJobModel) throws AlertException {
Set<String> updateEmailAddresses = emailTestActionHelper.createUpdatedEmailAddresses(testJobModel);
EmailJobDetailsModel originalEmailJobDetails = testJobModel.getDistributionJobDetails().getAs(DistributionJobDetailsModel.EMAIL);
// For testing configuration, just use additional email addresses field
List<String> originalAdditionalEmailAddresses = originalEmailJobDetails.getAdditionalEmailAddresses();
List<String> additionalEmailAddressesToUse = new ArrayList<>(updateEmailAddresses.size() + originalAdditionalEmailAddresses.size());
additionalEmailAddressesToUse.addAll(originalAdditionalEmailAddresses);
additionalEmailAddressesToUse.addAll(updateEmailAddresses);
return new EmailJobDetailsModel(testJobModel.getJobId(), originalEmailJobDetails.getSubjectLine().orElse(null), false, true, originalEmailJobDetails.getAttachmentFileType(), additionalEmailAddressesToUse);
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.EmailJobDetailsModel in project hub-alert by blackducksoftware.
the class EmailTestActionHelper method createUpdatedEmailAddresses.
public Set<String> createUpdatedEmailAddresses(DistributionJobModel distributionJobModel) throws AlertException {
Set<String> emailAddresses = new HashSet<>();
DistributionJobDetailsModel distributionJobDetails = distributionJobModel.getDistributionJobDetails();
EmailJobDetailsModel emailJobDetails = distributionJobDetails.getAs(DistributionJobDetailsModel.EMAIL);
Long providerConfigId = distributionJobModel.getBlackDuckGlobalConfigId();
boolean onlyAdditionalEmails = emailJobDetails.isAdditionalEmailAddressesOnly();
if (null != providerConfigId && !onlyAdditionalEmails) {
Set<ProviderProject> providerProjects = retrieveProviderProjects(distributionJobModel, providerConfigId);
if (CollectionUtils.isNotEmpty(providerProjects)) {
Set<String> providerEmailAddresses = addEmailAddresses(providerConfigId, providerProjects, distributionJobModel, emailJobDetails);
emailAddresses.addAll(providerEmailAddresses);
}
}
return emailAddresses;
}
use of com.synopsys.integration.alert.common.persistence.model.job.details.EmailJobDetailsModel in project hub-alert by blackducksoftware.
the class EmailJobDetailsAccessorTest method saveEmailJobDetailsTest.
@Test
void saveEmailJobDetailsTest() {
UUID jobId = UUID.randomUUID();
String additionalEmailAddress = "fake@synopsys.com";
EmailJobDetailsModel emailJobDetailsModel = new EmailJobDetailsModel(null, null, false, false, null, List.of(additionalEmailAddress));
EmailJobDetailsEntity emailJobDetailsEntity = new EmailJobDetailsEntity(jobId, null, false, false, null);
EmailJobAdditionalEmailAddressEntity emailJobAdditionalEmailAddressEntity = new EmailJobAdditionalEmailAddressEntity(jobId, additionalEmailAddress);
Mockito.when(emailJobDetailsRepository.save(Mockito.any())).thenReturn(emailJobDetailsEntity);
Mockito.when(additionalEmailAddressRepository.saveAll(Mockito.any())).thenReturn(List.of(emailJobAdditionalEmailAddressEntity));
Mockito.when(additionalEmailAddressRepository.findByJobId(Mockito.any())).thenReturn(List.of(emailJobAdditionalEmailAddressEntity));
EmailJobDetailsModel newEmailJobDetails = emailJobDetailsAccessor.saveJobDetails(jobId, emailJobDetailsModel);
Mockito.verify(additionalEmailAddressRepository).bulkDeleteByJobId(Mockito.any());
assertEquals(jobId, newEmailJobDetails.getJobId());
assertEquals(1, newEmailJobDetails.getAdditionalEmailAddresses().size());
assertEquals(additionalEmailAddress, newEmailJobDetails.getAdditionalEmailAddresses().get(0));
}
Aggregations