Search in sources :

Example 21 with WidgetOptions

use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.

the class PassingRateSummaryContentValidatorTest method testValidateWithException.

@Test
public void testValidateWithException() {
    Exception exception = assertThrows(ReportPortalException.class, () -> passingRateSummaryContentValidator.validate(Collections.singletonList("test"), new HashMap<>(), new WidgetOptions(), 5));
    String expectedMessage = "Filter-Sort mapping should not be empty";
    String actualMessage = exception.getMessage();
    assertTrue(actualMessage.contains(expectedMessage));
}
Also used : HashMap(java.util.HashMap) WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Test(org.junit.jupiter.api.Test)

Example 22 with WidgetOptions

use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.

the class LineChartContentLoader method loadContent.

@Override
public Map<String, ?> loadContent(List<String> contentFields, Map<Filter, Sort> filterSortMapping, WidgetOptions widgetOptions, int limit) {
    Filter filter = GROUP_FILTERS.apply(filterSortMapping.keySet());
    Sort sort = GROUP_SORTS.apply(filterSortMapping.values());
    List<ChartStatisticsContent> content = widgetContentRepository.launchStatistics(filter, contentFields, sort, limit);
    String timeLineOption = ofNullable(widgetOptions).map(wo -> WidgetOptionUtil.getValueByKey(TIMELINE, wo)).orElse(Strings.EMPTY);
    if (StringUtils.isNotBlank(timeLineOption)) {
        Optional<Period> period = Period.findByName(timeLineOption);
        if (period.isPresent()) {
            return CollectionUtils.isEmpty(content) ? emptyMap() : singletonMap(RESULT, groupByDate(content, period.get()));
        }
    }
    return CollectionUtils.isEmpty(content) ? emptyMap() : singletonMap(RESULT, content);
}
Also used : WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) GROUP_SORTS(com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_SORTS) Collections.emptyMap(java.util.Collections.emptyMap) TIMELINE(com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.TIMELINE) Optional.ofNullable(java.util.Optional.ofNullable) Filter(com.epam.ta.reportportal.commons.querygen.Filter) WidgetOptionUtil(com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) GROUP_FILTERS(com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_FILTERS) WidgetContentRepository(com.epam.ta.reportportal.dao.WidgetContentRepository) StringUtils(org.apache.commons.lang3.StringUtils) ChartStatisticsContent(com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent) List(java.util.List) RESULT(com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.RESULT) LoadContentStrategy(com.epam.ta.reportportal.core.widget.content.LoadContentStrategy) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) Map(java.util.Map) Strings(org.apache.logging.log4j.util.Strings) Optional(java.util.Optional) Sort(org.springframework.data.domain.Sort) Collections.singletonMap(java.util.Collections.singletonMap) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Sort(org.springframework.data.domain.Sort) ChartStatisticsContent(com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent)

Example 23 with WidgetOptions

use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.

the class MostTimeConsumingContentLoader method buildItemFilter.

private Filter buildItemFilter(Long launchId, WidgetOptions widgetOptions, List<String> contentFields) {
    Filter filter = Filter.builder().withTarget(TestItem.class).withCondition(FilterCondition.builder().eq(CRITERIA_LAUNCH_ID, String.valueOf(launchId)).build()).build();
    filter = updateFilterWithStatuses(filter, contentFields);
    filter = updateFilterWithTestItemTypes(filter, ofNullable(widgetOptions.getOptions().get(INCLUDE_METHODS)).map(v -> BooleanUtils.toBoolean(String.valueOf(v))).orElse(false));
    return filter.withCondition(FilterCondition.builder().eq(CRITERIA_HAS_CHILDREN, Boolean.FALSE.toString()).build()).withCondition(FilterCondition.builder().eq(CRITERIA_HAS_STATS, Boolean.TRUE.toString()).build());
}
Also used : TestItemTypeEnum(com.epam.ta.reportportal.entity.enums.TestItemTypeEnum) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) TestItem(com.epam.ta.reportportal.entity.item.TestItem) ContentLoaderConstants(com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) GROUP_FILTERS(com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_FILTERS) BooleanUtils(org.apache.commons.lang3.BooleanUtils) TestItemCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant) MostTimeConsumingTestCasesContent(com.epam.ta.reportportal.entity.widget.content.MostTimeConsumingTestCasesContent) StringUtils(org.apache.commons.lang3.StringUtils) Lists(com.google.common.collect.Lists) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Map(java.util.Map) CRITERIA_LAUNCH_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_LAUNCH_ID) CRITERIA_NAME(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_NAME) Sort(org.springframework.data.domain.Sort) Collections.emptyMap(java.util.Collections.emptyMap) Launch(com.epam.ta.reportportal.entity.launch.Launch) ImmutableMap(com.google.common.collect.ImmutableMap) Optional.ofNullable(java.util.Optional.ofNullable) Filter(com.epam.ta.reportportal.commons.querygen.Filter) WidgetOptionUtil(com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) WidgetContentRepository(com.epam.ta.reportportal.dao.WidgetContentRepository) Collectors(java.util.stream.Collectors) List(java.util.List) HAS_METHOD_OR_CLASS(com.epam.ta.reportportal.core.filter.predefined.PredefinedFilters.HAS_METHOD_OR_CLASS) LoadContentStrategy(com.epam.ta.reportportal.core.widget.content.LoadContentStrategy) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) LatestLaunchContent(com.epam.ta.reportportal.entity.widget.content.LatestLaunchContent) STEP(com.epam.ta.reportportal.jooq.enums.JTestItemTypeEnum.STEP) Collections(java.util.Collections) Filter(com.epam.ta.reportportal.commons.querygen.Filter)

Example 24 with WidgetOptions

use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.

the class MostTimeConsumingContentLoader method loadContent.

@Override
public Map<String, ?> loadContent(List<String> contentFields, Map<Filter, Sort> filterSortMap, WidgetOptions widgetOptions, int limit) {
    Filter filter = GROUP_FILTERS.apply(filterSortMap.keySet());
    String launchName = WidgetOptionUtil.getValueByKey(LAUNCH_NAME_FIELD, widgetOptions);
    return launchRepository.findLatestByFilter(filter.withCondition(FilterCondition.builder().eq(CRITERIA_NAME, launchName).build())).map(l -> loadContent(l, widgetOptions, contentFields)).orElseGet(Collections::emptyMap);
}
Also used : TestItemTypeEnum(com.epam.ta.reportportal.entity.enums.TestItemTypeEnum) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) TestItem(com.epam.ta.reportportal.entity.item.TestItem) ContentLoaderConstants(com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) GROUP_FILTERS(com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_FILTERS) BooleanUtils(org.apache.commons.lang3.BooleanUtils) TestItemCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant) MostTimeConsumingTestCasesContent(com.epam.ta.reportportal.entity.widget.content.MostTimeConsumingTestCasesContent) StringUtils(org.apache.commons.lang3.StringUtils) Lists(com.google.common.collect.Lists) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Map(java.util.Map) CRITERIA_LAUNCH_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_LAUNCH_ID) CRITERIA_NAME(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_NAME) Sort(org.springframework.data.domain.Sort) Collections.emptyMap(java.util.Collections.emptyMap) Launch(com.epam.ta.reportportal.entity.launch.Launch) ImmutableMap(com.google.common.collect.ImmutableMap) Optional.ofNullable(java.util.Optional.ofNullable) Filter(com.epam.ta.reportportal.commons.querygen.Filter) WidgetOptionUtil(com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) WidgetContentRepository(com.epam.ta.reportportal.dao.WidgetContentRepository) Collectors(java.util.stream.Collectors) List(java.util.List) HAS_METHOD_OR_CLASS(com.epam.ta.reportportal.core.filter.predefined.PredefinedFilters.HAS_METHOD_OR_CLASS) LoadContentStrategy(com.epam.ta.reportportal.core.widget.content.LoadContentStrategy) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) LatestLaunchContent(com.epam.ta.reportportal.entity.widget.content.LatestLaunchContent) STEP(com.epam.ta.reportportal.jooq.enums.JTestItemTypeEnum.STEP) Collections(java.util.Collections) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Collections(java.util.Collections)

Example 25 with WidgetOptions

use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.

the class FlakyCasesTableContentLoader method loadContent.

@Override
public Map<String, ?> loadContent(List<String> contentFields, Map<Filter, Sort> filterSortMapping, WidgetOptions widgetOptions, int limit) {
    Filter filter = GROUP_FILTERS.apply(filterSortMapping.keySet());
    String launchName = WidgetOptionUtil.getValueByKey(LAUNCH_NAME_FIELD, widgetOptions);
    filter.withCondition(new FilterCondition(Condition.EQUALS, false, launchName, CRITERIA_NAME));
    return launchRepository.findLatestByFilter(filter).map(l -> loadContent(l, filter, widgetOptions, limit)).orElseGet(Collections::emptyMap);
}
Also used : WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) ContentLoaderConstants(com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) GROUP_FILTERS(com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_FILTERS) BooleanUtils(org.apache.commons.lang3.BooleanUtils) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Map(java.util.Map) CRITERIA_NAME(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_NAME) Sort(org.springframework.data.domain.Sort) FlakyCasesTableContent(com.epam.ta.reportportal.entity.widget.content.FlakyCasesTableContent) Collections.emptyMap(java.util.Collections.emptyMap) Launch(com.epam.ta.reportportal.entity.launch.Launch) ImmutableMap(com.google.common.collect.ImmutableMap) Optional.ofNullable(java.util.Optional.ofNullable) Filter(com.epam.ta.reportportal.commons.querygen.Filter) WidgetOptionUtil(com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) WidgetContentRepository(com.epam.ta.reportportal.dao.WidgetContentRepository) List(java.util.List) LoadContentStrategy(com.epam.ta.reportportal.core.widget.content.LoadContentStrategy) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) LatestLaunchContent(com.epam.ta.reportportal.entity.widget.content.LatestLaunchContent) Collections(java.util.Collections) Filter(com.epam.ta.reportportal.commons.querygen.Filter) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Collections(java.util.Collections)

Aggregations

WidgetOptions (com.epam.ta.reportportal.entity.widget.WidgetOptions)34 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)20 Test (org.junit.jupiter.api.Test)20 Sort (org.springframework.data.domain.Sort)15 Filter (com.epam.ta.reportportal.commons.querygen.Filter)13 WidgetOptionUtil (com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil)10 Launch (com.epam.ta.reportportal.entity.launch.Launch)10 HashMap (java.util.HashMap)10 Optional.ofNullable (java.util.Optional.ofNullable)10 WidgetContentRepository (com.epam.ta.reportportal.dao.WidgetContentRepository)8 Map (java.util.Map)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 Service (org.springframework.stereotype.Service)7 ContentLoaderConstants (com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants)6 GROUP_FILTERS (com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_FILTERS)6 List (java.util.List)6 CollectionUtils (org.apache.commons.collections.CollectionUtils)6 BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)5 LoadContentStrategy (com.epam.ta.reportportal.core.widget.content.LoadContentStrategy)5 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)5