Search in sources :

Example 11 with WidgetRequest

use of org.entando.entando.web.widget.model.WidgetRequest in project entando-core by entando.

the class WidgetServiceTest method shouldAddNewWidget.

@Test
public void shouldAddNewWidget() throws Exception {
    // Given
    WidgetRequest widgetRequest = getWidgetRequest1();
    when(groupManager.getGroup(widgetRequest.getGroup())).thenReturn(mock(Group.class));
    // When
    WidgetDto widgetDto = widgetService.addWidget(widgetRequest);
    // Then
    ArgumentCaptor<WidgetType> argumentCaptor = ArgumentCaptor.forClass(WidgetType.class);
    verify(widgetManager).addWidgetType(argumentCaptor.capture());
    WidgetType argument = argumentCaptor.getValue();
    assertThat(argument.getCode()).isEqualTo(widgetRequest.getCode());
    assertThat(argument.getConfigUi()).isEqualTo(objectMapper.writeValueAsString(widgetRequest.getConfigUi()));
    assertThat(argument.getBundleId()).isEqualTo(widgetRequest.getBundleId());
    assertThat(widgetDto.getCode()).isEqualTo(widgetRequest.getCode());
    assertThat(widgetDto.getConfigUi()).isEqualTo(widgetRequest.getConfigUi());
    assertThat(widgetDto.getBundleId()).isEqualTo(widgetRequest.getBundleId());
}
Also used : Group(com.agiletec.aps.system.services.group.Group) WidgetRequest(org.entando.entando.web.widget.model.WidgetRequest) WidgetDto(org.entando.entando.aps.system.services.widgettype.model.WidgetDto) Test(org.junit.Test)

Aggregations

WidgetRequest (org.entando.entando.web.widget.model.WidgetRequest)11 Test (org.junit.Test)7 UserDetails (com.agiletec.aps.system.services.user.UserDetails)5 HashMap (java.util.HashMap)5 AbstractControllerIntegrationTest (org.entando.entando.web.AbstractControllerIntegrationTest)5 ResultActions (org.springframework.test.web.servlet.ResultActions)5 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)3 Group (com.agiletec.aps.system.services.group.Group)2 WidgetDto (org.entando.entando.aps.system.services.widgettype.model.WidgetDto)2 PageRequest (org.entando.entando.web.page.model.PageRequest)2 WidgetConfigurationRequest (org.entando.entando.web.page.model.WidgetConfigurationRequest)2