Search in sources :

Example 1 with CustomFieldCreationResponseModel

use of com.synopsys.integration.jira.common.model.response.CustomFieldCreationResponseModel in project hub-alert by blackducksoftware.

the class JiraCustomFieldResolver method initializeCaches.

private void initializeCaches() throws IntegrationException {
    List<CustomFieldCreationResponseModel> userVisibleFields = retrieveAvailableFields.get();
    for (CustomFieldCreationResponseModel jiraField : userVisibleFields) {
        nameToModelCache.put(jiraField.getName(), jiraField);
        idToNameCache.put(jiraField.getId(), jiraField.getName());
    }
    cachesHaveBeenInitialized = true;
}
Also used : CustomFieldCreationResponseModel(com.synopsys.integration.jira.common.model.response.CustomFieldCreationResponseModel)

Example 2 with CustomFieldCreationResponseModel

use of com.synopsys.integration.jira.common.model.response.CustomFieldCreationResponseModel in project hub-alert by blackducksoftware.

the class JiraCustomFieldResolver method retrieveCustomFieldDefinition.

protected CustomFieldDefinitionModel retrieveCustomFieldDefinition(JiraCustomFieldConfig customFieldConfig) {
    String fieldName = customFieldConfig.getFieldName();
    CustomFieldCreationResponseModel fieldResponse = retrieveFieldDefinition(fieldName).orElseThrow(() -> new AlertRuntimeException(String.format("No custom field named '%s' existed", fieldName)));
    return new CustomFieldDefinitionModel(fieldResponse.getId(), fieldResponse.getSchema().getType(), fieldResponse.getSchema().getItems());
}
Also used : CustomFieldCreationResponseModel(com.synopsys.integration.jira.common.model.response.CustomFieldCreationResponseModel) AlertRuntimeException(com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException)

Example 3 with CustomFieldCreationResponseModel

use of com.synopsys.integration.jira.common.model.response.CustomFieldCreationResponseModel in project hub-alert by blackducksoftware.

the class JiraCustomFieldResolverTest method verifyCachesAreInitializedTest.

@Test
void verifyCachesAreInitializedTest() {
    JiraCustomFieldResolver jiraCustomFieldResolver = new JiraCustomFieldResolver(retrieveCustomFields(Map.of(FIELD_ID_1, FIELD_NAME_1)));
    Set<String> customFieldIds = jiraCustomFieldResolver.getCustomFieldIds();
    assertEquals(1, customFieldIds.size());
    Optional<CustomFieldCreationResponseModel> customFieldCreationResponseModel = jiraCustomFieldResolver.retrieveFieldDefinition(FIELD_NAME_1);
    assertTrue(customFieldCreationResponseModel.isPresent());
    CustomFieldCreationResponseModel customField = customFieldCreationResponseModel.get();
    assertEquals(FIELD_ID_1, customField.getId());
}
Also used : CustomFieldCreationResponseModel(com.synopsys.integration.jira.common.model.response.CustomFieldCreationResponseModel) Test(org.junit.jupiter.api.Test)

Example 4 with CustomFieldCreationResponseModel

use of com.synopsys.integration.jira.common.model.response.CustomFieldCreationResponseModel in project hub-alert by blackducksoftware.

the class JiraCustomFieldResolverTest method resolveCustomFieldTest.

@Test
void resolveCustomFieldTest() {
    JiraCustomFieldResolver jiraCustomFieldResolver = new JiraCustomFieldResolver(retrieveCustomFields(Map.of(FIELD_ID_1, FIELD_NAME_1)));
    Optional<CustomFieldCreationResponseModel> customFieldCreationResponseModel = jiraCustomFieldResolver.retrieveFieldDefinition(FIELD_NAME_1);
    assertTrue(customFieldCreationResponseModel.isPresent());
    CustomFieldCreationResponseModel customField = customFieldCreationResponseModel.get();
    assertEquals(FIELD_ID_1, customField.getId());
    assertEquals(FIELD_KEY, customField.getKey());
    assertEquals(FIELD_SCHEMA_TYPE, customField.getSchema().getType());
}
Also used : CustomFieldCreationResponseModel(com.synopsys.integration.jira.common.model.response.CustomFieldCreationResponseModel) Test(org.junit.jupiter.api.Test)

Aggregations

CustomFieldCreationResponseModel (com.synopsys.integration.jira.common.model.response.CustomFieldCreationResponseModel)4 Test (org.junit.jupiter.api.Test)2 AlertRuntimeException (com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException)1