Search in sources :

Example 6 with EmailJobDetailsEntity

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));
}
Also used : EmailJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.EmailJobDetailsModel) EmailJobDetailsEntity(com.synopsys.integration.alert.channel.email.database.job.EmailJobDetailsEntity) UUID(java.util.UUID) EmailJobAdditionalEmailAddressEntity(com.synopsys.integration.alert.channel.email.database.job.additional.EmailJobAdditionalEmailAddressEntity) Test(org.junit.jupiter.api.Test)

Aggregations

EmailJobDetailsEntity (com.synopsys.integration.alert.channel.email.database.job.EmailJobDetailsEntity)6 EmailJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.EmailJobDetailsModel)5 UUID (java.util.UUID)5 EmailJobAdditionalEmailAddressEntity (com.synopsys.integration.alert.channel.email.database.job.additional.EmailJobAdditionalEmailAddressEntity)4 Test (org.junit.jupiter.api.Test)4 DistributionJobEntity (com.synopsys.integration.alert.database.job.DistributionJobEntity)2 EmailJobDetailsRepository (com.synopsys.integration.alert.channel.email.database.job.EmailJobDetailsRepository)1 EmailJobAdditionalEmailAddressRepository (com.synopsys.integration.alert.channel.email.database.job.additional.EmailJobAdditionalEmailAddressRepository)1 EmailJobDetailsAccessor (com.synopsys.integration.alert.common.persistence.accessor.EmailJobDetailsAccessor)1 DistributionJobModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel)1 DistributionJobRequestModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel)1 DistributionJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel)1 BlackDuckJobDetailsEntity (com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity)1 EmailChannelKey (com.synopsys.integration.alert.descriptor.api.EmailChannelKey)1 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Component (org.springframework.stereotype.Component)1