Search in sources :

Example 6 with TestItemHistory

use of com.epam.ta.reportportal.entity.item.history.TestItemHistory in project commons-dao by reportportal.

the class TestItemRepositoryCustomImpl method loadItemsHistoryPage.

@Override
public Page<TestItemHistory> loadItemsHistoryPage(Queryable filter, Pageable pageable, Long projectId, int historyDepth, boolean usingHash) {
    SelectQuery<? extends Record> filteringQuery = QueryBuilder.newBuilder(filter, QueryUtils.collectJoinFields(filter, pageable.getSort())).with(pageable.getSort()).build();
    Field<?> historyGroupingField = usingHash ? TEST_ITEM.TEST_CASE_HASH : TEST_ITEM.UNIQUE_ID;
    Page<String> historyBaseline = loadHistoryBaseline(filteringQuery, historyGroupingField, LAUNCH.PROJECT_ID.eq(projectId), pageable);
    List<TestItemHistory> itemHistories = historyBaseline.getContent().stream().map(value -> {
        List<Long> itemIds = loadHistoryItem(getHistoryFilter(filter, usingHash, value), pageable.getSort(), LAUNCH.PROJECT_ID.eq(projectId)).map(testItem -> getHistoryIds(testItem, usingHash, projectId, historyDepth - 1)).orElseGet(Collections::emptyList);
        return new TestItemHistory(value, itemIds);
    }).collect(Collectors.toList());
    return new PageImpl<>(itemHistories, pageable, historyBaseline.getTotalElements());
}
Also used : StatisticsField(com.epam.ta.reportportal.entity.statistics.StatisticsField) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) DSL(org.jooq.impl.DSL) JIssueGroupEnum(com.epam.ta.reportportal.jooq.enums.JIssueGroupEnum) Autowired(org.springframework.beans.factory.annotation.Autowired) IndexTestItem(com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem) TestItemCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant) Condition(org.jooq.Condition) CRITERIA_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID) org.jooq(org.jooq) Duration(java.time.Duration) Pair(org.springframework.data.util.Pair) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) CRITERIA_LAUNCH_MODE(com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE) Repository(org.springframework.stereotype.Repository) CRITERIA_START_TIME(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_START_TIME) TEST_ITEM_RESULTS(com.epam.ta.reportportal.jooq.tables.JTestItemResults.TEST_ITEM_RESULTS) TestItemRepositoryConstants(com.epam.ta.reportportal.dao.constant.TestItemRepositoryConstants) Timestamp(java.sql.Timestamp) WidgetContentRepositoryConstants(com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants) QueryBuilder.retrieveOffsetAndApplyBoundaries(com.epam.ta.reportportal.commons.querygen.QueryBuilder.retrieveOffsetAndApplyBoundaries) PageableExecutionUtils(org.springframework.data.repository.support.PageableExecutionUtils) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) ITEM(com.epam.ta.reportportal.dao.constant.LogRepositoryConstants.ITEM) Strings(org.apache.logging.log4j.util.Strings) com.epam.ta.reportportal.entity.item(com.epam.ta.reportportal.entity.item) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) PageImpl(org.springframework.data.domain.PageImpl) FILTERED_QUERY(com.epam.ta.reportportal.commons.querygen.FilterTarget.FILTERED_QUERY) TimestampUtils(com.epam.ta.reportportal.dao.util.TimestampUtils) TestItemTypeEnum(com.epam.ta.reportportal.entity.enums.TestItemTypeEnum) java.util(java.util) RecordMappers(com.epam.ta.reportportal.dao.util.RecordMappers) TestItemHistory(com.epam.ta.reportportal.entity.item.history.TestItemHistory) JLaunchModeEnum(com.epam.ta.reportportal.jooq.enums.JLaunchModeEnum) LocalDateTime(java.time.LocalDateTime) FILTERED_ID(com.epam.ta.reportportal.commons.querygen.FilterTarget.FILTERED_ID) JTestItem(com.epam.ta.reportportal.jooq.tables.JTestItem) Statistics(com.epam.ta.reportportal.entity.statistics.Statistics) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Tables(com.epam.ta.reportportal.jooq.Tables) Lists(com.google.common.collect.Lists) QueryUtils(com.epam.ta.reportportal.dao.util.QueryUtils) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) JooqFieldNameTransformer.fieldName(com.epam.ta.reportportal.dao.util.JooqFieldNameTransformer.fieldName) ISSUE_TYPE(com.epam.ta.reportportal.jooq.tables.JIssueType.ISSUE_TYPE) LOGS(com.epam.ta.reportportal.dao.constant.LogRepositoryConstants.LOGS) ResultFetchers(com.epam.ta.reportportal.dao.util.ResultFetchers) JTestItemTypeEnum(com.epam.ta.reportportal.jooq.enums.JTestItemTypeEnum) Optional.ofNullable(java.util.Optional.ofNullable) LaunchModeEnum(com.epam.ta.reportportal.entity.enums.LaunchModeEnum) TestItemIssueGroup(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup) ID(com.epam.ta.reportportal.dao.constant.WidgetRepositoryConstants.ID) Collectors.toList(java.util.stream.Collectors.toList) com.epam.ta.reportportal.commons.querygen(com.epam.ta.reportportal.commons.querygen) TEST_ITEM(com.epam.ta.reportportal.jooq.tables.JTestItem.TEST_ITEM) PageImpl(org.springframework.data.domain.PageImpl) Collectors.toList(java.util.stream.Collectors.toList) TestItemHistory(com.epam.ta.reportportal.entity.item.history.TestItemHistory)

Example 7 with TestItemHistory

use of com.epam.ta.reportportal.entity.item.history.TestItemHistory in project commons-dao by reportportal.

the class TestItemRepositoryCustomImpl method loadItemsHistoryPage.

@Override
public Page<TestItemHistory> loadItemsHistoryPage(Queryable filter, Pageable pageable, Long projectId, List<Long> launchIds, int historyDepth, boolean usingHash) {
    SelectQuery<? extends Record> filteringQuery = QueryBuilder.newBuilder(filter, QueryUtils.collectJoinFields(filter, pageable.getSort())).with(pageable.getSort()).addCondition(LAUNCH.ID.in(launchIds).and(LAUNCH.PROJECT_ID.eq(projectId))).build();
    Field<?> historyGroupingField = usingHash ? TEST_ITEM.TEST_CASE_HASH : TEST_ITEM.UNIQUE_ID;
    Page<String> historyBaseline = loadHistoryBaseline(filteringQuery, historyGroupingField, LAUNCH.ID.in(launchIds).and(LAUNCH.PROJECT_ID.eq(projectId)), pageable);
    List<TestItemHistory> itemHistories = historyBaseline.getContent().stream().map(value -> {
        List<Long> itemIds = loadHistoryItem(getHistoryFilter(filter, usingHash, value), pageable.getSort(), LAUNCH.ID.in(launchIds).and(LAUNCH.PROJECT_ID.eq(projectId))).map(testItem -> getHistoryIds(testItem, usingHash, projectId, historyDepth - 1)).orElseGet(Collections::emptyList);
        return new TestItemHistory(value, itemIds);
    }).collect(Collectors.toList());
    return new PageImpl<>(itemHistories, pageable, historyBaseline.getTotalElements());
}
Also used : StatisticsField(com.epam.ta.reportportal.entity.statistics.StatisticsField) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) DSL(org.jooq.impl.DSL) JIssueGroupEnum(com.epam.ta.reportportal.jooq.enums.JIssueGroupEnum) Autowired(org.springframework.beans.factory.annotation.Autowired) IndexTestItem(com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem) TestItemCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant) Condition(org.jooq.Condition) CRITERIA_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID) org.jooq(org.jooq) Duration(java.time.Duration) Pair(org.springframework.data.util.Pair) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) CRITERIA_LAUNCH_MODE(com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE) Repository(org.springframework.stereotype.Repository) CRITERIA_START_TIME(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_START_TIME) TEST_ITEM_RESULTS(com.epam.ta.reportportal.jooq.tables.JTestItemResults.TEST_ITEM_RESULTS) TestItemRepositoryConstants(com.epam.ta.reportportal.dao.constant.TestItemRepositoryConstants) Timestamp(java.sql.Timestamp) WidgetContentRepositoryConstants(com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants) QueryBuilder.retrieveOffsetAndApplyBoundaries(com.epam.ta.reportportal.commons.querygen.QueryBuilder.retrieveOffsetAndApplyBoundaries) PageableExecutionUtils(org.springframework.data.repository.support.PageableExecutionUtils) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) ITEM(com.epam.ta.reportportal.dao.constant.LogRepositoryConstants.ITEM) Strings(org.apache.logging.log4j.util.Strings) com.epam.ta.reportportal.entity.item(com.epam.ta.reportportal.entity.item) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) PageImpl(org.springframework.data.domain.PageImpl) FILTERED_QUERY(com.epam.ta.reportportal.commons.querygen.FilterTarget.FILTERED_QUERY) TimestampUtils(com.epam.ta.reportportal.dao.util.TimestampUtils) TestItemTypeEnum(com.epam.ta.reportportal.entity.enums.TestItemTypeEnum) java.util(java.util) RecordMappers(com.epam.ta.reportportal.dao.util.RecordMappers) TestItemHistory(com.epam.ta.reportportal.entity.item.history.TestItemHistory) JLaunchModeEnum(com.epam.ta.reportportal.jooq.enums.JLaunchModeEnum) LocalDateTime(java.time.LocalDateTime) FILTERED_ID(com.epam.ta.reportportal.commons.querygen.FilterTarget.FILTERED_ID) JTestItem(com.epam.ta.reportportal.jooq.tables.JTestItem) Statistics(com.epam.ta.reportportal.entity.statistics.Statistics) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Tables(com.epam.ta.reportportal.jooq.Tables) Lists(com.google.common.collect.Lists) QueryUtils(com.epam.ta.reportportal.dao.util.QueryUtils) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) JooqFieldNameTransformer.fieldName(com.epam.ta.reportportal.dao.util.JooqFieldNameTransformer.fieldName) ISSUE_TYPE(com.epam.ta.reportportal.jooq.tables.JIssueType.ISSUE_TYPE) LOGS(com.epam.ta.reportportal.dao.constant.LogRepositoryConstants.LOGS) ResultFetchers(com.epam.ta.reportportal.dao.util.ResultFetchers) JTestItemTypeEnum(com.epam.ta.reportportal.jooq.enums.JTestItemTypeEnum) Optional.ofNullable(java.util.Optional.ofNullable) LaunchModeEnum(com.epam.ta.reportportal.entity.enums.LaunchModeEnum) TestItemIssueGroup(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup) ID(com.epam.ta.reportportal.dao.constant.WidgetRepositoryConstants.ID) Collectors.toList(java.util.stream.Collectors.toList) com.epam.ta.reportportal.commons.querygen(com.epam.ta.reportportal.commons.querygen) TEST_ITEM(com.epam.ta.reportportal.jooq.tables.JTestItem.TEST_ITEM) PageImpl(org.springframework.data.domain.PageImpl) Collectors.toList(java.util.stream.Collectors.toList) TestItemHistory(com.epam.ta.reportportal.entity.item.history.TestItemHistory)

Example 8 with TestItemHistory

use of com.epam.ta.reportportal.entity.item.history.TestItemHistory in project commons-dao by reportportal.

the class TestItemRepositoryTest method stepHistoryWithUniqueIdTest.

@Test
void stepHistoryWithUniqueIdTest() {
    List<ConvertibleCondition> commonConditions = Lists.newArrayList(FilterCondition.builder().eq(CRITERIA_HAS_STATS, "true").build(), FilterCondition.builder().eq(CRITERIA_HAS_CHILDREN, "false").build(), FilterCondition.builder().eq(CRITERIA_TYPE, "STEP").build(), FilterCondition.builder().eq(CRITERIA_LAUNCH_ID, "1").build());
    Filter baseFilter = new Filter(FilterTarget.TEST_ITEM_TARGET.getClazz(), commonConditions);
    PageRequest pageable = PageRequest.of(0, 20, Sort.by(CRITERIA_ID));
    List<TestItemHistory> content = custom.loadItemsHistoryPage(baseFilter, pageable, 1L, 30, false).getContent();
    assertFalse(content.isEmpty());
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) TestItemHistory(com.epam.ta.reportportal.entity.item.history.TestItemHistory) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 9 with TestItemHistory

use of com.epam.ta.reportportal.entity.item.history.TestItemHistory in project commons-dao by reportportal.

the class TestItemRepositoryTest method testItemHistoryPageWithLaunchIds.

@Test
void testItemHistoryPageWithLaunchIds() {
    Filter itemFilter = Filter.builder().withTarget(TestItem.class).withCondition(new FilterCondition(Condition.EQUALS, false, "FAILED", CRITERIA_STATUS)).build();
    Sort sort = Sort.by(Lists.newArrayList(new Sort.Order(Sort.Direction.ASC, CRITERIA_START_TIME)));
    Page<TestItemHistory> testItemHistories = testItemRepository.loadItemsHistoryPage(itemFilter, PageRequest.of(0, 2, sort), 1L, com.google.common.collect.Lists.newArrayList(1L, 2L, 3L), 5, true);
    assertFalse(testItemHistories.isEmpty());
    testItemHistories = testItemRepository.loadItemsHistoryPage(itemFilter, PageRequest.of(0, 2, sort), 1L, com.google.common.collect.Lists.newArrayList(1L, 2L, 3L), 5, false);
    assertFalse(testItemHistories.isEmpty());
}
Also used : Sort(org.springframework.data.domain.Sort) TestItemHistory(com.epam.ta.reportportal.entity.item.history.TestItemHistory) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 10 with TestItemHistory

use of com.epam.ta.reportportal.entity.item.history.TestItemHistory in project commons-dao by reportportal.

the class TestItemRepositoryTest method testItemHistoryEmptyPage.

@Test
void testItemHistoryEmptyPage() {
    Filter itemFilter = Filter.builder().withTarget(TestItem.class).withCondition(new FilterCondition(Condition.EQUALS, false, "28933", CRITERIA_PARENT_ID)).withCondition(new FilterCondition(Condition.EQUALS, false, "DEFAULT", CRITERIA_LAUNCH_MODE)).withCondition(new FilterCondition(Condition.EQUALS, false, "1", CRITERIA_PROJECT_ID)).build();
    Sort sort = Sort.by(Lists.newArrayList(new Sort.Order(Sort.Direction.ASC, ID)));
    Page<TestItemHistory> testItemHistories = testItemRepository.loadItemsHistoryPage(itemFilter, PageRequest.of(0, 20, sort), 1L, 5, true);
    assertTrue(testItemHistories.isEmpty());
    testItemHistories = testItemRepository.loadItemsHistoryPage(itemFilter, PageRequest.of(0, 20, sort), 1L, 5, false);
    assertTrue(testItemHistories.isEmpty());
}
Also used : Sort(org.springframework.data.domain.Sort) TestItemHistory(com.epam.ta.reportportal.entity.item.history.TestItemHistory) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

TestItemHistory (com.epam.ta.reportportal.entity.item.history.TestItemHistory)13 Sort (org.springframework.data.domain.Sort)11 BaseTest (com.epam.ta.reportportal.BaseTest)8 Test (org.junit.jupiter.api.Test)8 com.epam.ta.reportportal.commons.querygen (com.epam.ta.reportportal.commons.querygen)5 FILTERED_ID (com.epam.ta.reportportal.commons.querygen.FilterTarget.FILTERED_ID)5 FILTERED_QUERY (com.epam.ta.reportportal.commons.querygen.FilterTarget.FILTERED_QUERY)5 QueryBuilder.retrieveOffsetAndApplyBoundaries (com.epam.ta.reportportal.commons.querygen.QueryBuilder.retrieveOffsetAndApplyBoundaries)5 CRITERIA_ID (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID)5 CRITERIA_START_TIME (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_START_TIME)5 CRITERIA_LAUNCH_MODE (com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE)5 TestItemCriteriaConstant (com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant)5 ITEM (com.epam.ta.reportportal.dao.constant.LogRepositoryConstants.ITEM)5 LOGS (com.epam.ta.reportportal.dao.constant.LogRepositoryConstants.LOGS)5 TestItemRepositoryConstants (com.epam.ta.reportportal.dao.constant.TestItemRepositoryConstants)5 WidgetContentRepositoryConstants (com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants)5 ID (com.epam.ta.reportportal.dao.constant.WidgetRepositoryConstants.ID)5 JooqFieldNameTransformer.fieldName (com.epam.ta.reportportal.dao.util.JooqFieldNameTransformer.fieldName)5 QueryUtils (com.epam.ta.reportportal.dao.util.QueryUtils)5 RecordMappers (com.epam.ta.reportportal.dao.util.RecordMappers)5