Search in sources :

Example 6 with DistributionJobRequestModel

use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel in project hub-alert by blackducksoftware.

the class StaticJobAccessorTestIT method verifyMSTeamsSavesTest.

@Test
public void verifyMSTeamsSavesTest() {
    MSTeamsJobDetailsModel msTeamsJobDetailsModel = new MSTeamsJobDetailsModel(UUID.randomUUID(), "webhook");
    DistributionJobRequestModel jobRequestModel = createJobRequestModel(msTeamsJobDetailsModel, new MsTeamsKey());
    createAndAssertJob(jobRequestModel);
}
Also used : MsTeamsKey(com.synopsys.integration.alert.descriptor.api.MsTeamsKey) MSTeamsJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.MSTeamsJobDetailsModel) DistributionJobRequestModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 7 with DistributionJobRequestModel

use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel in project hub-alert by blackducksoftware.

the class NotificationContentRepositoryIT method initializeNotificationRepo.

private Long initializeNotificationRepo(String searchTerm, int numberToCreate) throws ParseException {
    List<NotificationEntity> notifications = new ArrayList<>(numberToCreate);
    long searchableCount = 0;
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(RestConstants.JSON_DATE_FORMAT);
    for (int i = 0; i < numberToCreate; i++) {
        Date newDate = new Date();
        String dateString = simpleDateFormat.format(newDate);
        NotificationEntity entity;
        if (i % 31 == 0) {
            entity = createEntity(dateString, searchTerm);
            searchableCount++;
        } else {
            entity = createEntity(dateString);
        }
        notifications.add(entity);
    }
    List<NotificationEntity> savedNotifications = notificationContentRepository.saveAll(notifications);
    DistributionJobRequestModel jobRequestModel = createJobRequestModel();
    DistributionJobModel jobModel = jobAccessor.createJob(jobRequestModel);
    UUID jobId = jobModel.getJobId();
    // more investigation is needed
    for (NotificationEntity savedNotification : savedNotifications) {
        AuditEntryEntity newEntry = new AuditEntryEntity(jobId, OffsetDateTime.now(), null, AuditEntryStatus.PENDING.name(), null, null);
        AuditEntryEntity savedEntry = auditEntryRepository.save(newEntry);
        AuditNotificationRelation notifAudit = new AuditNotificationRelation(savedEntry.getId(), savedNotification.getId());
        auditNotificationRepository.save(notifAudit);
    }
    auditEntryRepository.flush();
    return searchableCount;
}
Also used : ArrayList(java.util.ArrayList) DistributionJobRequestModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel) Date(java.util.Date) DistributionJobModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel) AuditNotificationRelation(com.synopsys.integration.alert.database.audit.AuditNotificationRelation) AuditEntryEntity(com.synopsys.integration.alert.database.audit.AuditEntryEntity) UUID(java.util.UUID) NotificationEntity(com.synopsys.integration.alert.database.notification.NotificationEntity) SimpleDateFormat(java.text.SimpleDateFormat)

Example 8 with DistributionJobRequestModel

use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel 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());
}
Also used : DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) JiraServerJobDetailsEntity(com.synopsys.integration.alert.channel.jira.server.database.job.JiraServerJobDetailsEntity) UUID(java.util.UUID) DistributionJobRequestModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel) JiraServerJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraServerJobDetailsModel) 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 9 with DistributionJobRequestModel

use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel 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());
}
Also used : JiraCloudJobDetailsEntity(com.synopsys.integration.alert.database.job.jira.cloud.JiraCloudJobDetailsEntity) DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) UUID(java.util.UUID) JiraCloudJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraCloudJobDetailsModel) DistributionJobRequestModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel) 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 10 with DistributionJobRequestModel

use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel 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());
}
Also used : MSTeamsJobDetailsEntity(com.synopsys.integration.alert.database.job.msteams.MSTeamsJobDetailsEntity) DistributionJobEntity(com.synopsys.integration.alert.database.job.DistributionJobEntity) MSTeamsJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.MSTeamsJobDetailsModel) UUID(java.util.UUID) DistributionJobRequestModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel) 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)

Aggregations

DistributionJobRequestModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel)34 Test (org.junit.jupiter.api.Test)25 DistributionJobModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel)18 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)16 UUID (java.util.UUID)10 DistributionJobEntity (com.synopsys.integration.alert.database.job.DistributionJobEntity)7 BlackDuckJobDetailsEntity (com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity)7 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)6 SlackJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.SlackJobDetailsModel)6 AuditEntryEntity (com.synopsys.integration.alert.database.audit.AuditEntryEntity)6 ArrayList (java.util.ArrayList)6 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)4 AuditNotificationRelation (com.synopsys.integration.alert.database.audit.AuditNotificationRelation)4 NotificationEntity (com.synopsys.integration.alert.database.notification.NotificationEntity)4 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)3 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)3 ValidationActionResponse (com.synopsys.integration.alert.common.action.ValidationActionResponse)3 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)3 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)3 JobFieldModel (com.synopsys.integration.alert.common.rest.model.JobFieldModel)3