Search in sources :

Example 1 with GenerateWidgetViewEvent

use of com.epam.ta.reportportal.core.events.widget.GenerateWidgetViewEvent in project service-api by reportportal.

the class CreatedMaterializedWidgetStateHandler method handleWidgetState.

@Override
public Map<String, Object> handleWidgetState(Widget widget, MultiValueMap<String, String> params) {
    widgetRepository.save(new WidgetBuilder(widget).addOption(STATE, WidgetState.RENDERING.getValue()).get());
    eventPublisher.publishEvent(new GenerateWidgetViewEvent(widget.getId(), params));
    return emptyMap();
}
Also used : GenerateWidgetViewEvent(com.epam.ta.reportportal.core.events.widget.GenerateWidgetViewEvent) WidgetBuilder(com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder)

Example 2 with GenerateWidgetViewEvent

use of com.epam.ta.reportportal.core.events.widget.GenerateWidgetViewEvent in project service-api by reportportal.

the class ComponentHealthCheckTableEventHandlerTest method shouldGenerate.

@Test
void shouldGenerate() {
    Widget widget = getWidget();
    when(widgetRepository.findById(anyLong())).thenReturn(Optional.of(widget));
    Map<Filter, Sort> filterSortMap = new HashMap<>();
    Filter filter = Filter.builder().withTarget(Widget.class).withCondition(FilterCondition.builder().eq("id", "1").build()).build();
    Sort sort = Sort.unsorted();
    filterSortMap.put(filter, sort);
    when(buildFilterStrategy.buildFilter(widget)).thenReturn(filterSortMap);
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.put(REFRESH, Collections.singletonList(Boolean.FALSE.toString()));
    GenerateWidgetViewEvent event = new GenerateWidgetViewEvent(1L, params);
    generateWidgetViewEventHandler.onApplicationEvent(event);
    healthCheckTableExecutor.shutdown();
    verify(healthCheckTableGenerator, times(1)).generate(anyBoolean(), anyString(), any(Widget.class), any(Filter.class), any(Sort.class), any(MultiValueMap.class));
}
Also used : Filter(com.epam.ta.reportportal.commons.querygen.Filter) HashMap(java.util.HashMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Widget(com.epam.ta.reportportal.entity.widget.Widget) Sort(org.springframework.data.domain.Sort) GenerateWidgetViewEvent(com.epam.ta.reportportal.core.events.widget.GenerateWidgetViewEvent) MultiValueMap(org.springframework.util.MultiValueMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Test(org.junit.jupiter.api.Test)

Aggregations

GenerateWidgetViewEvent (com.epam.ta.reportportal.core.events.widget.GenerateWidgetViewEvent)2 Filter (com.epam.ta.reportportal.commons.querygen.Filter)1 Widget (com.epam.ta.reportportal.entity.widget.Widget)1 WidgetBuilder (com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1 Sort (org.springframework.data.domain.Sort)1 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)1 MultiValueMap (org.springframework.util.MultiValueMap)1