Search in sources :

Example 6 with JiraServerJobDetailsModel

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

the class JiraServerExternalConnectionTest method createDistributionDetails.

private JiraServerJobDetailsModel createDistributionDetails() {
    UUID uuid = UUID.randomUUID();
    List<JiraJobCustomFieldModel> customFields = new ArrayList<>();
    // This test requires that the JIRA server has 2 components associated with the project: "component1" and "component2"
    customFields.add(new JiraJobCustomFieldModel("Component/s", "component1 component2"));
    return new JiraServerJobDetailsModel(uuid, Boolean.parseBoolean(testProperties.getProperty(TestPropertyKey.TEST_JIRA_SERVER_ADD_COMMENTS)), testProperties.getOptionalProperty(TestPropertyKey.TEST_JIRA_SERVER_ISSUE_CREATOR).orElse(null), testProperties.getProperty(TestPropertyKey.TEST_JIRA_SERVER_PROJECT_NAME), testProperties.getProperty(TestPropertyKey.TEST_JIRA_SERVER_ISSUE_TYPE), testProperties.getProperty(TestPropertyKey.TEST_JIRA_SERVER_RESOLVE_TRANSITION), testProperties.getProperty(TestPropertyKey.TEST_JIRA_SERVER_REOPEN_TRANSITION), customFields, "");
}
Also used : JiraJobCustomFieldModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraJobCustomFieldModel) ArrayList(java.util.ArrayList) UUID(java.util.UUID) JiraServerJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraServerJobDetailsModel)

Example 7 with JiraServerJobDetailsModel

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

the class JiraServerJobDetailsAccessorTest method retrieveDetailsUnknownIdTest.

@Test
void retrieveDetailsUnknownIdTest() {
    UUID jobId = UUID.randomUUID();
    Mockito.when(jobDetailsRepository.findById(Mockito.any())).thenReturn(Optional.empty());
    Optional<JiraServerJobDetailsModel> foundJobDetailsModel = jobDetailsAccessor.retrieveDetails(jobId);
    assertTrue(foundJobDetailsModel.isEmpty());
}
Also used : UUID(java.util.UUID) JiraServerJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraServerJobDetailsModel) Test(org.junit.jupiter.api.Test)

Example 8 with JiraServerJobDetailsModel

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

the class JiraServerJobDetailsAccessorTest method saveJobDetailsTest.

@Test
void saveJobDetailsTest() {
    UUID jobId = UUID.randomUUID();
    List<JiraServerJobCustomFieldEntity> customFields = createCustomFieldEntities(jobId);
    JiraServerJobDetailsEntity jiraJobDetailsEntity = createDetailsEntity(jobId);
    jiraJobDetailsEntity.setJobCustomFields(customFields);
    JiraServerJobDetailsModel jiraJobDetailsModel = createDetailsModel(jiraJobDetailsEntity);
    Mockito.when(jiraServerJobCustomFieldRepository.saveAll(Mockito.any())).thenReturn(customFields);
    Mockito.when(jiraServerJobCustomFieldRepository.findByJobId(jobId)).thenReturn(customFields);
    Mockito.when(jobDetailsRepository.findById(jobId)).thenReturn(Optional.of(jiraJobDetailsEntity));
    Mockito.when(jobDetailsRepository.save(Mockito.any())).thenReturn(jiraJobDetailsEntity);
    JiraServerJobDetailsModel newJiraJobDetails = jobDetailsAccessor.saveJobDetails(jobId, jiraJobDetailsModel);
    assertEquals(jobId, newJiraJobDetails.getJobId());
    assertNotNull(newJiraJobDetails.getCustomFields());
    assertEquals(1, newJiraJobDetails.getCustomFields().size());
}
Also used : JiraServerJobDetailsEntity(com.synopsys.integration.alert.channel.jira.server.database.job.JiraServerJobDetailsEntity) JiraServerJobCustomFieldEntity(com.synopsys.integration.alert.channel.jira.server.database.job.custom_field.JiraServerJobCustomFieldEntity) UUID(java.util.UUID) JiraServerJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraServerJobDetailsModel) Test(org.junit.jupiter.api.Test)

Aggregations

JiraServerJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.JiraServerJobDetailsModel)8 UUID (java.util.UUID)6 Test (org.junit.jupiter.api.Test)5 JiraServerJobDetailsEntity (com.synopsys.integration.alert.channel.jira.server.database.job.JiraServerJobDetailsEntity)4 JiraServerJobCustomFieldEntity (com.synopsys.integration.alert.channel.jira.server.database.job.custom_field.JiraServerJobCustomFieldEntity)3 DistributionJobRequestModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel)2 JiraJobCustomFieldModel (com.synopsys.integration.alert.common.persistence.model.job.details.JiraJobCustomFieldModel)2 JiraServerChannelKey (com.synopsys.integration.alert.descriptor.api.JiraServerChannelKey)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 IssueTrackerCallbackInfoCreator (com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator)1 IssueCategoryRetriever (com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever)1 JiraServerJobDetailsRepository (com.synopsys.integration.alert.channel.jira.server.database.job.JiraServerJobDetailsRepository)1 JiraServerJobCustomFieldRepository (com.synopsys.integration.alert.channel.jira.server.database.job.custom_field.JiraServerJobCustomFieldRepository)1 JiraServerMessageSenderFactory (com.synopsys.integration.alert.channel.jira.server.distribution.JiraServerMessageSenderFactory)1 JiraServerJobDetailsAccessor (com.synopsys.integration.alert.common.persistence.accessor.JiraServerJobDetailsAccessor)1 DistributionJobModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel)1 DistributionJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel)1 DistributionJobEntity (com.synopsys.integration.alert.database.job.DistributionJobEntity)1 BlackDuckJobDetailsEntity (com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity)1