use of com.epam.ta.reportportal.ws.model.activity.WidgetActivityResource in project service-api by reportportal.
the class WidgetEventsTest method getWidget.
private static WidgetActivityResource getWidget(String name, boolean shared, String description, int itemsCount, Set<String> contentFields) {
WidgetActivityResource widget = new WidgetActivityResource();
widget.setName(name);
widget.setId(2L);
widget.setDescription(description);
widget.setShared(shared);
widget.setProjectId(3L);
widget.setItemsCount(itemsCount);
widget.setContentFields(contentFields);
return widget;
}
use of com.epam.ta.reportportal.ws.model.activity.WidgetActivityResource in project service-api by reportportal.
the class WidgetConverterTest method toActivityResource.
@Test
void toActivityResource() {
final Widget widget = getWidget();
final WidgetActivityResource resource = WidgetConverter.TO_ACTIVITY_RESOURCE.apply(widget);
assertEquals(resource.getId(), widget.getId());
assertEquals(resource.getName(), widget.getName());
assertEquals(resource.getProjectId(), widget.getProject().getId());
assertEquals(resource.getDescription(), widget.getDescription());
assertEquals(resource.getItemsCount(), widget.getItemsCount());
assertEquals(resource.getContentFields(), widget.getContentFields());
assertThat(resource.getWidgetOptions()).containsAllEntriesOf(widget.getWidgetOptions().getOptions());
}
use of com.epam.ta.reportportal.ws.model.activity.WidgetActivityResource in project service-api by reportportal.
the class UpdateWidgetHandlerImpl method updateWidget.
@Override
public OperationCompletionRS updateWidget(Long widgetId, WidgetRQ updateRQ, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
Widget widget = getShareableEntityHandler.getAdministrated(widgetId, projectDetails);
widgetContentFieldsValidator.validate(widget);
if (!widget.getName().equals(updateRQ.getName())) {
BusinessRule.expect(widgetRepository.existsByNameAndOwnerAndProjectId(updateRQ.getName(), user.getUsername(), projectDetails.getProjectId()), BooleanUtils::isFalse).verify(ErrorType.RESOURCE_ALREADY_EXISTS, updateRQ.getName());
}
WidgetActivityResource before = TO_ACTIVITY_RESOURCE.apply(widget);
List<UserFilter> userFilter = getUserFilters(updateRQ.getFilterIds(), projectDetails.getProjectId(), user.getUsername());
String widgetOptionsBefore = parseWidgetOptions(widget);
updateSharing(widget, projectDetails.getProjectId(), updateRQ.getShare());
widget = new WidgetBuilder(widget).addWidgetRq(updateRQ).addFilters(userFilter).get();
widgetRepository.save(widget);
messageBus.publishActivity(new WidgetUpdatedEvent(before, TO_ACTIVITY_RESOURCE.apply(widget), widgetOptionsBefore, parseWidgetOptions(widget), user.getUserId(), user.getUsername()));
return new OperationCompletionRS("Widget with ID = '" + widget.getId() + "' successfully updated.");
}
Aggregations