Search in sources :

Example 11 with DistributionJobEntity

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

the class StaticJobAccessorTest method getJobsByIdTest.

@Test
void getJobsByIdTest() {
    UUID jobId = UUID.randomUUID();
    DistributionJobEntity distributionJobEntity = createSlackDistributionJobEntity(jobId);
    distributionJobEntity.setBlackDuckJobDetails(new BlackDuckJobDetailsEntity(jobId, 3L, true, "*", "*"));
    Mockito.when(distributionJobRepository.findAllById(Mockito.any())).thenReturn(List.of(distributionJobEntity));
    List<DistributionJobModel> jobsById = jobAccessor.getJobsById(List.of(jobId));
    assertEquals(1, jobsById.size());
    DistributionJobModel distributionJobModel = jobsById.get(0);
    assertEquals(jobId, distributionJobModel.getJobId());
    assertEquals(jobName, distributionJobModel.getName());
}
Also used : DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) 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 12 with DistributionJobEntity

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

the class StaticJobAccessorTest method getPageOfJobsEmailTest.

@Test
void getPageOfJobsEmailTest() {
    UUID jobId = UUID.randomUUID();
    DistributionJobEntity distributionJobEntity = createEmailDistributionJobEntity(jobId);
    distributionJobEntity.setBlackDuckJobDetails(new BlackDuckJobDetailsEntity(jobId, 3L, true, "*", "*"));
    Page<DistributionJobEntity> page = new PageImpl<>(List.of(distributionJobEntity));
    Mockito.when(distributionJobRepository.findAll(Mockito.any(PageRequest.class))).thenReturn(page);
    Mockito.when(emailJobDetailsAccessor.retrieveDetails(Mockito.any())).thenReturn(Optional.of(new EmailJobDetailsModel(jobId, null, false, false, "NONE", List.of())));
    AlertPagedModel<DistributionJobModel> pageOfJobs = jobAccessor.getPageOfJobs(0, 10);
    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) PageRequest(org.springframework.data.domain.PageRequest) DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) EmailJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.EmailJobDetailsModel) 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 13 with DistributionJobEntity

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

the class StaticJobAccessorTest method createAzureBoardsJobTest.

@Test
void createAzureBoardsJobTest() {
    UUID jobId = UUID.randomUUID();
    AzureBoardsJobDetailsModel azureBoardsJobDetailsModel = new AzureBoardsJobDetailsModel(jobId, false, null, null, null, null);
    DistributionJobRequestModel distributionJobRequestModel = createDistributionJobEntity(ChannelKeys.AZURE_BOARDS.getUniversalKey(), azureBoardsJobDetailsModel);
    AzureBoardsJobDetailsEntity azureBoardsJobDetailsEntity = new AzureBoardsJobDetailsEntity(null, false, null, null, null, null);
    DistributionJobEntity distributionJobEntity = createDistributionJobEntity(jobId, distributionJobRequestModel);
    distributionJobEntity.setAzureBoardsJobDetails(azureBoardsJobDetailsEntity);
    BlackDuckJobDetailsEntity blackDuckJobDetailsEntity = createBlackDuckJobDetailsEntity(jobId, distributionJobRequestModel);
    Mockito.when(azureBoardsJobDetailsAccessor.saveAzureBoardsJobDetails(Mockito.any(), Mockito.any())).thenReturn(azureBoardsJobDetailsEntity);
    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) AzureBoardsJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.AzureBoardsJobDetailsModel) AzureBoardsJobDetailsEntity(com.synopsys.integration.alert.database.job.azure.boards.AzureBoardsJobDetailsEntity) 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 14 with DistributionJobEntity

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

the class StaticJobAccessorTest method createJobTest.

@Test
void createJobTest() {
    UUID jobId = UUID.randomUUID();
    SlackJobDetailsModel slackJobDetailsModel = new SlackJobDetailsModel(jobId, null, null, null);
    DistributionJobRequestModel distributionJobRequestModel = createDistributionJobEntity(ChannelKeys.SLACK.getUniversalKey(), slackJobDetailsModel);
    SlackJobDetailsEntity slackJobDetailsEntity = new SlackJobDetailsEntity();
    DistributionJobEntity distributionJobEntity = createDistributionJobEntity(jobId, distributionJobRequestModel);
    distributionJobEntity.setSlackJobDetails(slackJobDetailsEntity);
    BlackDuckJobDetailsEntity blackDuckJobDetailsEntity = createBlackDuckJobDetailsEntity(jobId, distributionJobRequestModel);
    Mockito.when(slackJobDetailsAccessor.saveSlackJobDetails(Mockito.any(), Mockito.any())).thenReturn(slackJobDetailsEntity);
    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) SlackJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.SlackJobDetailsModel) UUID(java.util.UUID) DistributionJobRequestModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel) SlackJobDetailsEntity(com.synopsys.integration.alert.database.job.slack.SlackJobDetailsEntity) 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 15 with DistributionJobEntity

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

the class StaticJobAccessorTest method updateJobTest.

@Test
void updateJobTest() throws Exception {
    UUID jobId = UUID.randomUUID();
    SlackJobDetailsModel slackJobDetailsModel = new SlackJobDetailsModel(jobId, null, null, null);
    DistributionJobRequestModel distributionJobRequestModel = new DistributionJobRequestModel(true, jobName, FrequencyType.DAILY, ProcessingType.DEFAULT, ChannelKeys.SLACK.getUniversalKey(), UUID.randomUUID(), 3L, true, "*", "*", Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), slackJobDetailsModel);
    SlackJobDetailsEntity slackJobDetailsEntity = new SlackJobDetailsEntity();
    DistributionJobEntity distributionJobEntity = new DistributionJobEntity(jobId, distributionJobRequestModel.getName(), distributionJobRequestModel.isEnabled(), distributionJobRequestModel.getDistributionFrequency().name(), distributionJobRequestModel.getProcessingType().name(), distributionJobRequestModel.getChannelDescriptorName(), distributionJobRequestModel.getChannelGlobalConfigId(), DateUtils.createCurrentDateTimestamp(), DateUtils.createCurrentDateTimestamp());
    distributionJobEntity.setSlackJobDetails(slackJobDetailsEntity);
    BlackDuckJobDetailsEntity blackDuckJobDetailsEntity = new BlackDuckJobDetailsEntity(jobId, distributionJobRequestModel.getBlackDuckGlobalConfigId(), distributionJobRequestModel.isFilterByProject(), distributionJobRequestModel.getProjectNamePattern().orElse(null), distributionJobRequestModel.getProjectVersionNamePattern().orElse(null));
    Mockito.when(slackJobDetailsAccessor.saveSlackJobDetails(Mockito.any(), Mockito.any())).thenReturn(slackJobDetailsEntity);
    Mockito.when(blackDuckJobDetailsAccessor.saveBlackDuckJobDetails(Mockito.any(), Mockito.any())).thenReturn(blackDuckJobDetailsEntity);
    Mockito.when(distributionJobRepository.findById(Mockito.any())).thenReturn(Optional.of(distributionJobEntity));
    Mockito.when(distributionJobRepository.save(Mockito.any())).thenReturn(distributionJobEntity);
    DistributionJobModel updatedJob = jobAccessor.updateJob(jobId, distributionJobRequestModel);
    Mockito.verify(distributionJobRepository).findById(jobId);
    Mockito.verify(distributionJobRepository).save(Mockito.any());
    assertEquals(jobId, updatedJob.getJobId());
    assertEquals(jobName, updatedJob.getName());
}
Also used : DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) SlackJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.SlackJobDetailsModel) UUID(java.util.UUID) DistributionJobRequestModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel) SlackJobDetailsEntity(com.synopsys.integration.alert.database.job.slack.SlackJobDetailsEntity) 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)

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