Search in sources :

Example 16 with WidgetOptions

use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.

the class UniqueBugContentValidatorTest method testValidateWithException.

@Test
public void testValidateWithException() {
    Exception exception = assertThrows(ReportPortalException.class, () -> {
        uniqueBugContentValidator.validate(Collections.singletonList("test"), new HashMap<>(), new WidgetOptions(), 5);
    });
    String expectedMessage = "Filter-Sort mapping should not be empty";
    String actualMessage = exception.getMessage();
    assertTrue(actualMessage.contains(expectedMessage));
}
Also used : WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Test(org.junit.jupiter.api.Test)

Example 17 with WidgetOptions

use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.

the class WidgetOptionUtilTest method getStringValueWhenCorrectTypeTest.

@Test
void getStringValueWhenCorrectTypeTest() {
    // given
    WidgetOptions widgetOptions = new WidgetOptions(getMapWithStringValues());
    // when
    String value = WidgetOptionUtil.getValueByKey(FIRST_KEY, widgetOptions);
    // then
    assertNotNull(value);
    assertEquals(FIRST_STRING_VALUE, value);
}
Also used : WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) Test(org.junit.jupiter.api.Test)

Example 18 with WidgetOptions

use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.

the class WidgetOptionUtilTest method throwExceptionWhenGetMapValueWithInCorrectTypeTest.

@Test
void throwExceptionWhenGetMapValueWithInCorrectTypeTest() {
    // given
    WidgetOptions widgetOptions = new WidgetOptions(getMapWithStringValues());
    // when //then throw exception
    assertThrows(ReportPortalException.class, () -> WidgetOptionUtil.getMapByKey(FIRST_KEY, widgetOptions));
}
Also used : WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) Test(org.junit.jupiter.api.Test)

Example 19 with WidgetOptions

use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.

the class MostTimeConsumingContentValidatorTest method testValidateWithException.

@Test
public void testValidateWithException() {
    Exception exception = assertThrows(ReportPortalException.class, () -> {
        HashMap<Filter, Sort> filterSortMap = new HashMap<>();
        filterSortMap.put(Filter.builder().withTarget(Launch.class).withCondition(FilterCondition.builder().eq("id", "1").build()).build(), Sort.unsorted());
        Map<String, Object> params = new HashMap<>();
        params.put(LAUNCH_NAME_FIELD, "");
        WidgetOptions widgetOptions = new WidgetOptions();
        mostTimeConsumingContentValidator.validate(Collections.singletonList("test"), filterSortMap, widgetOptions, 5);
    });
    String expectedMessage = LAUNCH_NAME_FIELD + " should be specified for widget.";
    String actualMessage = exception.getMessage();
    assertTrue(actualMessage.contains(expectedMessage));
}
Also used : Filter(com.epam.ta.reportportal.commons.querygen.Filter) HashMap(java.util.HashMap) WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) Sort(org.springframework.data.domain.Sort) Launch(com.epam.ta.reportportal.entity.launch.Launch) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Test(org.junit.jupiter.api.Test)

Example 20 with WidgetOptions

use of com.epam.ta.reportportal.entity.widget.WidgetOptions in project service-api by reportportal.

the class PassingRatePerLaunchContentValidatorTest method testValidateWithException.

@Test
public void testValidateWithException() {
    Exception exception = assertThrows(ReportPortalException.class, () -> {
        HashMap<Filter, Sort> filterSortMap = new HashMap<>();
        filterSortMap.put(Filter.builder().withTarget(Launch.class).withCondition(FilterCondition.builder().eq("id", "1").build()).build(), Sort.unsorted());
        Map<String, Object> params = new HashMap<>();
        params.put(LAUNCH_NAME_FIELD, "");
        WidgetOptions widgetOptions = new WidgetOptions();
        passingRatePerLaunchContentValidator.validate(Collections.singletonList("test"), filterSortMap, widgetOptions, 5);
    });
    String expectedMessage = LAUNCH_NAME_FIELD + " should be specified for widget.";
    String actualMessage = exception.getMessage();
    assertTrue(actualMessage.contains(expectedMessage));
}
Also used : Filter(com.epam.ta.reportportal.commons.querygen.Filter) HashMap(java.util.HashMap) WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) Sort(org.springframework.data.domain.Sort) Launch(com.epam.ta.reportportal.entity.launch.Launch) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Test(org.junit.jupiter.api.Test)

Aggregations

WidgetOptions (com.epam.ta.reportportal.entity.widget.WidgetOptions)34 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)20 Test (org.junit.jupiter.api.Test)20 Sort (org.springframework.data.domain.Sort)15 Filter (com.epam.ta.reportportal.commons.querygen.Filter)13 WidgetOptionUtil (com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil)10 Launch (com.epam.ta.reportportal.entity.launch.Launch)10 HashMap (java.util.HashMap)10 Optional.ofNullable (java.util.Optional.ofNullable)10 WidgetContentRepository (com.epam.ta.reportportal.dao.WidgetContentRepository)8 Map (java.util.Map)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 Service (org.springframework.stereotype.Service)7 ContentLoaderConstants (com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants)6 GROUP_FILTERS (com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_FILTERS)6 List (java.util.List)6 CollectionUtils (org.apache.commons.collections.CollectionUtils)6 BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)5 LoadContentStrategy (com.epam.ta.reportportal.core.widget.content.LoadContentStrategy)5 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)5