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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations