use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class TopPatternContentValidatorTest method testValidateWithException.
@Test
public void testValidateWithException() {
Exception exception = assertThrows(ReportPortalException.class, () -> {
topPatternContentValidator.validate(Collections.singletonList("test"), new HashMap<>(), new WidgetOptions(), new String[] {}, new HashMap<>(), 5);
});
String expectedMessage = "Filter-Sort mapping should not be empty";
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class LaunchesDurationContentValidatorTest method testValidateWithException.
@Test
public void testValidateWithException() {
Exception exception = assertThrows(ReportPortalException.class, () -> {
launchesDurationContentValidator.validate(Collections.singletonList("test"), new HashMap<>(), new WidgetOptions(), 5);
});
String expectedMessage = "Filter-Sort mapping should not be empty";
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class ComponentHealthCheckContentLoader method loadContent.
@Override
public Map<String, Object> loadContent(List<String> contentFields, Map<Filter, Sort> filterSortMapping, WidgetOptions widgetOptions, String[] attributes, MultiValueMap<String, String> params, int limit) {
List<String> attributeKeys = WidgetOptionUtil.getListByKey(ATTRIBUTE_KEYS, widgetOptions);
List<String> attributeValues = ofNullable(attributes).map(Arrays::asList).orElseGet(Collections::emptyList);
int currentLevel = attributeValues.size();
BusinessRule.expect(attributeKeys, keys -> keys.size() > currentLevel).verify(ErrorType.UNABLE_LOAD_WIDGET_CONTENT, "Incorrect level definition");
Filter launchesFilter = GROUP_FILTERS.apply(filterSortMapping.keySet());
Sort launchesSort = GROUP_SORTS.apply(filterSortMapping.values());
boolean latestMode = WidgetOptionUtil.getBooleanByKey(LATEST_OPTION, widgetOptions);
Filter testItemFilter = Filter.builder().withTarget(TestItem.class).withCondition(getTestItemCondition(attributeKeys, attributeValues)).build();
String currentLevelKey = attributeKeys.get(currentLevel);
List<ComponentHealthCheckContent> content = widgetContentRepository.componentHealthCheck(launchesFilter, launchesSort, latestMode, limit, testItemFilter, currentLevelKey);
return CollectionUtils.isNotEmpty(content) ? Collections.singletonMap(RESULT, content) : emptyMap();
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class MaterializedViewContentRemover method validateState.
private void validateState(WidgetOptions widgetOptions) {
WidgetState widgetState = ofNullable(WidgetOptionUtil.getValueByKey(STATE, widgetOptions)).flatMap(WidgetState::findByName).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_UPDATE_WIDGET_REQUEST, "Widget state not provided"));
BusinessRule.expect(widgetState, it -> !WidgetState.RENDERING.equals(it)).verify(ErrorType.BAD_UPDATE_WIDGET_REQUEST, "Unable to remove widget in 'rendering' state");
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class CasesTrendContentValidatorTest 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());
casesTrendContentValidator.validate(Collections.singletonList("test"), filterSortMap, new WidgetOptions(), 5);
});
String expectedMessage = "Bad content fields format";
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
Aggregations