Search in sources :

Example 1 with LaunchAttributeRule

use of com.epam.ta.reportportal.entity.project.email.LaunchAttributeRule in project service-api by reportportal.

the class NotificationConfigConverterTest method getSenderCases.

private static Set<SenderCase> getSenderCases() {
    Set<SenderCase> senderCases = new HashSet<>();
    senderCases.add(getCase());
    final LaunchAttributeRule launchAttributeRule = new LaunchAttributeRule();
    launchAttributeRule.setId(1L);
    launchAttributeRule.setKey("key");
    launchAttributeRule.setValue("value");
    senderCases.add(new SenderCase(Sets.newHashSet("recipent3", "recipient8"), Sets.newHashSet("launch1", "launch5", "launch10"), Sets.newHashSet(launchAttributeRule), SendCase.ALWAYS, true));
    return senderCases;
}
Also used : SenderCase(com.epam.ta.reportportal.entity.project.email.SenderCase) LaunchAttributeRule(com.epam.ta.reportportal.entity.project.email.LaunchAttributeRule) HashSet(java.util.HashSet)

Example 2 with LaunchAttributeRule

use of com.epam.ta.reportportal.entity.project.email.LaunchAttributeRule in project service-api by reportportal.

the class NotificationConfigConverterTest method getCase.

private static SenderCase getCase() {
    final LaunchAttributeRule launchAttributeRule = new LaunchAttributeRule();
    launchAttributeRule.setId(2L);
    launchAttributeRule.setKey("key1");
    launchAttributeRule.setValue("value1");
    return new SenderCase(Sets.newHashSet("recipent1", "recipient2"), Sets.newHashSet("launch1", "launch2", "launch3"), Sets.newHashSet(launchAttributeRule), SendCase.MORE_10, true);
}
Also used : SenderCase(com.epam.ta.reportportal.entity.project.email.SenderCase) LaunchAttributeRule(com.epam.ta.reportportal.entity.project.email.LaunchAttributeRule)

Example 3 with LaunchAttributeRule

use of com.epam.ta.reportportal.entity.project.email.LaunchAttributeRule in project service-api by reportportal.

the class LaunchNotificationSubscriber method isAttributesMatched.

/**
 * Validate matching of finished launch tags and project settings for emailing
 *
 * @param launch Launch to be evaluated
 * @return TRUE if tags matched
 */
@VisibleForTesting
private static boolean isAttributesMatched(Launch launch, Set<LaunchAttributeRule> launchAttributeRules) {
    if (CollectionUtils.isEmpty(launchAttributeRules)) {
        return true;
    }
    return launch.getAttributes().stream().filter(attribute -> !attribute.isSystem()).map(attribute -> {
        ItemAttributeResource attributeResource = new ItemAttributeResource();
        attributeResource.setKey(attribute.getKey());
        attributeResource.setValue(attribute.getValue());
        return attributeResource;
    }).collect(Collectors.toSet()).containsAll(launchAttributeRules.stream().map(NotificationConfigConverter.TO_ATTRIBUTE_RULE_RESOURCE).collect(Collectors.toSet()));
}
Also used : StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) GetIntegrationHandler(com.epam.ta.reportportal.core.integration.GetIntegrationHandler) Project(com.epam.ta.reportportal.entity.project.Project) SenderCase(com.epam.ta.reportportal.entity.project.email.SenderCase) IntegrationGroupEnum(com.epam.ta.reportportal.entity.enums.IntegrationGroupEnum) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) BooleanUtils(org.apache.commons.lang3.BooleanUtils) ProjectAttributeEnum(com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) LaunchFinishedEvent(com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent) EmailService(com.epam.ta.reportportal.util.email.EmailService) ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) MailServiceFactory(com.epam.ta.reportportal.util.email.MailServiceFactory) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) NotificationConfigConverter(com.epam.ta.reportportal.ws.converter.converters.NotificationConfigConverter) Logger(org.slf4j.Logger) Launch(com.epam.ta.reportportal.entity.launch.Launch) User(com.epam.ta.reportportal.entity.user.User) WidgetContentRepositoryConstants(com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants) Integration(com.epam.ta.reportportal.entity.integration.Integration) LaunchFinishedEventSubscriber(com.epam.ta.reportportal.core.events.handler.subscriber.LaunchFinishedEventSubscriber) UserRepository(com.epam.ta.reportportal.dao.UserRepository) ProjectUtils(com.epam.ta.reportportal.entity.project.ProjectUtils) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Set(java.util.Set) Collectors(java.util.stream.Collectors) LaunchAttributeRule(com.epam.ta.reportportal.entity.project.email.LaunchAttributeRule) Objects(java.util.Objects) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) Optional(java.util.Optional) StatisticsHelper.extractStatisticsCount(com.epam.ta.reportportal.core.statistics.StatisticsHelper.extractStatisticsCount) VisibleForTesting(com.google.common.annotations.VisibleForTesting) SendCase(com.epam.ta.reportportal.entity.enums.SendCase) ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

LaunchAttributeRule (com.epam.ta.reportportal.entity.project.email.LaunchAttributeRule)3 SenderCase (com.epam.ta.reportportal.entity.project.email.SenderCase)3 LaunchFinishedEvent (com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent)1 LaunchFinishedEventSubscriber (com.epam.ta.reportportal.core.events.handler.subscriber.LaunchFinishedEventSubscriber)1 GetIntegrationHandler (com.epam.ta.reportportal.core.integration.GetIntegrationHandler)1 StatisticsHelper.extractStatisticsCount (com.epam.ta.reportportal.core.statistics.StatisticsHelper.extractStatisticsCount)1 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)1 UserRepository (com.epam.ta.reportportal.dao.UserRepository)1 WidgetContentRepositoryConstants (com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants)1 IntegrationGroupEnum (com.epam.ta.reportportal.entity.enums.IntegrationGroupEnum)1 ProjectAttributeEnum (com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum)1 SendCase (com.epam.ta.reportportal.entity.enums.SendCase)1 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)1 Integration (com.epam.ta.reportportal.entity.integration.Integration)1 Launch (com.epam.ta.reportportal.entity.launch.Launch)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ProjectUtils (com.epam.ta.reportportal.entity.project.ProjectUtils)1 User (com.epam.ta.reportportal.entity.user.User)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 EmailService (com.epam.ta.reportportal.util.email.EmailService)1