use of com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity in project hub-alert by blackducksoftware.
the class StaticJobAccessorTest method getJobByIdTest.
@Test
void getJobByIdTest() {
UUID jobId = UUID.randomUUID();
DistributionJobEntity distributionJobEntity = createSlackDistributionJobEntity(jobId);
distributionJobEntity.setBlackDuckJobDetails(new BlackDuckJobDetailsEntity(jobId, 3L, true, "*", "*"));
Mockito.when(distributionJobRepository.findById(jobId)).thenReturn(Optional.of(distributionJobEntity));
Optional<DistributionJobModel> jobById = jobAccessor.getJobById(jobId);
assertTrue(jobById.isPresent());
DistributionJobModel distributionJobModel = jobById.get();
assertEquals(jobId, distributionJobModel.getJobId());
assertEquals(jobName, distributionJobModel.getName());
}
use of com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity in project hub-alert by blackducksoftware.
the class StaticJobAccessorTest method getJobByNameTest.
@Test
void getJobByNameTest() {
UUID jobId = UUID.randomUUID();
DistributionJobEntity distributionJobEntity = createSlackDistributionJobEntity(jobId);
distributionJobEntity.setBlackDuckJobDetails(new BlackDuckJobDetailsEntity(jobId, 3L, true, "*", "*"));
Mockito.when(distributionJobRepository.findByName(Mockito.any())).thenReturn(Optional.of(distributionJobEntity));
Optional<DistributionJobModel> jobByName = jobAccessor.getJobByName(jobName);
assertTrue(jobByName.isPresent());
DistributionJobModel distributionJobModel = jobByName.get();
assertEquals(jobId, distributionJobModel.getJobId());
assertEquals(jobName, distributionJobModel.getName());
}
use of com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity 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());
}
use of com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity 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());
}
use of com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity 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());
}
Aggregations