Search in sources :

Example 1 with MIN_PASSING_RATE

use of com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.MIN_PASSING_RATE in project service-api by reportportal.

the class ComponentHealthCheckContentValidator method validateWidgetOptions.

private void validateWidgetOptions(WidgetOptions widgetOptions) {
    BusinessRule.expect(widgetOptions, Objects::nonNull).verify(ErrorType.UNABLE_LOAD_WIDGET_CONTENT, "Widgets options not provided");
    Integer passingRate = WidgetOptionUtil.getIntegerByKey(MIN_PASSING_RATE, widgetOptions).orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_LOAD_WIDGET_CONTENT, "Minimum passing rate option was not specified"));
    BusinessRule.expect(passingRate, v -> v >= 0 && v <= 100).verify(ErrorType.UNABLE_LOAD_WIDGET_CONTENT, "Minimum passing rate value should be greater or equal to 0 and less or equal to 100");
}
Also used : BusinessRule(com.epam.ta.reportportal.commons.validation.BusinessRule) WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) java.util(java.util) Optional.ofNullable(java.util.Optional.ofNullable) Filter(com.epam.ta.reportportal.commons.querygen.Filter) WidgetOptionUtil(com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) ATTRIBUTE_KEYS(com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.ATTRIBUTE_KEYS) Sort(org.springframework.data.domain.Sort) MIN_PASSING_RATE(com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.MIN_PASSING_RATE) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException)

Aggregations

Filter (com.epam.ta.reportportal.commons.querygen.Filter)1 BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)1 ATTRIBUTE_KEYS (com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.ATTRIBUTE_KEYS)1 MIN_PASSING_RATE (com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.MIN_PASSING_RATE)1 WidgetOptionUtil (com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil)1 WidgetOptions (com.epam.ta.reportportal.entity.widget.WidgetOptions)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)1 java.util (java.util)1 Optional.ofNullable (java.util.Optional.ofNullable)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Sort (org.springframework.data.domain.Sort)1 Service (org.springframework.stereotype.Service)1