Search in sources :

Example 11 with TestItemHistory

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

the class TestItemRepositoryTest method testItemHistoryPageWithLaunchFilterAndLaunchName.

@Test
void testItemHistoryPageWithLaunchFilterAndLaunchName() {
    Filter itemFilter = Filter.builder().withTarget(TestItem.class).withCondition(new FilterCondition(Condition.EQUALS, false, "FAILED", CRITERIA_STATUS)).build();
    Filter launchFilter = Filter.builder().withTarget(Launch.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(false, launchFilter, itemFilter, PageRequest.of(0, 5), PageRequest.of(0, 2, sort), 1L, "launch name 1", 5, true);
    assertTrue(testItemHistories.isEmpty());
    testItemHistories = testItemRepository.loadItemsHistoryPage(false, launchFilter, itemFilter, PageRequest.of(0, 5), PageRequest.of(0, 2, sort), 1L, "launch name 1", 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)

Example 12 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(boolean isLatest, Queryable launchFilter, Queryable testItemFilter, Pageable launchPageable, Pageable testItemPageable, Long projectId, int historyDepth, boolean usingHash) {
    SelectQuery<? extends Record> filteringQuery = buildCompositeFilterHistoryQuery(isLatest, launchFilter, testItemFilter, launchPageable, testItemPageable);
    Field<?> historyGroupingField = usingHash ? TEST_ITEM.TEST_CASE_HASH : TEST_ITEM.UNIQUE_ID;
    Page<String> historyBaseline = loadHistoryBaseline(filteringQuery, historyGroupingField, LAUNCH.PROJECT_ID.eq(projectId), testItemPageable);
    List<TestItemHistory> itemHistories = historyBaseline.getContent().stream().map(value -> {
        List<Long> itemIds = loadHistoryItem(getHistoryFilter(testItemFilter, usingHash, value), testItemPageable.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, testItemPageable, 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 13 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(boolean isLatest, Queryable launchFilter, Queryable testItemFilter, Pageable launchPageable, Pageable testItemPageable, Long projectId, String launchName, int historyDepth, boolean usingHash) {
    SelectQuery<? extends Record> filteringQuery = buildCompositeFilterHistoryQuery(isLatest, launchFilter, testItemFilter, launchPageable, testItemPageable);
    Field<?> historyGroupingField = usingHash ? TEST_ITEM.TEST_CASE_HASH : TEST_ITEM.UNIQUE_ID;
    Page<String> historyBaseline = loadHistoryBaseline(filteringQuery, historyGroupingField, LAUNCH.PROJECT_ID.eq(projectId).and(LAUNCH.NAME.eq(launchName)), testItemPageable);
    List<TestItemHistory> itemHistories = historyBaseline.getContent().stream().map(value -> {
        List<Long> itemIds = loadHistoryItem(getHistoryFilter(testItemFilter, usingHash, value), testItemPageable.getSort(), LAUNCH.PROJECT_ID.eq(projectId).and(LAUNCH.NAME.eq(launchName))).map(testItem -> getHistoryIds(testItem, usingHash, projectId, historyDepth - 1)).orElseGet(Collections::emptyList);
        return new TestItemHistory(value, itemIds);
    }).collect(Collectors.toList());
    return new PageImpl<>(itemHistories, testItemPageable, 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)

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