use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel 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());
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel 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());
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel in project hub-alert by blackducksoftware.
the class AuditEntryControllerTestIT method testResendNotification.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void testResendNotification() throws Exception {
DistributionJobRequestModel jobRequestModel = createJobRequestModel();
DistributionJobModel job = jobAccessor.createJob(jobRequestModel);
NotificationEntity notificationEntity = mockNotificationContent.createEntity();
notificationEntity = notificationRepository.save(notificationEntity);
mockAuditEntryEntity.setCommonConfigId(job.getJobId());
AuditEntryEntity auditEntity = mockAuditEntryEntity.createEntity();
auditEntity = auditEntryRepository.save(auditEntity);
auditNotificationRepository.save(new AuditNotificationRelation(auditEntity.getId(), notificationEntity.getId()));
String resendUrl = auditUrl + "/resend/" + notificationEntity.getId() + "/";
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(resendUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel in project hub-alert by blackducksoftware.
the class AuditEntryControllerTestIT method testResendJobConfig.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void testResendJobConfig() throws Exception {
List<ConfigurationFieldModel> slackFields = new ArrayList<>(MockConfigurationModelFactory.createSlackDistributionFields());
ConfigurationFieldModel providerConfigName = providerConfigModel.getField(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME).orElse(null);
slackFields.add(providerConfigName);
DistributionJobRequestModel jobRequestModel = createJobRequestModel();
DistributionJobModel jobModel = jobAccessor.createJob(jobRequestModel);
NotificationEntity notificationEntity = mockNotificationContent.createEntity();
notificationEntity = notificationRepository.save(notificationEntity);
mockAuditEntryEntity.setCommonConfigId(jobModel.getJobId());
AuditEntryEntity auditEntity = mockAuditEntryEntity.createEntity();
auditEntity = auditEntryRepository.save(auditEntity);
auditNotificationRepository.save(new AuditNotificationRelation(auditEntity.getId(), notificationEntity.getId()));
String resendUrl = auditUrl + "/resend/" + notificationEntity.getId() + "/job/" + auditEntity.getCommonConfigId();
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(resendUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel in project hub-alert by blackducksoftware.
the class AuditEntryHandlerTestIT method getTestIT.
@Test
public void getTestIT() {
NotificationEntity savedNotificationEntity = notificationContentRepository.save(mockNotification.createEntity());
notificationContentRepository.save(new MockNotificationContent(DateUtils.createCurrentDateTimestamp(), "provider", DateUtils.createCurrentDateTimestamp(), "notificationType", "{}", 234L, providerConfigModel.getConfigurationId()).createEntity());
DistributionJobRequestModel jobRequestModel = createJobRequestModel();
DistributionJobModel jobModel = jobAccessor.createJob(jobRequestModel);
AuditEntryEntity savedAuditEntryEntity = auditEntryRepository.save(new AuditEntryEntity(jobModel.getJobId(), DateUtils.createCurrentDateTimestamp(), DateUtils.createCurrentDateTimestamp(), AuditEntryStatus.SUCCESS.toString(), null, null));
auditNotificationRepository.save(new AuditNotificationRelation(savedAuditEntryEntity.getId(), savedNotificationEntity.getId()));
AuthorizationManager authorizationManager = Mockito.mock(AuthorizationManager.class);
Mockito.when(authorizationManager.hasReadPermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
AuditEntryActions auditEntryActions = createAuditActions(authorizationManager);
AuditEntryPageModel auditEntries = auditEntryActions.get(null, null, null, null, null, true).getContent().orElse(null);
assertEquals(1, auditEntries.getContent().size());
AuditEntryModel auditEntryResponse = auditEntryActions.get(savedNotificationEntity.getId()).getContent().orElse(null);
assertNotNull(auditEntryResponse);
AuditEntryModel auditEntry = auditEntries.getContent().get(0);
assertEquals(savedNotificationEntity.getId().toString(), auditEntry.getId());
assertFalse(auditEntry.getJobs().isEmpty());
assertEquals(1, auditEntry.getJobs().size());
NotificationConfig notification = auditEntry.getNotification();
String createdAtStringValue = DateUtils.formatDate(savedNotificationEntity.getCreatedAt(), DateUtils.AUDIT_DATE_FORMAT);
assertEquals(createdAtStringValue, notification.getCreatedAt());
assertEquals(savedNotificationEntity.getNotificationType(), notification.getNotificationType());
assertNotNull(notification.getContent());
auditEntries = auditEntryActions.get(null, null, null, null, null, false).getContent().orElse(null);
assertEquals(2, auditEntries.getContent().size());
}
Aggregations