Search in sources :

Example 1 with WidgetPreviewRQ

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"));
}
Also used : WidgetPreviewRQ(com.epam.ta.reportportal.ws.model.widget.WidgetPreviewRQ) AbstractMap(java.util.AbstractMap) HashMap(java.util.HashMap) Widget(com.epam.ta.reportportal.entity.widget.Widget) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters) Test(org.junit.jupiter.api.Test)

Example 2 with WidgetPreviewRQ

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());
}
Also used : WidgetPreviewRQ(com.epam.ta.reportportal.ws.model.widget.WidgetPreviewRQ) HashMap(java.util.HashMap) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Aggregations

ContentParameters (com.epam.ta.reportportal.ws.model.widget.ContentParameters)2 WidgetPreviewRQ (com.epam.ta.reportportal.ws.model.widget.WidgetPreviewRQ)2 HashMap (java.util.HashMap)2 Test (org.junit.jupiter.api.Test)2 Widget (com.epam.ta.reportportal.entity.widget.Widget)1 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)1 AbstractMap (java.util.AbstractMap)1