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