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());
}
Aggregations