Search in sources :

Example 16 with BlackDuckJobDetailsEntity

use of com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity 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 17 with BlackDuckJobDetailsEntity

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

the class DefaultProcessingJobAccessor method convertToFilteredDistributionJobResponseModel.

private FilteredDistributionJobResponseModel convertToFilteredDistributionJobResponseModel(DistributionJobEntity jobEntity) {
    UUID jobId = jobEntity.getJobId();
    ProcessingType processingType = Enum.valueOf(ProcessingType.class, jobEntity.getProcessingType());
    String channelName = jobEntity.getChannelDescriptorName();
    String jobName = jobEntity.getName();
    BlackDuckJobDetailsEntity blackDuckJobDetails = jobEntity.getBlackDuckJobDetails();
    List<String> notificationTypes = blackDuckJobDetailsAccessor.retrieveNotificationTypesForJob(jobId);
    List<BlackDuckProjectDetailsModel> projectDetails = blackDuckJobDetailsAccessor.retrieveProjectDetailsForJob(jobId);
    List<String> policyNames = blackDuckJobDetailsAccessor.retrievePolicyNamesForJob(jobId);
    List<String> vulnerabilitySeverityNames = blackDuckJobDetailsAccessor.retrieveVulnerabilitySeverityNamesForJob(jobId);
    boolean filterByProject = blackDuckJobDetails.getFilterByProject();
    String projectNamePattern = blackDuckJobDetails.getProjectNamePattern();
    String projectVersionNamePattern = blackDuckJobDetails.getProjectVersionNamePattern();
    return new FilteredDistributionJobResponseModel(jobId, processingType, channelName, jobName, notificationTypes, projectDetails, policyNames, vulnerabilitySeverityNames, filterByProject, projectNamePattern, projectVersionNamePattern);
}
Also used : FilteredDistributionJobResponseModel(com.synopsys.integration.alert.common.persistence.model.job.FilteredDistributionJobResponseModel) BlackDuckProjectDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.BlackDuckProjectDetailsModel) ProcessingType(com.synopsys.integration.alert.common.enumeration.ProcessingType) UUID(java.util.UUID) BlackDuckJobDetailsEntity(com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity)

Aggregations

BlackDuckJobDetailsEntity (com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity)17 UUID (java.util.UUID)17 DistributionJobEntity (com.synopsys.integration.alert.database.job.DistributionJobEntity)15 DistributionJobModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel)14 Test (org.junit.jupiter.api.Test)14 DistributionJobRequestModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel)7 PageImpl (org.springframework.data.domain.PageImpl)4 SlackJobDetailsEntity (com.synopsys.integration.alert.database.job.slack.SlackJobDetailsEntity)3 BlackDuckProjectDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.BlackDuckProjectDetailsModel)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 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 ChannelKey (com.synopsys.integration.alert.descriptor.api.model.ChannelKey)2 ProviderKey (com.synopsys.integration.alert.descriptor.api.model.ProviderKey)2 PageRequest (org.springframework.data.domain.PageRequest)2 EmailJobDetailsEntity (com.synopsys.integration.alert.channel.email.database.job.EmailJobDetailsEntity)1 JiraServerJobDetailsEntity (com.synopsys.integration.alert.channel.jira.server.database.job.JiraServerJobDetailsEntity)1