use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class TopTestCasesContentLoader method loadContent.
@Override
public Map<String, ?> loadContent(List<String> contentFields, Map<Filter, Sort> filterSortMapping, WidgetOptions widgetOptions, int limit) {
String criteria = contentFields.get(0);
Filter filter = GROUP_FILTERS.apply(filterSortMapping.keySet()).withCondition(new FilterCondition(Condition.EQUALS, false, WidgetOptionUtil.getValueByKey(LAUNCH_NAME_FIELD, widgetOptions), CRITERIA_NAME));
return launchRepository.findLatestByFilter(filter).map(it -> Pair.of(it, widgetContentRepository.topItemsByCriteria(filter, criteria, limit, ofNullable(widgetOptions.getOptions().get(INCLUDE_METHODS)).map(v -> BooleanUtils.toBoolean(String.valueOf(v))).orElse(false)))).filter(it -> !it.getRight().isEmpty()).map(it -> (Map<String, ?>) ImmutableMap.<String, Object>builder().put(LATEST_LAUNCH, launchConverter.TO_RESOURCE.apply(it.getLeft())).put(RESULT, it.getRight()).build()).orElse(Collections.emptyMap());
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class HealthCheckTableReadyContentLoader method getParams.
private HealthCheckTableGetParams getParams(WidgetOptions widgetOptions, List<String> attributeValues) {
List<String> attributeKeys = WidgetOptionUtil.getListByKey(ATTRIBUTE_KEYS, widgetOptions);
int currentLevel = attributeValues.size();
BusinessRule.expect(attributeKeys, keys -> keys.size() > currentLevel).verify(ErrorType.UNABLE_LOAD_WIDGET_CONTENT, "Incorrect level definition");
String viewName = ofNullable(WidgetOptionUtil.getValueByKey(VIEW_NAME, widgetOptions)).orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_LOAD_WIDGET_CONTENT, "Widget view name not provided"));
String currentLevelKey = attributeKeys.get(currentLevel);
boolean includeCustomColumn = ofNullable(WidgetOptionUtil.getValueByKey(CUSTOM_COLUMN, widgetOptions)).isPresent();
return HealthCheckTableGetParams.of(viewName, currentLevelKey, resolveSort(widgetOptions), includeCustomColumn, getLevelEntries(attributeKeys, attributeValues));
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class ComponentHealthCheckContentValidator method validateWidgetOptions.
private void validateWidgetOptions(WidgetOptions widgetOptions) {
BusinessRule.expect(widgetOptions, Objects::nonNull).verify(ErrorType.UNABLE_LOAD_WIDGET_CONTENT, "Widgets options not provided");
Integer passingRate = WidgetOptionUtil.getIntegerByKey(MIN_PASSING_RATE, widgetOptions).orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_LOAD_WIDGET_CONTENT, "Minimum passing rate option was not specified"));
BusinessRule.expect(passingRate, v -> v >= 0 && v <= 100).verify(ErrorType.UNABLE_LOAD_WIDGET_CONTENT, "Minimum passing rate value should be greater or equal to 0 and less or equal to 100");
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class WidgetConverterTest method getWidget.
private Widget getWidget() {
final Widget widget = new Widget();
widget.setDescription("description");
widget.setItemsCount(10);
widget.setWidgetType("widgetType");
widget.setName("name");
widget.setShared(true);
final Project project = new Project();
project.setId(3L);
widget.setProject(project);
final WidgetOptions widgetOptions = new WidgetOptions();
final HashMap<String, Object> options = new HashMap<>();
options.put("option1", "val1");
options.put("option2", "val2");
widgetOptions.setOptions(options);
widget.setWidgetOptions(widgetOptions);
final UserFilter filter = new UserFilter();
filter.setId(1L);
filter.setOwner("owner");
filter.setName("name");
filter.setTargetClass(ObjectType.Launch);
filter.setDescription("filter description");
filter.setFilterCondition(Sets.newHashSet(FilterCondition.builder().eq(CRITERIA_LAUNCH_ID, "100").build()));
widget.setFilters(Sets.newHashSet(filter));
final FilterSort filterSort = new FilterSort();
filterSort.setField("name");
filterSort.setDirection(Sort.Direction.ASC);
filterSort.setId(2L);
filter.setFilterSorts(Sets.newHashSet(filterSort));
return widget;
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class LaunchesTableContentValidatorTest method testValidateWithException.
@Test
public void testValidateWithException() {
Exception exception = assertThrows(ReportPortalException.class, () -> {
HashMap<Filter, Sort> filterSortMap = new HashMap<>();
filterSortMap.put(Filter.builder().withTarget(Launch.class).withCondition(FilterCondition.builder().eq("id", "1").build()).build(), Sort.unsorted());
launchesTableContentValidator.validate(new ArrayList<>(), filterSortMap, new WidgetOptions(), 5);
});
String expectedMessage = "Content fields should not be empty";
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
Aggregations