use of com.epam.ta.reportportal.ws.model.activity.DashboardActivityResource in project service-api by reportportal.
the class DashboardConverterTest method toActivityResource.
@Test
void toActivityResource() {
final Dashboard dashboard = getDashboard();
final DashboardActivityResource activityResource = DashboardConverter.TO_ACTIVITY_RESOURCE.apply(dashboard);
assertEquals(activityResource.getId(), dashboard.getId());
assertEquals(activityResource.getName(), dashboard.getName());
assertEquals(activityResource.getDescription(), dashboard.getDescription());
assertEquals(activityResource.getProjectId(), dashboard.getProject().getId());
assertEquals(activityResource.isShared(), dashboard.isShared());
}
use of com.epam.ta.reportportal.ws.model.activity.DashboardActivityResource in project service-api by reportportal.
the class UpdateDashboardHandlerImpl method updateDashboard.
@Override
public OperationCompletionRS updateDashboard(ReportPortalUser.ProjectDetails projectDetails, UpdateDashboardRQ rq, Long dashboardId, ReportPortalUser user) {
Dashboard dashboard = getShareableDashboardHandler.getAdministrated(dashboardId, projectDetails);
DashboardActivityResource before = TO_ACTIVITY_RESOURCE.apply(dashboard);
if (!dashboard.getName().equals(rq.getName())) {
BusinessRule.expect(dashboardRepository.existsByNameAndOwnerAndProjectId(rq.getName(), user.getUsername(), projectDetails.getProjectId()), BooleanUtils::isFalse).verify(ErrorType.RESOURCE_ALREADY_EXISTS, rq.getName());
}
dashboard = new DashboardBuilder(dashboard).addUpdateRq(rq).get();
dashboardRepository.save(dashboard);
if (before.isShared() != dashboard.isShared()) {
aclHandler.updateAcl(dashboard, projectDetails.getProjectId(), dashboard.isShared());
updateWidgetHandler.updateSharing(dashboard.getDashboardWidgets().stream().map(DashboardWidget::getWidget).collect(Collectors.toList()), projectDetails.getProjectId(), dashboard.isShared());
}
messageBus.publishActivity(new DashboardUpdatedEvent(before, TO_ACTIVITY_RESOURCE.apply(dashboard), user.getUserId(), user.getUsername()));
return new OperationCompletionRS("Dashboard with ID = '" + dashboard.getId() + "' successfully updated");
}
use of com.epam.ta.reportportal.ws.model.activity.DashboardActivityResource in project service-api by reportportal.
the class DashboardEventsTest method getTestDashboard.
private static DashboardActivityResource getTestDashboard(String name, boolean shared, String description) {
DashboardActivityResource dashboard = new DashboardActivityResource();
dashboard.setShared(shared);
dashboard.setDescription(description);
dashboard.setProjectId(3L);
dashboard.setName(name);
dashboard.setId(2L);
return dashboard;
}
Aggregations