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);
}
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;
}
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);
}
}
Aggregations