use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class MSTeamsChannelMessageSender method sendMessages.
@Override
public MessageResult sendMessages(MSTeamsJobDetailsModel msTeamsJobDetailsModel, List<MSTeamsChannelMessageModel> channelMessages) throws AlertException {
String webhook = msTeamsJobDetailsModel.getWebhook();
Map<String, String> requestHeaders = new HashMap<>();
requestHeaders.put("Content-Type", "application/json");
IntHttpClient intHttpClient = connectionFactory.createIntHttpClient(webhook);
RestChannelUtility restChannelUtility = new RestChannelUtility(intHttpClient);
List<Request> messageRequests = channelMessages.stream().map(this::createJsonString).map(jsonString -> restChannelUtility.createPostMessageRequest(webhook, requestHeaders, jsonString)).collect(Collectors.toList());
restChannelUtility.sendMessage(messageRequests, msTeamsKey.getUniversalKey());
return new MessageResult(String.format("Successfully sent %d MSTeams message(s)", channelMessages.size()));
}
use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class AzureBoardsGlobalFieldModelTestAction method testConfig.
@Override
public MessageResult testConfig(String configId, FieldModel fieldModel, FieldUtility registeredFieldValues) throws IntegrationException {
try {
Optional<ConfigurationFieldModel> configurationFieldModel = registeredFieldValues.getField(AzureBoardsDescriptor.KEY_ORGANIZATION_NAME);
String organizationName = configurationFieldModel.flatMap(ConfigurationFieldModel::getFieldValue).orElse(null);
AzureBoardsProperties azureBoardsProperties = AzureBoardsProperties.fromFieldAccessor(azureBoardsCredentialDataStoreFactory, azureRedirectUrlCreator.createOAuthRedirectUri(), registeredFieldValues);
AzureHttpService azureHttpService = createAzureHttpService(azureBoardsProperties);
AzureProjectService azureProjectService = new AzureProjectService(azureHttpService, new AzureApiVersionAppender());
azureProjectService.getProjects(organizationName);
return new MessageResult("Successfully connected to Azure instance.");
} catch (HttpServiceException ex) {
logger.error("Global Test Action failed testing Azure Boards connection.", ex);
throw (ex);
}
}
use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class BlackDuckDistributionFieldModelTestActionTest method testConfigWithOnlyProjectVersionNamePatternTest.
@Test
public void testConfigWithOnlyProjectVersionNamePatternTest() throws IntegrationException {
FieldUtility fieldUtility = createFieldUtilityData(null, "1.0.*");
BlackDuckDistributionFieldModelTestAction testAction = createTestAction();
MessageResult messageResult = testAction.testConfig(null, null, fieldUtility);
assertNotNull(messageResult);
assertFalse(messageResult.hasErrors(), messageResult.getFieldStatusesBySeverity(FieldStatusSeverity.ERROR).toString());
assertFalse(messageResult.hasWarnings(), messageResult.getFieldStatusesBySeverity(FieldStatusSeverity.WARNING).toString());
}
use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class BlackDuckDistributionFieldModelTestActionTest method testConfigWithProjectVersionAndProjectNamePatternsTest.
@Test
public void testConfigWithProjectVersionAndProjectNamePatternsTest() throws IntegrationException {
FieldUtility fieldUtility = createFieldUtilityData("na.*", "1.0.*");
BlackDuckDistributionFieldModelTestAction testAction = createTestAction();
MessageResult messageResult = testAction.testConfig(null, null, fieldUtility);
assertNotNull(messageResult);
assertFalse(messageResult.hasErrors(), messageResult.getFieldStatusesBySeverity(FieldStatusSeverity.ERROR).toString());
assertFalse(messageResult.hasWarnings(), messageResult.getFieldStatusesBySeverity(FieldStatusSeverity.WARNING).toString());
}
use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class BlackDuckDistributionFieldModelTestActionTest method testConfigWithProjectVersionAndProjectNamePatternsNotMatchingTest.
@Test
public void testConfigWithProjectVersionAndProjectNamePatternsNotMatchingTest() throws IntegrationException {
FieldUtility fieldUtility = createFieldUtilityData("fake*", "wrong");
BlackDuckDistributionFieldModelTestAction testAction = createTestAction();
MessageResult messageResult = testAction.testConfig(null, null, fieldUtility);
assertNotNull(messageResult);
assertFalse(messageResult.hasErrors(), messageResult.getFieldStatusesBySeverity(FieldStatusSeverity.ERROR).toString());
assertTrue(messageResult.hasWarnings(), messageResult.getFieldStatusesBySeverity(FieldStatusSeverity.WARNING).toString());
assertEquals(2, messageResult.getFieldStatuses().size(), messageResult.getFieldStatuses().toString());
}
Aggregations