use of com.epam.ta.reportportal.ws.model.dashboard.UpdateDashboardRQ in project service-api by reportportal.
the class DashboardBuilder method addUpdateRq.
public DashboardBuilder addUpdateRq(UpdateDashboardRQ rq) {
Optional.ofNullable(rq.getName()).ifPresent(name -> dashboard.setName(name));
Optional.ofNullable(rq.getDescription()).ifPresent(description -> dashboard.setDescription(description));
Optional.ofNullable(rq.getShare()).ifPresent(share -> dashboard.setShared(share));
Optional.ofNullable(rq.getWidgets()).ifPresent(widgets -> {
for (DashboardWidget dashboardWidget : dashboard.getDashboardWidgets()) {
widgets.stream().filter(updWidget -> Objects.equals(dashboardWidget.getId().getWidgetId(), updWidget.getWidgetId())).forEach(updWidget -> {
ofNullable(updWidget.getWidgetPosition()).ifPresent(position -> {
dashboardWidget.setPositionX(position.getX());
dashboardWidget.setPositionY(position.getY());
});
ofNullable(updWidget.getWidgetSize()).ifPresent(size -> {
dashboardWidget.setWidth(size.getWidth());
dashboardWidget.setHeight(size.getHeight());
});
});
}
});
return this;
}
use of com.epam.ta.reportportal.ws.model.dashboard.UpdateDashboardRQ in project service-api by reportportal.
the class DashboardControllerTest method updateDashboardPositive.
@Test
void updateDashboardPositive() throws Exception {
final UpdateDashboardRQ rq = new UpdateDashboardRQ();
rq.setName("updated");
rq.setDescription("updated");
rq.setShare(false);
mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/dashboard/17").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON)).andExpect(status().isOk());
final Optional<Dashboard> optionalDashboard = dashboardRepository.findById(17L);
assertTrue(optionalDashboard.isPresent());
assertEquals("updated", optionalDashboard.get().getName());
assertEquals("updated", optionalDashboard.get().getDescription());
assertFalse(optionalDashboard.get().isShared());
}
use of com.epam.ta.reportportal.ws.model.dashboard.UpdateDashboardRQ in project service-api by reportportal.
the class DashboardBuilderTest method updateDashboard.
@Test
void updateDashboard() {
final String name = "name";
final String description = "description";
final boolean share = true;
UpdateDashboardRQ updateDashboardRQ = new UpdateDashboardRQ();
updateDashboardRQ.setName(name);
updateDashboardRQ.setDescription(description);
updateDashboardRQ.setShare(share);
updateDashboardRQ.setWidgets(Collections.singletonList(new DashboardResource.WidgetObjectModel("kek", 1L, new Size(10, 20), new Position(30, 40))));
DashboardWidget dashboardWidget = new DashboardWidget();
dashboardWidget.setHeight(5);
dashboardWidget.setWidth(10);
dashboardWidget.setPositionX(1);
dashboardWidget.setPositionY(2);
dashboardWidget.setId(new DashboardWidgetId(1L, 1L));
final Dashboard existDashboard = new Dashboard();
existDashboard.addWidget(dashboardWidget);
final Dashboard dashboard = new DashboardBuilder(existDashboard).addUpdateRq(updateDashboardRQ).get();
assertEquals(name, dashboard.getName());
assertEquals(description, dashboard.getDescription());
assertEquals(share, dashboard.isShared());
}
Aggregations