use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class EmailITTestAssertions method assertSendSimpleMessageSuccess.
public static <D extends DistributionJobDetailsModel> void assertSendSimpleMessageSuccess(DistributionChannel<D> channel, D distributionDetails) {
MessageResult messageResult = null;
try {
messageResult = channel.distributeMessages(distributionDetails, TEST_MESSAGE_HOLDER, "jobName");
} catch (AlertException e) {
Assertions.fail("Failed to distribute simple channel message due to an exception", e);
}
assertFalse(messageResult.hasErrors(), "The message result had errors");
assertFalse(messageResult.hasWarnings(), "The message result had warnings");
}
use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class EmailGlobalFieldModelTestActionTest method testConfigValidTest.
@Test
public void testConfigValidTest() throws AlertException {
EmailChannelMessagingService emailChannelMessagingService = Mockito.mock(EmailChannelMessagingService.class);
Mockito.when(emailChannelMessagingService.sendMessage(Mockito.any(), Mockito.any())).thenReturn(new MessageResult("PASS"));
JavamailPropertiesFactory javamailPropertiesFactory = new JavamailPropertiesFactory();
EmailGlobalFieldModelTestAction emailGlobalFieldModelTestAction = new EmailGlobalFieldModelTestAction(emailChannelMessagingService, javamailPropertiesFactory);
FieldModel validFieldModel = createFieldModelToTest("noreply@synopsys.com");
try {
MessageResult messageResult = emailGlobalFieldModelTestAction.testConfig("0", validFieldModel, new FieldUtility(Map.of()));
assertFalse(messageResult.hasErrors(), "Expected the message result to not have errors");
assertFalse(messageResult.hasWarnings(), "Expected the message result to not have warnings");
} catch (AlertException e) {
fail("An exception was thrown where none was expected", e);
}
}
use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class BlackDuckDistributionFieldModelTestActionTest method verifyProjectNameVersionPatternCheckIsFasterWithMatchingProjectNamePatternTest.
@Disabled
@Test
@Tag(TestTags.DEFAULT_PERFORMANCE)
public void verifyProjectNameVersionPatternCheckIsFasterWithMatchingProjectNamePatternTest() throws IntegrationException {
FieldUtility fieldUtility = createFieldUtilityData(null, "0.0.*");
FieldUtility fasterFieldUtility = createFieldUtilityData("project 2*", "0.0.*");
BlackDuckDistributionFieldModelTestAction testAction = createTestAction();
long startTest1 = System.nanoTime();
MessageResult messageResult = testAction.testConfig(null, null, fieldUtility);
long endTest1 = System.nanoTime();
long slowTime = endTest1 - startTest1;
long startTest2 = System.nanoTime();
MessageResult fasterResult = testAction.testConfig(null, null, fasterFieldUtility);
long endTest2 = System.nanoTime();
long fastTime = endTest2 - startTest2;
assertEquals(messageResult, fasterResult);
assertTrue(fastTime < slowTime, "config with project name pattern should be faster: Fast time " + fastTime + " Slow time " + slowTime);
}
use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class BlackDuckDistributionFieldModelTestActionTest method testConfigWithProjectVersionNamePatternNotMatchingTest.
@Test
public void testConfigWithProjectVersionNamePatternNotMatchingTest() throws IntegrationException {
FieldUtility fieldUtility = createFieldUtilityData(null, "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(1, messageResult.getFieldStatuses().size(), messageResult.getFieldStatuses().toString());
}
use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class BlackDuckDistributionFieldModelTestActionTest method testConfigWithProjectNamePatternNotMatchingTest.
@Test
public void testConfigWithProjectNamePatternNotMatchingTest() throws IntegrationException {
FieldUtility fieldUtility = createFieldUtilityData("fake*", null);
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(1, messageResult.getFieldStatuses().size(), messageResult.getFieldStatuses().toString());
}
Aggregations