use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class WidgetBuilder method addWidgetPreviewRq.
public WidgetBuilder addWidgetPreviewRq(WidgetPreviewRQ previewRQ) {
WidgetOptions widgetOptions = ofNullable(widget.getWidgetOptions()).orElseGet(WidgetOptions::new);
Map<String, Object> options = ofNullable(widgetOptions.getOptions()).orElseGet(LinkedHashMap::new);
options.putAll(previewRQ.getContentParameters().getWidgetOptions());
widgetOptions.setOptions(options);
widget.setWidgetOptions(widgetOptions);
widget.setWidgetType(previewRQ.getWidgetType());
widget.setItemsCount(previewRQ.getContentParameters().getItemsCount());
widget.getContentFields().clear();
widget.getContentFields().addAll(ofNullable(previewRQ.getContentParameters().getContentFields()).orElse(Collections.emptyList()));
return this;
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class MaterializedWidgetProviderHandlerImpl 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 WidgetOptionUtilTest method getMapValueWhenCorrectTypeTest.
@Test
void getMapValueWhenCorrectTypeTest() {
// given
WidgetOptions widgetOptions = new WidgetOptions(getMapWithNonStringValues());
// when
Map<String, String> mapByKey = WidgetOptionUtil.getMapByKey(FIRST_KEY, widgetOptions);
// then
assertNotNull(mapByKey);
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class WidgetOptionUtilTest method throwExceptionWhenGetStringValueWithInCorrectTypeTest.
@Test
void throwExceptionWhenGetStringValueWithInCorrectTypeTest() {
// given
WidgetOptions widgetOptions = new WidgetOptions(getMapWithNonStringValues());
// when //then throw exception
assertThrows(ReportPortalException.class, () -> WidgetOptionUtil.getValueByKey(FIRST_KEY, widgetOptions));
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class NotPassedTestsContentValidatorTest method testValidateWithException.
@Test
public void testValidateWithException() {
Exception exception = assertThrows(ReportPortalException.class, () -> {
notPassedTestsContentValidator.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));
}
Aggregations