Search in sources :

Example 6 with ContentParameters

use of com.epam.ta.reportportal.ws.model.widget.ContentParameters in project service-api by reportportal.

the class WidgetControllerTest method updateWidgetPositive.

@Test
void updateWidgetPositive() throws Exception {
    final WidgetRQ rq = new WidgetRQ();
    rq.setName("updated");
    rq.setDescription("updated");
    rq.setWidgetType("activityStream");
    rq.setShare(false);
    final ContentParameters contentParameters = new ContentParameters();
    contentParameters.setContentFields(Arrays.asList("number", "start_time", "user"));
    contentParameters.setItemsCount(50);
    rq.setContentParameters(contentParameters);
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/widget/12").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON)).andExpect(status().isOk());
    final Optional<Widget> optionalWidget = widgetRepository.findById(12L);
    assertTrue(optionalWidget.isPresent());
    assertEquals("updated", optionalWidget.get().getName());
    assertEquals("updated", optionalWidget.get().getDescription());
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) Widget(com.epam.ta.reportportal.entity.widget.Widget) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 7 with ContentParameters

use of com.epam.ta.reportportal.ws.model.widget.ContentParameters 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)

Example 8 with ContentParameters

use of com.epam.ta.reportportal.ws.model.widget.ContentParameters in project service-api by reportportal.

the class WidgetControllerValidationTest method prepareWidget.

private WidgetRQ prepareWidget() {
    WidgetRQ widgetRQ = new WidgetRQ();
    widgetRQ.setDescription("description");
    widgetRQ.setWidgetType("oldLineChart");
    ContentParameters contentParameters = new ContentParameters();
    contentParameters.setContentFields(Arrays.asList("number", "name", "user", "statistics$defects$automation_bug$AB002"));
    contentParameters.setItemsCount(50);
    widgetRQ.setContentParameters(contentParameters);
    widgetRQ.setShare(true);
    return widgetRQ;
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters)

Example 9 with ContentParameters

use of com.epam.ta.reportportal.ws.model.widget.ContentParameters in project service-api by reportportal.

the class HealthCheckTableReadyContentResolverTest method getContentTest.

@Test
void getContentTest() {
    WidgetRQ widgetRQ = new WidgetRQ();
    widgetRQ.setName("name");
    widgetRQ.setWidgetType("componentHealthCheckTable");
    ContentParameters contentParameters = new ContentParameters();
    contentParameters.setContentFields(new ArrayList<>());
    contentParameters.setItemsCount(600);
    Map<String, Object> options = new HashMap<>();
    contentParameters.setWidgetOptions(options);
    widgetRQ.setContentParameters(contentParameters);
    widgetRQ.setFilterIds(Collections.singletonList(1L));
    widgetRQ.setDescription("descr");
    SortEntry sortEntry = new SortEntry();
    sortEntry.setSortingColumn("passingRate");
    Widget widget = new WidgetBuilder().addWidgetRq(widgetRQ).addOption("viewName", "name").addOption("sort", sortEntry).addOption(ATTRIBUTE_KEYS, Lists.newArrayList("k1", "k2")).get();
    HealthCheckTableContent content = new HealthCheckTableContent();
    content.setAttributeValue("v2");
    content.setPassingRate(50.00);
    HashMap<String, Integer> statistics = new HashMap<>();
    statistics.put(EXECUTIONS_PASSED, 5);
    statistics.put(EXECUTIONS_TOTAL, 10);
    content.setStatistics(statistics);
    when(widgetContentRepository.componentHealthCheckTable(any())).thenReturn(Lists.newArrayList(content));
    MultiValueMap<String, String> values = new LinkedMultiValueMap<>();
    values.put(ATTRIBUTES, Lists.newArrayList("v1"));
    Map<String, Object> result = contentResolver.loadContent(widget, values);
    List<HealthCheckTableContent> resultList = (List<HealthCheckTableContent>) result.get("result");
    HealthCheckTableContent tableContent = resultList.get(0);
    assertEquals(content.getPassingRate(), tableContent.getPassingRate());
    assertEquals(content.getAttributeValue(), tableContent.getAttributeValue());
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Widget(com.epam.ta.reportportal.entity.widget.Widget) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters) WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) HealthCheckTableContent(com.epam.ta.reportportal.entity.widget.content.healthcheck.HealthCheckTableContent) WidgetBuilder(com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder) SortEntry(com.epam.ta.reportportal.ws.model.widget.SortEntry) Test(org.junit.jupiter.api.Test)

Aggregations

ContentParameters (com.epam.ta.reportportal.ws.model.widget.ContentParameters)9 Test (org.junit.jupiter.api.Test)8 WidgetRQ (com.epam.ta.reportportal.ws.model.widget.WidgetRQ)7 Widget (com.epam.ta.reportportal.entity.widget.Widget)5 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)5 HashMap (java.util.HashMap)3 WidgetPreviewRQ (com.epam.ta.reportportal.ws.model.widget.WidgetPreviewRQ)2 AbstractMap (java.util.AbstractMap)2 UserFilter (com.epam.ta.reportportal.entity.filter.UserFilter)1 HealthCheckTableContent (com.epam.ta.reportportal.entity.widget.content.healthcheck.HealthCheckTableContent)1 WidgetBuilder (com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder)1 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)1 SortEntry (com.epam.ta.reportportal.ws.model.widget.SortEntry)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)1