use of com.synopsys.integration.alert.channel.email.database.job.EmailJobDetailsEntity 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