Search in sources :

Example 16 with DistributionJobEntity

use of com.synopsys.integration.alert.database.job.DistributionJobEntity in project hub-alert by blackducksoftware.

the class StaticJobAccessorTest method getPageOfJobsSearchTest.

@Test
void getPageOfJobsSearchTest() {
    ProviderKey providerKey = new BlackDuckProviderKey();
    UUID jobId = UUID.randomUUID();
    DistributionJobEntity distributionJobEntity = createSlackDistributionJobEntity(jobId);
    distributionJobEntity.setBlackDuckJobDetails(new BlackDuckJobDetailsEntity(jobId, 3L, true, "*", "*"));
    Page<DistributionJobEntity> page = new PageImpl<>(List.of(distributionJobEntity));
    Mockito.when(distributionJobRepository.findByChannelDescriptorNamesAndSearchTerm(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(page);
    AlertPagedModel<DistributionJobModel> pageOfJobs = jobAccessor.getPageOfJobs(0, 10, "test-search-term", List.of(providerKey.getUniversalKey()));
    assertEquals(1, pageOfJobs.getTotalPages());
    List<DistributionJobModel> models = pageOfJobs.getModels();
    assertEquals(1, models.size());
    DistributionJobModel distributionJobModel = models.get(0);
    assertEquals(jobId, distributionJobModel.getJobId());
    assertEquals(jobName, distributionJobModel.getName());
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) BlackDuckProviderKey(com.synopsys.integration.alert.descriptor.api.BlackDuckProviderKey) DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) BlackDuckProviderKey(com.synopsys.integration.alert.descriptor.api.BlackDuckProviderKey) ProviderKey(com.synopsys.integration.alert.descriptor.api.model.ProviderKey) UUID(java.util.UUID) BlackDuckJobDetailsEntity(com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity) DistributionJobModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel) Test(org.junit.jupiter.api.Test)

Example 17 with DistributionJobEntity

use of com.synopsys.integration.alert.database.job.DistributionJobEntity 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());
}
Also used : DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) 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) DistributionJobRequestModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel) BlackDuckJobDetailsEntity(com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity) DistributionJobModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel) Test(org.junit.jupiter.api.Test)

Example 18 with DistributionJobEntity

use of com.synopsys.integration.alert.database.job.DistributionJobEntity in project hub-alert by blackducksoftware.

the class StaticJobAccessorTest method createSlackDistributionJobEntity.

private DistributionJobEntity createSlackDistributionJobEntity(UUID jobId) {
    SlackJobDetailsEntity slackJobDetailsEntity = new SlackJobDetailsEntity();
    DistributionJobEntity distributionJobEntity = new DistributionJobEntity(jobId, jobName, true, FrequencyType.REAL_TIME.name(), ProcessingType.DEFAULT.name(), ChannelKeys.SLACK.getUniversalKey(), UUID.randomUUID(), DateUtils.createCurrentDateTimestamp(), DateUtils.createCurrentDateTimestamp());
    distributionJobEntity.setSlackJobDetails(slackJobDetailsEntity);
    return distributionJobEntity;
}
Also used : DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) SlackJobDetailsEntity(com.synopsys.integration.alert.database.job.slack.SlackJobDetailsEntity)

Example 19 with DistributionJobEntity

use of com.synopsys.integration.alert.database.job.DistributionJobEntity in project hub-alert by blackducksoftware.

the class StaticJobAccessorTest method getPageOfJobsBlankSearchTest.

@Test
void getPageOfJobsBlankSearchTest() {
    ProviderKey providerKey = new BlackDuckProviderKey();
    UUID jobId = UUID.randomUUID();
    DistributionJobEntity distributionJobEntity = createSlackDistributionJobEntity(jobId);
    distributionJobEntity.setBlackDuckJobDetails(new BlackDuckJobDetailsEntity(jobId, 3L, true, "*", "*"));
    Page<DistributionJobEntity> page = new PageImpl<>(List.of(distributionJobEntity));
    Mockito.when(distributionJobRepository.findByChannelDescriptorNameIn(Mockito.any(), Mockito.any())).thenReturn(page);
    AlertPagedModel<DistributionJobModel> pageOfJobs = jobAccessor.getPageOfJobs(0, 10, " ", List.of(providerKey.getUniversalKey()));
    assertEquals(1, pageOfJobs.getTotalPages());
    List<DistributionJobModel> models = pageOfJobs.getModels();
    assertEquals(1, models.size());
    DistributionJobModel distributionJobModel = models.get(0);
    assertEquals(jobId, distributionJobModel.getJobId());
    assertEquals(jobName, distributionJobModel.getName());
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) BlackDuckProviderKey(com.synopsys.integration.alert.descriptor.api.BlackDuckProviderKey) DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) BlackDuckProviderKey(com.synopsys.integration.alert.descriptor.api.BlackDuckProviderKey) ProviderKey(com.synopsys.integration.alert.descriptor.api.model.ProviderKey) UUID(java.util.UUID) BlackDuckJobDetailsEntity(com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity) DistributionJobModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel) Test(org.junit.jupiter.api.Test)

Example 20 with DistributionJobEntity

use of com.synopsys.integration.alert.database.job.DistributionJobEntity in project hub-alert by blackducksoftware.

the class StaticJobAccessorTest method createEmailDistributionJobEntity.

private DistributionJobEntity createEmailDistributionJobEntity(UUID jobId) {
    EmailJobDetailsEntity emailJobDetailsEntity = new EmailJobDetailsEntity();
    DistributionJobEntity distributionJobEntity = new DistributionJobEntity(jobId, jobName, true, FrequencyType.REAL_TIME.name(), ProcessingType.DEFAULT.name(), ChannelKeys.EMAIL.getUniversalKey(), UUID.randomUUID(), DateUtils.createCurrentDateTimestamp(), DateUtils.createCurrentDateTimestamp());
    distributionJobEntity.setEmailJobDetails(emailJobDetailsEntity);
    return distributionJobEntity;
}
Also used : DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) EmailJobDetailsEntity(com.synopsys.integration.alert.channel.email.database.job.EmailJobDetailsEntity)

Aggregations

DistributionJobEntity (com.synopsys.integration.alert.database.job.DistributionJobEntity)21 DistributionJobModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel)15 BlackDuckJobDetailsEntity (com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity)15 UUID (java.util.UUID)15 Test (org.junit.jupiter.api.Test)15 DistributionJobRequestModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel)7 PageRequest (org.springframework.data.domain.PageRequest)5 SlackJobDetailsEntity (com.synopsys.integration.alert.database.job.slack.SlackJobDetailsEntity)4 PageImpl (org.springframework.data.domain.PageImpl)4 EmailJobDetailsEntity (com.synopsys.integration.alert.channel.email.database.job.EmailJobDetailsEntity)2 EmailJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.EmailJobDetailsModel)2 SlackJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.SlackJobDetailsModel)2 AlertPagedModel (com.synopsys.integration.alert.common.rest.model.AlertPagedModel)2 AzureBoardsJobDetailsEntity (com.synopsys.integration.alert.database.job.azure.boards.AzureBoardsJobDetailsEntity)2 JiraCloudJobDetailsEntity (com.synopsys.integration.alert.database.job.jira.cloud.JiraCloudJobDetailsEntity)2 MSTeamsJobDetailsEntity (com.synopsys.integration.alert.database.job.msteams.MSTeamsJobDetailsEntity)2 BlackDuckProviderKey (com.synopsys.integration.alert.descriptor.api.BlackDuckProviderKey)2 ProviderKey (com.synopsys.integration.alert.descriptor.api.model.ProviderKey)2 OffsetDateTime (java.time.OffsetDateTime)2 Transactional (org.springframework.transaction.annotation.Transactional)2