Search in sources :

Example 1 with FilterCondition

use of com.epam.ta.reportportal.commons.querygen.FilterCondition in project commons-dao by reportportal.

the class WidgetContentRepositoryTest method activityStatistics.

@Test
void activityStatistics() {
    Filter filter = buildDefaultActivityFilter(1L);
    Sort sort = Sort.by(Lists.newArrayList(new Sort.Order(Sort.Direction.DESC, CRITERIA_CREATION_DATE)));
    List<String> contentFields = buildActivityContentFields();
    filter.withCondition(new FilterCondition(Condition.EQUALS, false, "superadmin", CRITERIA_USER)).withCondition(new FilterCondition(Condition.IN, false, String.join(",", contentFields), CRITERIA_ACTION));
    List<ActivityResource> activityContentList = widgetContentRepository.activityStatistics(filter, sort, 4);
    assertNotNull(activityContentList);
    assertEquals(4, activityContentList.size());
}
Also used : Filter(com.epam.ta.reportportal.commons.querygen.Filter) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) ActivityResource(com.epam.ta.reportportal.ws.model.ActivityResource) Sort(org.springframework.data.domain.Sort) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 2 with FilterCondition

use of com.epam.ta.reportportal.commons.querygen.FilterCondition in project commons-dao by reportportal.

the class WidgetContentRepositoryTest method launchesComparisonStatisticsSorting.

@Test
void launchesComparisonStatisticsSorting() {
    String sortingColumn = "statistics$defects$no_defect$nd001";
    Filter filter = buildDefaultFilter(1L);
    List<String> contentFields = buildTotalContentFields();
    filter = filter.withConditions(Lists.newArrayList(new FilterCondition(Condition.EQUALS, false, "launch name 1", NAME)));
    List<Sort.Order> orders = filter.getTarget().getCriteriaHolders().stream().map(ch -> new Sort.Order(Sort.Direction.ASC, ch.getFilterCriteria())).collect(Collectors.toList());
    orders.add(new Sort.Order(Sort.Direction.DESC, sortingColumn));
    Sort sort = Sort.by(orders);
    List<ChartStatisticsContent> chartStatisticsContents = widgetContentRepository.launchesComparisonStatistics(filter, contentFields, sort, 2);
    assertNotNull(chartStatisticsContents);
    assertEquals(2, chartStatisticsContents.size());
}
Also used : com.epam.ta.reportportal.entity.widget.content.healthcheck(com.epam.ta.reportportal.entity.widget.content.healthcheck) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) CRITERIA_STATUS(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_STATUS) DSL(org.jooq.impl.DSL) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Activity(com.epam.ta.reportportal.entity.activity.Activity) Autowired(org.springframework.beans.factory.annotation.Autowired) com.epam.ta.reportportal.entity.widget.content(com.epam.ta.reportportal.entity.widget.content) CRITERIA_COMPOSITE_ATTRIBUTE(com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_COMPOSITE_ATTRIBUTE) CRITERIA_ACTION(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_ACTION) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BigDecimal(java.math.BigDecimal) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Map(java.util.Map) DSLContext(org.jooq.DSLContext) Sort(org.springframework.data.domain.Sort) CRITERIA_LAUNCH_MODE(com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE) RoundingMode(java.math.RoundingMode) Record(org.jooq.Record) BaseTest(com.epam.ta.reportportal.BaseTest) Launch(com.epam.ta.reportportal.entity.launch.Launch) ImmutableMap(com.google.common.collect.ImmutableMap) JTestItemTypeEnum(com.epam.ta.reportportal.jooq.enums.JTestItemTypeEnum) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Timestamp(java.sql.Timestamp) WidgetContentRepositoryConstants(com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants) GeneralCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant) ConvertibleCondition(com.epam.ta.reportportal.commons.querygen.ConvertibleCondition) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Result(org.jooq.Result) Maps(com.google.common.collect.Maps) Sql(org.springframework.test.context.jdbc.Sql) Collectors(java.util.stream.Collectors) CRITERIA_CREATION_DATE(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_CREATION_DATE) Test(org.junit.jupiter.api.Test) List(java.util.List) CRITERIA_USER(com.epam.ta.reportportal.commons.querygen.constant.UserCriteriaConstant.CRITERIA_USER) Lists(org.assertj.core.util.Lists) Assertions(org.junit.jupiter.api.Assertions) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) CRITERIA_ITEM_ATTRIBUTE_KEY(com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_ITEM_ATTRIBUTE_KEY) Mode(com.epam.ta.reportportal.ws.model.launch.Mode) ActivityResource(com.epam.ta.reportportal.ws.model.ActivityResource) Filter(com.epam.ta.reportportal.commons.querygen.Filter) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Sort(org.springframework.data.domain.Sort) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 3 with FilterCondition

use of com.epam.ta.reportportal.commons.querygen.FilterCondition in project commons-dao by reportportal.

the class WidgetContentRepositoryTest method activityStatisticsSorting.

@Test
void activityStatisticsSorting() {
    Filter filter = buildDefaultActivityFilter(1L);
    List<Sort.Order> orders = filter.getTarget().getCriteriaHolders().stream().map(ch -> new Sort.Order(Sort.Direction.ASC, ch.getFilterCriteria())).collect(Collectors.toList());
    Sort sort = Sort.by(orders);
    List<String> contentFields = buildActivityContentFields();
    filter.withCondition(new FilterCondition(Condition.EQUALS, false, "superadmin", CRITERIA_USER)).withCondition(new FilterCondition(Condition.IN, false, String.join(",", contentFields), CRITERIA_ACTION));
    List<ActivityResource> activityContentList = widgetContentRepository.activityStatistics(filter, sort, 4);
    assertNotNull(activityContentList);
    assertEquals(4, activityContentList.size());
}
Also used : com.epam.ta.reportportal.entity.widget.content.healthcheck(com.epam.ta.reportportal.entity.widget.content.healthcheck) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) CRITERIA_STATUS(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_STATUS) DSL(org.jooq.impl.DSL) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Activity(com.epam.ta.reportportal.entity.activity.Activity) Autowired(org.springframework.beans.factory.annotation.Autowired) com.epam.ta.reportportal.entity.widget.content(com.epam.ta.reportportal.entity.widget.content) CRITERIA_COMPOSITE_ATTRIBUTE(com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_COMPOSITE_ATTRIBUTE) CRITERIA_ACTION(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_ACTION) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BigDecimal(java.math.BigDecimal) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Map(java.util.Map) DSLContext(org.jooq.DSLContext) Sort(org.springframework.data.domain.Sort) CRITERIA_LAUNCH_MODE(com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE) RoundingMode(java.math.RoundingMode) Record(org.jooq.Record) BaseTest(com.epam.ta.reportportal.BaseTest) Launch(com.epam.ta.reportportal.entity.launch.Launch) ImmutableMap(com.google.common.collect.ImmutableMap) JTestItemTypeEnum(com.epam.ta.reportportal.jooq.enums.JTestItemTypeEnum) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Timestamp(java.sql.Timestamp) WidgetContentRepositoryConstants(com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants) GeneralCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant) ConvertibleCondition(com.epam.ta.reportportal.commons.querygen.ConvertibleCondition) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Result(org.jooq.Result) Maps(com.google.common.collect.Maps) Sql(org.springframework.test.context.jdbc.Sql) Collectors(java.util.stream.Collectors) CRITERIA_CREATION_DATE(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_CREATION_DATE) Test(org.junit.jupiter.api.Test) List(java.util.List) CRITERIA_USER(com.epam.ta.reportportal.commons.querygen.constant.UserCriteriaConstant.CRITERIA_USER) Lists(org.assertj.core.util.Lists) Assertions(org.junit.jupiter.api.Assertions) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) CRITERIA_ITEM_ATTRIBUTE_KEY(com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_ITEM_ATTRIBUTE_KEY) Mode(com.epam.ta.reportportal.ws.model.launch.Mode) ActivityResource(com.epam.ta.reportportal.ws.model.ActivityResource) Filter(com.epam.ta.reportportal.commons.querygen.Filter) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) ActivityResource(com.epam.ta.reportportal.ws.model.ActivityResource) Sort(org.springframework.data.domain.Sort) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 4 with FilterCondition

use of com.epam.ta.reportportal.commons.querygen.FilterCondition in project commons-dao by reportportal.

the class WidgetContentRepositoryTest method launchPassPerLaunchStatistics.

@Test
void launchPassPerLaunchStatistics() {
    Filter filter = buildDefaultFilter(1L);
    filter.withCondition(new FilterCondition(Condition.EQUALS, false, "launch name 1", CRITERIA_NAME));
    final Launch launch = launchRepository.findLatestByFilter(filter).get();
    PassingRateStatisticsResult passStatisticsResult = widgetContentRepository.passingRatePerLaunchStatistics(launch.getId());
    assertNotNull(passStatisticsResult);
    assertEquals(4L, passStatisticsResult.getId());
    assertEquals(4, passStatisticsResult.getNumber());
    assertEquals(3, passStatisticsResult.getPassed());
    assertEquals(12, passStatisticsResult.getTotal());
}
Also used : Filter(com.epam.ta.reportportal.commons.querygen.Filter) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Launch(com.epam.ta.reportportal.entity.launch.Launch) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 5 with FilterCondition

use of com.epam.ta.reportportal.commons.querygen.FilterCondition in project commons-dao by reportportal.

the class WidgetContentRepositoryTest method launchesComparisonStatistics.

@Test
void launchesComparisonStatistics() {
    Filter filter = buildDefaultFilter(1L);
    List<String> contentFields = buildTotalContentFields();
    filter = filter.withConditions(Lists.newArrayList(new FilterCondition(Condition.EQUALS, false, "launch name 1", NAME)));
    Sort sort = Sort.by(Lists.newArrayList(new Sort.Order(Sort.Direction.ASC, CRITERIA_START_TIME)));
    List<ChartStatisticsContent> chartStatisticsContents = widgetContentRepository.launchesComparisonStatistics(filter, contentFields, sort, 2);
    assertNotNull(chartStatisticsContents);
    assertEquals(2, chartStatisticsContents.size());
    chartStatisticsContents.forEach(res -> {
        Map<String, String> currStatistics = res.getValues();
        Map<Long, Map<String, Integer>> preDefinedStatistics = buildLaunchesComparisonStatistics();
        Map<String, Integer> testStatistics = preDefinedStatistics.get(res.getId());
        int executionsSum = testStatistics.entrySet().stream().filter(entry -> entry.getKey().contains(EXECUTIONS_KEY) && !entry.getKey().equalsIgnoreCase(EXECUTIONS_TOTAL)).mapToInt(Map.Entry::getValue).sum();
        int defectsSum = testStatistics.entrySet().stream().filter(entry -> entry.getKey().contains(DEFECTS_KEY)).mapToInt(Map.Entry::getValue).sum();
        currStatistics.keySet().stream().filter(key -> key.contains(EXECUTIONS_KEY) && !key.equalsIgnoreCase(EXECUTIONS_TOTAL)).forEach(key -> assertEquals(Double.parseDouble(currStatistics.get(key)), BigDecimal.valueOf((double) 100 * testStatistics.get(key) / executionsSum).setScale(2, RoundingMode.HALF_UP).doubleValue(), 0.01));
        assertEquals((double) testStatistics.get(EXECUTIONS_TOTAL), Double.parseDouble(currStatistics.get(EXECUTIONS_TOTAL)), 0.01);
        currStatistics.keySet().stream().filter(key -> key.contains(DEFECTS_KEY)).forEach(key -> assertEquals(Double.parseDouble(currStatistics.get(key)), BigDecimal.valueOf((double) 100 * testStatistics.get(key) / defectsSum).setScale(2, RoundingMode.HALF_UP).doubleValue(), 0.01));
    });
}
Also used : com.epam.ta.reportportal.entity.widget.content.healthcheck(com.epam.ta.reportportal.entity.widget.content.healthcheck) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) CRITERIA_STATUS(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_STATUS) DSL(org.jooq.impl.DSL) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Activity(com.epam.ta.reportportal.entity.activity.Activity) Autowired(org.springframework.beans.factory.annotation.Autowired) com.epam.ta.reportportal.entity.widget.content(com.epam.ta.reportportal.entity.widget.content) CRITERIA_COMPOSITE_ATTRIBUTE(com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_COMPOSITE_ATTRIBUTE) CRITERIA_ACTION(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_ACTION) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BigDecimal(java.math.BigDecimal) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Map(java.util.Map) DSLContext(org.jooq.DSLContext) Sort(org.springframework.data.domain.Sort) CRITERIA_LAUNCH_MODE(com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE) RoundingMode(java.math.RoundingMode) Record(org.jooq.Record) BaseTest(com.epam.ta.reportportal.BaseTest) Launch(com.epam.ta.reportportal.entity.launch.Launch) ImmutableMap(com.google.common.collect.ImmutableMap) JTestItemTypeEnum(com.epam.ta.reportportal.jooq.enums.JTestItemTypeEnum) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Timestamp(java.sql.Timestamp) WidgetContentRepositoryConstants(com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants) GeneralCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant) ConvertibleCondition(com.epam.ta.reportportal.commons.querygen.ConvertibleCondition) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Result(org.jooq.Result) Maps(com.google.common.collect.Maps) Sql(org.springframework.test.context.jdbc.Sql) Collectors(java.util.stream.Collectors) CRITERIA_CREATION_DATE(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_CREATION_DATE) Test(org.junit.jupiter.api.Test) List(java.util.List) CRITERIA_USER(com.epam.ta.reportportal.commons.querygen.constant.UserCriteriaConstant.CRITERIA_USER) Lists(org.assertj.core.util.Lists) Assertions(org.junit.jupiter.api.Assertions) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) CRITERIA_ITEM_ATTRIBUTE_KEY(com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_ITEM_ATTRIBUTE_KEY) Mode(com.epam.ta.reportportal.ws.model.launch.Mode) ActivityResource(com.epam.ta.reportportal.ws.model.ActivityResource) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Sort(org.springframework.data.domain.Sort) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

BaseTest (com.epam.ta.reportportal.BaseTest)13 Filter (com.epam.ta.reportportal.commons.querygen.Filter)13 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)13 Test (org.junit.jupiter.api.Test)13 CompositeFilterCondition (com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition)8 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)6 ProjectUser (com.epam.ta.reportportal.entity.user.ProjectUser)6 User (com.epam.ta.reportportal.entity.user.User)6 Launch (com.epam.ta.reportportal.entity.launch.Launch)4 ActivityResource (com.epam.ta.reportportal.ws.model.ActivityResource)4 Sort (org.springframework.data.domain.Sort)4 Condition (com.epam.ta.reportportal.commons.querygen.Condition)3 ConvertibleCondition (com.epam.ta.reportportal.commons.querygen.ConvertibleCondition)3 CRITERIA_ACTION (com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_ACTION)3 CRITERIA_CREATION_DATE (com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_CREATION_DATE)3 GeneralCriteriaConstant (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant)3 CRITERIA_COMPOSITE_ATTRIBUTE (com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_COMPOSITE_ATTRIBUTE)3 CRITERIA_ITEM_ATTRIBUTE_KEY (com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_ITEM_ATTRIBUTE_KEY)3 CRITERIA_LAUNCH_MODE (com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE)3 CRITERIA_STATUS (com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_STATUS)3