use of com.epam.ta.reportportal.commons.querygen.FilterCondition in project commons-dao by reportportal.
the class WidgetContentRepositoryTest method activityStatistics.
@Test
void activityStatistics() {
Filter filter = buildDefaultActivityFilter(1L);
Sort sort = Sort.by(Lists.newArrayList(new Sort.Order(Sort.Direction.DESC, CRITERIA_CREATION_DATE)));
List<String> contentFields = buildActivityContentFields();
filter.withCondition(new FilterCondition(Condition.EQUALS, false, "superadmin", CRITERIA_USER)).withCondition(new FilterCondition(Condition.IN, false, String.join(",", contentFields), CRITERIA_ACTION));
List<ActivityResource> activityContentList = widgetContentRepository.activityStatistics(filter, sort, 4);
assertNotNull(activityContentList);
assertEquals(4, activityContentList.size());
}
use of com.epam.ta.reportportal.commons.querygen.FilterCondition 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.commons.querygen.FilterCondition in project commons-dao by reportportal.
the class WidgetContentRepositoryTest method activityStatisticsSorting.
@Test
void activityStatisticsSorting() {
Filter filter = buildDefaultActivityFilter(1L);
List<Sort.Order> orders = filter.getTarget().getCriteriaHolders().stream().map(ch -> new Sort.Order(Sort.Direction.ASC, ch.getFilterCriteria())).collect(Collectors.toList());
Sort sort = Sort.by(orders);
List<String> contentFields = buildActivityContentFields();
filter.withCondition(new FilterCondition(Condition.EQUALS, false, "superadmin", CRITERIA_USER)).withCondition(new FilterCondition(Condition.IN, false, String.join(",", contentFields), CRITERIA_ACTION));
List<ActivityResource> activityContentList = widgetContentRepository.activityStatistics(filter, sort, 4);
assertNotNull(activityContentList);
assertEquals(4, activityContentList.size());
}
use of com.epam.ta.reportportal.commons.querygen.FilterCondition 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.commons.querygen.FilterCondition 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));
});
}
Aggregations