Search in sources :

Example 71 with FieldModel

use of com.synopsys.integration.alert.common.rest.model.FieldModel in project hub-alert by blackducksoftware.

the class JiraCloudPerformanceTest method jiraCloudJobTest.

@Test
@Disabled
public void jiraCloudJobTest() throws Exception {
    TestProperties testProperties = new TestProperties();
    FieldModel globalConfig = createGlobalConfig(testProperties);
    // Install plugin
    ActionResponse<String> actionResponse = jiraCloudCustomFunctionAction.createActionResponse(globalConfig, null);
    if (actionResponse.isError()) {
        fail("Unable to install the Alert plugin for Jira Cloud. Exiting test...");
    }
    Map<String, FieldValueModel> channelFieldsMap = createChannelFieldsMap(testProperties);
    IntegrationPerformanceTestRunner testRunner = createTestRunner();
    testRunner.runTest(globalConfig, channelFieldsMap, JIRA_CLOUD_PERFORMANCE_JOB_NAME);
}
Also used : TestProperties(com.synopsys.integration.alert.test.common.TestProperties) IntegrationPerformanceTestRunner(com.synopsys.integration.alert.performance.utility.IntegrationPerformanceTestRunner) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Disabled(org.junit.jupiter.api.Disabled)

Example 72 with FieldModel

use of com.synopsys.integration.alert.common.rest.model.FieldModel in project hub-alert by blackducksoftware.

the class BlackDuckProviderService method findBlackDuckProvider.

public String findBlackDuckProvider() throws IntegrationException {
    String blackDuckProviderSearch = String.format("/api/configuration?context=%s&descriptorName=%s", ConfigContextEnum.GLOBAL, blackDuckProviderKey);
    String response = alertRequestUtility.executeGetRequest(blackDuckProviderSearch, "Could not find the Black Duck provider.");
    MultiFieldModel blackDuckConfigurations = gson.fromJson(response, MultiFieldModel.class);
    FieldModel blackDuckProviderConfiguration = blackDuckConfigurations.getFieldModels().stream().filter(blackDuckConfiguration -> blackDuckConfiguration.getFieldValue("blackduck.url").filter(blackDuckProviderUrl::equals).isPresent()).findFirst().orElseThrow(() -> new IntegrationException("Could not find the BlackDuck provider configuration."));
    String blackDuckProviderID = blackDuckProviderConfiguration.getId();
    String blackDuckConfigBody = gson.toJson(blackDuckProviderConfiguration);
    alertRequestUtility.executePutRequest("/api/configuration/" + blackDuckProviderID, blackDuckConfigBody, "Could not save the Black Duck provider.");
    intLogger.info(String.format("Retrieved the Black Duck provider, ID %s.", blackDuckProviderID));
    return blackDuckProviderID;
}
Also used : IntegrationException(com.synopsys.integration.exception.IntegrationException) MultiFieldModel(com.synopsys.integration.alert.common.rest.model.MultiFieldModel) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) MultiFieldModel(com.synopsys.integration.alert.common.rest.model.MultiFieldModel)

Example 73 with FieldModel

use of com.synopsys.integration.alert.common.rest.model.FieldModel in project hub-alert by blackducksoftware.

the class ConfigurationManager method createGlobalConfiguration.

public void createGlobalConfiguration(FieldModel globalConfig) {
    String configurationRequestBody = gson.toJson(globalConfig);
    String descriptorName = globalConfig.getDescriptorName();
    try {
        String globalConfigSearchResponse = alertRequestUtility.executeGetRequest(String.format("/api/configuration?context=%s&descriptorName=%s", ConfigContextEnum.GLOBAL.name(), descriptorName), String.format("Could not find the existing global configuration for %s.", descriptorName));
        JsonObject globalConfigSearchJsonObject = gson.fromJson(globalConfigSearchResponse, JsonObject.class);
        JsonArray fieldModels = globalConfigSearchJsonObject.get("fieldModels").getAsJsonArray();
        JsonElement firstFieldModel = fieldModels.get(0);
        FieldModel originalGlobalConfig = gson.fromJson(firstFieldModel, FieldModel.class);
        globalConfig.setId(originalGlobalConfig.getId());
        alertRequestUtility.executePostRequest("/api/configuration/validate", configurationRequestBody, String.format("Validating the global configuration %s failed.", descriptorName));
        alertRequestUtility.executePostRequest("/api/configuration/test", configurationRequestBody, String.format("Testing the global configuration %s failed.", descriptorName));
        alertRequestUtility.executePutRequest(String.format("/api/configuration/%s", globalConfig.getId()), configurationRequestBody, String.format("Could not create the global configuration %s.", descriptorName));
    } catch (IntegrationException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : JsonArray(com.google.gson.JsonArray) AlertRuntimeException(com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException) IntegrationException(com.synopsys.integration.exception.IntegrationException) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) JobProviderProjectFieldModel(com.synopsys.integration.alert.common.rest.model.JobProviderProjectFieldModel) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) JobFieldModel(com.synopsys.integration.alert.common.rest.model.JobFieldModel)

Aggregations

FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)73 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)43 FieldValueModel (com.synopsys.integration.alert.common.rest.model.FieldValueModel)31 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)28 Test (org.junit.jupiter.api.Test)26 HashMap (java.util.HashMap)25 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)21 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)21 ConfigurationFieldModelConverter (com.synopsys.integration.alert.common.persistence.util.ConfigurationFieldModelConverter)19 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)18 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)18 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)15 ValidationActionResponse (com.synopsys.integration.alert.common.action.ValidationActionResponse)14 FieldUtility (com.synopsys.integration.alert.common.persistence.accessor.FieldUtility)13 JobFieldModel (com.synopsys.integration.alert.common.rest.model.JobFieldModel)13 List (java.util.List)13 Autowired (org.springframework.beans.factory.annotation.Autowired)13 DescriptorAccessor (com.synopsys.integration.alert.common.persistence.accessor.DescriptorAccessor)12 JobProviderProjectFieldModel (com.synopsys.integration.alert.common.rest.model.JobProviderProjectFieldModel)12 MultiFieldModel (com.synopsys.integration.alert.common.rest.model.MultiFieldModel)12