Search in sources :

Example 1 with Launch

use of com.epam.ta.reportportal.entity.launch.Launch 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 2 with Launch

use of com.epam.ta.reportportal.entity.launch.Launch 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 3 with Launch

use of com.epam.ta.reportportal.entity.launch.Launch 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)

Example 4 with Launch

use of com.epam.ta.reportportal.entity.launch.Launch in project commons-dao by reportportal.

the class LaunchRepositoryTest method sortingByJoinedColumnLatestTest.

@Test
void sortingByJoinedColumnLatestTest() {
    PageRequest pageRequest = PageRequest.of(0, 10, Sort.by(Sort.Direction.ASC, "statistics$defects$product_bug$pb001"));
    Page<Launch> launchesPage = launchRepository.findAllLatestByFilter(Filter.builder().withTarget(Launch.class).withCondition(FilterCondition.builder().withCondition(Condition.LOWER_THAN).withSearchCriteria(CRITERIA_ID).withValue("100").build()).build(), pageRequest);
    assertTrue(Comparators.isInOrder(launchesPage.getContent(), Comparator.comparing(Launch::getUserId)));
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) Launch(com.epam.ta.reportportal.entity.launch.Launch) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 5 with Launch

use of com.epam.ta.reportportal.entity.launch.Launch in project commons-dao by reportportal.

the class LaunchRepositoryTest method sortingByJoinedColumnTest.

@Test
void sortingByJoinedColumnTest() {
    PageRequest pageRequest = PageRequest.of(0, 10, Sort.by(Sort.Direction.ASC, CRITERIA_USER));
    Page<Launch> launchesPage = launchRepository.findByFilter(Filter.builder().withTarget(Launch.class).withCondition(FilterCondition.builder().withCondition(Condition.LOWER_THAN).withSearchCriteria(CRITERIA_ID).withValue("100").build()).build(), pageRequest);
    assertTrue(Comparators.isInOrder(launchesPage.getContent(), Comparator.comparing(Launch::getUserId)));
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) Launch(com.epam.ta.reportportal.entity.launch.Launch) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

Launch (com.epam.ta.reportportal.entity.launch.Launch)9 BaseTest (com.epam.ta.reportportal.BaseTest)7 Test (org.junit.jupiter.api.Test)7 TestItem (com.epam.ta.reportportal.entity.item.TestItem)5 Filter (com.epam.ta.reportportal.commons.querygen.Filter)4 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)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 CRITERIA_USER (com.epam.ta.reportportal.commons.querygen.constant.UserCriteriaConstant.CRITERIA_USER)3 WidgetContentRepositoryConstants (com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants)3 Activity (com.epam.ta.reportportal.entity.activity.Activity)3 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)3 com.epam.ta.reportportal.entity.widget.content (com.epam.ta.reportportal.entity.widget.content)3