Search in sources :

Example 26 with MessageResult

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");
}
Also used : MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException)

Example 27 with MessageResult

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);
    }
}
Also used : MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) EmailChannelMessagingService(com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService) JavamailPropertiesFactory(com.synopsys.integration.alert.service.email.JavamailPropertiesFactory) FieldUtility(com.synopsys.integration.alert.common.persistence.accessor.FieldUtility) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) Test(org.junit.jupiter.api.Test)

Example 28 with MessageResult

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);
}
Also used : MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) FieldUtility(com.synopsys.integration.alert.common.persistence.accessor.FieldUtility) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag) Disabled(org.junit.jupiter.api.Disabled)

Example 29 with MessageResult

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());
}
Also used : MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) FieldUtility(com.synopsys.integration.alert.common.persistence.accessor.FieldUtility) Test(org.junit.jupiter.api.Test)

Example 30 with MessageResult

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());
}
Also used : MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) FieldUtility(com.synopsys.integration.alert.common.persistence.accessor.FieldUtility) Test(org.junit.jupiter.api.Test)

Aggregations

MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)39 Test (org.junit.jupiter.api.Test)25 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)22 List (java.util.List)12 FieldUtility (com.synopsys.integration.alert.common.persistence.accessor.FieldUtility)11 DistributionJobModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel)10 UUID (java.util.UUID)9 IssueTrackerIssueResponseModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel)8 IssueTrackerModelHolder (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder)8 OffsetDateTime (java.time.OffsetDateTime)8 IssueTransitionModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel)7 DistributionJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel)7 IssueTrackerMessageSender (com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSender)6 EmailChannelMessagingService (com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService)6 IssueOperation (com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation)6 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)6 JavamailPropertiesFactory (com.synopsys.integration.alert.service.email.JavamailPropertiesFactory)6 IssueTrackerMessageSenderFactory (com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSenderFactory)5 FrequencyType (com.synopsys.integration.alert.common.enumeration.FrequencyType)5 ProcessingType (com.synopsys.integration.alert.common.enumeration.ProcessingType)5