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());
}
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());
}
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;
}
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());
}
Aggregations