Search in sources :

Example 1 with SortEntry

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

Widget (com.epam.ta.reportportal.entity.widget.Widget)1 HealthCheckTableContent (com.epam.ta.reportportal.entity.widget.content.healthcheck.HealthCheckTableContent)1 WidgetBuilder (com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder)1 ContentParameters (com.epam.ta.reportportal.ws.model.widget.ContentParameters)1 SortEntry (com.epam.ta.reportportal.ws.model.widget.SortEntry)1 WidgetRQ (com.epam.ta.reportportal.ws.model.widget.WidgetRQ)1 Test (org.junit.jupiter.api.Test)1 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)1