Search in sources :

Example 1 with ContentParameters

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

the class WidgetControllerTest method updateNonExistingWidget.

@Test
void updateNonExistingWidget() throws Exception {
    WidgetRQ rq = new WidgetRQ();
    rq.setName("name");
    rq.setWidgetType("oldLineChart");
    rq.setShare(false);
    var contextParams = new ContentParameters();
    contextParams.setItemsCount(1);
    contextParams.setContentFields(Collections.singletonList("test"));
    rq.setContentParameters(contextParams);
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/widget/100").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON)).andExpect(status().isNotFound());
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 2 with ContentParameters

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

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

the class WidgetControllerTest method updateWidgetWithDuplicatedName.

@Test
void updateWidgetWithDuplicatedName() throws Exception {
    final WidgetRQ rq = new WidgetRQ();
    rq.setName("LAUNCH STATISTICS");
    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(SUPERADMIN_PROJECT_BASE_URL + "/widget/5").with(token(oAuthHelper.getSuperadminToken())).content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON)).andExpect(status().isConflict());
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 4 with ContentParameters

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

the class WidgetControllerTest method createWidgetPositive.

@Test
void createWidgetPositive() throws Exception {
    WidgetRQ rq = new WidgetRQ();
    rq.setName("widget");
    rq.setDescription("description");
    rq.setWidgetType("oldLineChart");
    ContentParameters contentParameters = new ContentParameters();
    contentParameters.setContentFields(Collections.singletonList("statistics$executions$passed"));
    contentParameters.setItemsCount(50);
    rq.setFilterIds(Collections.singletonList(3L));
    rq.setContentParameters(contentParameters);
    rq.setShare(true);
    final MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + "/widget").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON)).andExpect(status().isCreated()).andReturn();
    final EntryCreatedRS entryCreatedRS = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), EntryCreatedRS.class);
    final Optional<Widget> optionalWidget = widgetRepository.findById(entryCreatedRS.getId());
    assertTrue(optionalWidget.isPresent());
    assertEquals("widget", optionalWidget.get().getName());
    assertEquals("description", optionalWidget.get().getDescription());
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) Widget(com.epam.ta.reportportal.entity.widget.Widget) EntryCreatedRS(com.epam.ta.reportportal.ws.model.EntryCreatedRS) MvcResult(org.springframework.test.web.servlet.MvcResult) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 5 with ContentParameters

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

the class WidgetBuilderTest method widgetBuilderTest.

@Test
void widgetBuilderTest() {
    final WidgetRQ widgetRQ = new WidgetRQ();
    final String name = "name";
    widgetRQ.setName(name);
    final String description = "description";
    widgetRQ.setDescription(description);
    final boolean share = true;
    widgetRQ.setShare(share);
    final String widgetType = "oldLineChart";
    widgetRQ.setWidgetType(widgetType);
    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);
    widgetRQ.setContentParameters(contentParameters);
    final String owner = "owner";
    final UserFilter userFilter = new UserFilter();
    userFilter.setId(1L);
    final Widget widget = new WidgetBuilder().addWidgetRq(widgetRQ).addFilters(Collections.singletonList(userFilter)).addOwner(owner).get();
    assertEquals(name, widget.getName());
    assertEquals(description, widget.getDescription());
    assertEquals(share, widget.isShared());
    assertEquals(owner, widget.getOwner());
    assertEquals(widgetType, widget.getWidgetType());
    assertThat(widget.getFilters()).containsExactly(userFilter);
    assertThat(widget.getContentFields()).containsExactly("contentField");
    assertThat(widget.getWidgetOptions().getOptions()).containsExactly(new AbstractMap.SimpleEntry<>("param", "val"));
}
Also used : AbstractMap(java.util.AbstractMap) HashMap(java.util.HashMap) WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) UserFilter(com.epam.ta.reportportal.entity.filter.UserFilter) Widget(com.epam.ta.reportportal.entity.widget.Widget) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters) 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