use of com.epam.ta.reportportal.ws.model.widget.WidgetPreviewRQ in project service-api by reportportal.
the class WidgetBuilderTest method addWidgetPreviewRqTest.
@Test
void addWidgetPreviewRqTest() {
final WidgetPreviewRQ previewRQ = new WidgetPreviewRQ();
final ContentParameters contentParameters = new ContentParameters();
contentParameters.setContentFields(Collections.singletonList("contentField"));
contentParameters.setItemsCount(10);
final HashMap<String, Object> widgetOptions = new HashMap<>();
widgetOptions.put("param", "val");
contentParameters.setWidgetOptions(widgetOptions);
previewRQ.setContentParameters(contentParameters);
final String widgetType = "oldLineChart";
previewRQ.setWidgetType(widgetType);
final Widget widget = new WidgetBuilder(new Widget()).addWidgetPreviewRq(previewRQ).get();
assertEquals(widgetType, widget.getWidgetType());
assertThat(widget.getContentFields()).containsExactly("contentField");
assertThat(widget.getWidgetOptions().getOptions()).containsExactly(new AbstractMap.SimpleEntry<>("param", "val"));
}
use of com.epam.ta.reportportal.ws.model.widget.WidgetPreviewRQ in project service-api by reportportal.
the class WidgetControllerTest method getWidgetPreview.
@Test
void getWidgetPreview() throws Exception {
WidgetPreviewRQ request = new WidgetPreviewRQ();
request.setWidgetType("launchStatistics");
final ContentParameters contentParameters = new ContentParameters();
final HashMap<String, Object> widgetOptions = new HashMap<>();
widgetOptions.put("timeline", "WEEK");
contentParameters.setWidgetOptions(widgetOptions);
contentParameters.setItemsCount(20);
contentParameters.setContentFields(Arrays.asList("statistics$executions$total", "statistics$executions$passed", "statistics$executions$failed", "statistics$executions$skipped"));
request.setContentParameters(contentParameters);
request.setFilterIds(Collections.singletonList(4L));
mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + "/widget/preview").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
}
Aggregations