use of com.synopsys.integration.alert.descriptor.api.model.ProviderKey in project hub-alert by blackducksoftware.
the class PhoneHomeTest method runTest.
@Test
public void runTest() {
RestApiAuditAccessor auditAccessor = Mockito.mock(RestApiAuditAccessor.class);
Mockito.when(auditAccessor.findFirstByJobId(Mockito.any())).thenReturn(Optional.empty());
TaskScheduler taskScheduler = Mockito.mock(TaskScheduler.class);
ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
AboutReader aboutReader = Mockito.mock(AboutReader.class);
Mockito.when(aboutReader.getProductVersion()).thenReturn(TEST_VERSION);
JobAccessor jobAccessor = Mockito.mock(JobAccessor.class);
// FIXME implement mocks
DefaultConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(DefaultConfigurationModelConfigurationAccessor.class);
ConfigurationModel config = Mockito.mock(ConfigurationModel.class);
Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(Mockito.any(DescriptorKey.class))).thenReturn(List.of(config));
DescriptorMap descriptorMap = Mockito.mock(DescriptorMap.class);
Descriptor descriptor = Mockito.mock(Descriptor.class);
DescriptorKey descriptorKey = Mockito.mock(DescriptorKey.class);
Mockito.when(descriptorKey.getUniversalKey()).thenReturn(TEST_DESCRIPTOR_NAME);
Mockito.when(descriptorMap.getDescriptorMap()).thenReturn(Collections.singletonMap(descriptorKey, descriptor));
List<ProviderPhoneHomeHandler> providerHandlers = List.of();
ProviderKey providerKey = new BlackDuckProviderKey();
PhoneHomeTask phoneHomeTask = new PhoneHomeTask(taskScheduler, aboutReader, jobAccessor, configurationModelConfigurationAccessor, null, proxyManager, new Gson(), auditAccessor, providerHandlers, providerKey);
try {
phoneHomeTask.run();
} catch (Exception e) {
fail("Unexpected exception");
}
}
use of com.synopsys.integration.alert.descriptor.api.model.ProviderKey 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());
}
use of com.synopsys.integration.alert.descriptor.api.model.ProviderKey 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());
}
Aggregations