Search in sources :

Example 16 with ItemAttributeResource

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource in project service-api by reportportal.

the class ItemAttributeConverterTest method fromResource.

@Test
void fromResource() {
    ItemAttributeResource resource = new ItemAttributeResource("key", "val");
    final ItemAttribute itemAttribute = ItemAttributeConverter.FROM_RESOURCE.apply(resource);
    assertEquals(itemAttribute.getKey(), resource.getKey());
    assertEquals(itemAttribute.getValue(), resource.getValue());
    assertEquals(itemAttribute.isSystem(), false);
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) Test(org.junit.jupiter.api.Test)

Example 17 with ItemAttributeResource

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource in project service-api by reportportal.

the class EmailRulesValidatorTest method validateEmptyLaunchAttributes.

@Test
void validateEmptyLaunchAttributes() {
    ItemAttributeResource attribute = new ItemAttributeResource();
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> EmailRulesValidator.validateLaunchAttribute(attribute));
    assertEquals("Error in handled Request. Please, check specified parameters: 'Attribute' values cannot be empty. Please specify them or do not include in a request.'", exception.getMessage());
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Test(org.junit.jupiter.api.Test)

Example 18 with ItemAttributeResource

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource in project service-api by reportportal.

the class EmailRulesValidatorTest method successfullyValidateLaunchAttribute.

@Test
void successfullyValidateLaunchAttribute() {
    ItemAttributeResource attribute = new ItemAttributeResource();
    attribute.setKey("key");
    attribute.setValue("value");
    EmailRulesValidator.validateLaunchAttribute(attribute);
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) Test(org.junit.jupiter.api.Test)

Example 19 with ItemAttributeResource

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource 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

ItemAttributeResource (com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource)19 Test (org.junit.jupiter.api.Test)16 Launch (com.epam.ta.reportportal.entity.launch.Launch)10 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)9 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)9 LocalDateTime (java.time.LocalDateTime)8 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)7 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 BulkInfoUpdateRQ (com.epam.ta.reportportal.ws.model.BulkInfoUpdateRQ)6 UpdateItemAttributeRQ (com.epam.ta.reportportal.ws.model.attribute.UpdateItemAttributeRQ)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 Lists (com.google.common.collect.Lists)5 Sets (com.google.common.collect.Sets)5 ZoneId (java.time.ZoneId)5 java.util (java.util)5 Matchers.hasSize (org.hamcrest.Matchers.hasSize)5 Assertions (org.junit.jupiter.api.Assertions)5 APPLICATION_JSON (org.springframework.http.MediaType.APPLICATION_JSON)5 Sql (org.springframework.test.context.jdbc.Sql)5