use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class BugTrendChartContentValidatorTest 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());
bugTrendChartContentValidator.validate(Collections.singletonList("statistics$defects$automation_bug$total'"), filterSortMap, new WidgetOptions(), 5);
});
String expectedMessage = "Bad content fields format";
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 ChartInvestigatedContentValidatorTest method testValidateWithException.
@Test
public void testValidateWithException() {
Exception exception = assertThrows(ReportPortalException.class, () -> {
chartInvestigatedContentValidator.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 WidgetBuilder method addOption.
public WidgetBuilder addOption(String key, Object value) {
WidgetOptions widgetOptions = ofNullable(widget.getWidgetOptions()).orElseGet(() -> {
WidgetOptions opts = new WidgetOptions();
widget.setWidgetOptions(opts);
return opts;
});
Map<String, Object> options = ofNullable(widgetOptions.getOptions()).orElseGet(() -> {
LinkedHashMap<String, Object> opts = new LinkedHashMap<>();
widgetOptions.setOptions(opts);
return opts;
});
options.put(key, value);
return this;
}
use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.
the class WidgetBuilder method addWidgetRq.
public WidgetBuilder addWidgetRq(WidgetRQ widgetRQ) {
ofNullable(widgetRQ.getName()).ifPresent(name -> widget.setName(name));
ofNullable(widgetRQ.getShare()).ifPresent(it -> widget.setShared(it));
widget.setDescription(widgetRQ.getDescription());
ofNullable(widgetRQ.getContentParameters().getWidgetOptions()).ifPresent(wo -> {
WidgetOptions widgetOptions = ofNullable(widget.getWidgetOptions()).orElseGet(WidgetOptions::new);
Map<String, Object> options = ofNullable(widgetOptions.getOptions()).orElseGet(LinkedHashMap::new);
options.putAll(wo);
widgetOptions.setOptions(options);
widget.setWidgetOptions(widgetOptions);
});
widget.setWidgetType(widgetRQ.getWidgetType());
widget.setItemsCount(widgetRQ.getContentParameters().getItemsCount());
widget.getContentFields().clear();
widget.getContentFields().addAll(ofNullable(widgetRQ.getContentParameters().getContentFields()).orElse(Collections.emptyList()));
return this;
}
Aggregations