use of com.synopsys.integration.alert.database.job.DistributionJobEntity in project hub-alert by blackducksoftware.
the class StaticJobAccessorTest method createJiraServerJobTest.
@Test
void createJiraServerJobTest() {
UUID jobId = UUID.randomUUID();
JiraServerJobDetailsModel jiraServerJobDetailsModel = new JiraServerJobDetailsModel(jobId, false, null, null, null, null, null, List.of(), "issueSummary");
DistributionJobRequestModel distributionJobRequestModel = createDistributionJobEntity(ChannelKeys.JIRA_SERVER.getUniversalKey(), jiraServerJobDetailsModel);
JiraServerJobDetailsEntity jiraServerJobDetailsEntity = new JiraServerJobDetailsEntity(null, false, null, null, null, null, null, null);
jiraServerJobDetailsEntity.setJobCustomFields(List.of());
DistributionJobEntity distributionJobEntity = createDistributionJobEntity(jobId, distributionJobRequestModel);
distributionJobEntity.setJiraServerJobDetails(jiraServerJobDetailsEntity);
BlackDuckJobDetailsEntity blackDuckJobDetailsEntity = createBlackDuckJobDetailsEntity(jobId, distributionJobRequestModel);
Mockito.when(jiraServerJobDetailsAccessor.saveJobDetails(Mockito.any(), Mockito.any())).thenReturn(jiraServerJobDetailsModel);
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());
}
use of com.synopsys.integration.alert.database.job.DistributionJobEntity in project hub-alert by blackducksoftware.
the class StaticJobAccessorTest method createJiraCloudJobTest.
@Test
void createJiraCloudJobTest() {
UUID jobId = UUID.randomUUID();
JiraCloudJobDetailsModel jiraCloudJobDetailsModel = new JiraCloudJobDetailsModel(jobId, false, null, null, null, null, null, List.of(), null);
DistributionJobRequestModel distributionJobRequestModel = createDistributionJobEntity(ChannelKeys.JIRA_CLOUD.getUniversalKey(), jiraCloudJobDetailsModel);
JiraCloudJobDetailsEntity jiraCloudJobDetailsEntity = new JiraCloudJobDetailsEntity(null, false, null, null, null, null, null, null);
jiraCloudJobDetailsEntity.setJobCustomFields(List.of());
DistributionJobEntity distributionJobEntity = createDistributionJobEntity(jobId, distributionJobRequestModel);
distributionJobEntity.setJiraCloudJobDetails(jiraCloudJobDetailsEntity);
BlackDuckJobDetailsEntity blackDuckJobDetailsEntity = createBlackDuckJobDetailsEntity(jobId, distributionJobRequestModel);
Mockito.when(jiraCloudJobDetailsAccessor.saveJiraCloudJobDetails(Mockito.any(), Mockito.any())).thenReturn(jiraCloudJobDetailsEntity);
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());
}
use of com.synopsys.integration.alert.database.job.DistributionJobEntity in project hub-alert by blackducksoftware.
the class StaticJobAccessorTest method createMSTeamsJobTest.
@Test
void createMSTeamsJobTest() {
UUID jobId = UUID.randomUUID();
MSTeamsJobDetailsModel msTeamsJobDetailsModel = new MSTeamsJobDetailsModel(jobId, null);
DistributionJobRequestModel distributionJobRequestModel = createDistributionJobEntity(ChannelKeys.MS_TEAMS.getUniversalKey(), msTeamsJobDetailsModel);
MSTeamsJobDetailsEntity msTeamsJobDetailsEntity = new MSTeamsJobDetailsEntity();
DistributionJobEntity distributionJobEntity = createDistributionJobEntity(jobId, distributionJobRequestModel);
distributionJobEntity.setMsTeamsJobDetails(msTeamsJobDetailsEntity);
BlackDuckJobDetailsEntity blackDuckJobDetailsEntity = createBlackDuckJobDetailsEntity(jobId, distributionJobRequestModel);
Mockito.when(msTeamsJobDetailsAccessor.saveMSTeamsJobDetails(Mockito.any(), Mockito.any())).thenReturn(msTeamsJobDetailsEntity);
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());
}
use of com.synopsys.integration.alert.database.job.DistributionJobEntity 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.DistributionJobEntity 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());
}
Aggregations