EnumEditorViewImpl extends KieEditorViewImpl implements EnumEditorView { @PostConstruct public void init() { final CellTable<EnumRow> cellTable = new CellTable<EnumRow>(Integer.MAX_VALUE); cellTable.setStriped(true); cellTable.setCondensed(true); cellTable.setBordered(true); cellTable.setEmptyTableWidget(new Label(EnumEditorConstants.INSTANCE.noEnumsDefined())); cellTable.setWidth("100%"); final VerticalPanel panel = new VerticalPanel(); panel.setWidth("100%"); final Column<EnumRow, String> factNameColumn = new Column<EnumRow, String>(new EnumEditTextCell()) { @Override public String getValue(final EnumRow enumRow) { if (enumRow.isValid()) { return enumRow.getFactName(); } return enumRow.getRaw(); } }; final Column<EnumRow, String> fieldNameColumn = new Column<EnumRow, String>(new EnumEditTextCell()) { @Override public String getValue(final EnumRow enumRow) { if (enumRow.isValid()) { return enumRow.getFieldName(); } return ""; } }; final Column<EnumRow, String> contextColumn = new Column<EnumRow, String>(new EnumEditTextCell()) { @Override public String getValue(final EnumRow enumRow) { if (enumRow.isValid()) { return enumRow.getContext(); } return ""; } }; final ButtonCell deleteEnumButton = new ButtonCell(IconType.MINUS, ButtonType.DANGER, ButtonSize.SMALL); final Column<EnumRow, String> deleteEnumColumn = new Column<EnumRow, String>(deleteEnumButton) { @Override public String getValue(final EnumRow global) { return EnumEditorConstants.INSTANCE.remove(); } }; factNameColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow enumRow, final String value) { enumRow.setFactName(value); } }); fieldNameColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow enumRow, final String value) { enumRow.setFieldName(value); } }); contextColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow enumRow, final String value) { enumRow.setContext(value); } }); deleteEnumColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow enumRow, final String value) { dataProvider.getList().remove(index); } }); cellTable.addColumn(factNameColumn, EnumEditorConstants.INSTANCE.FactColumnHeader()); cellTable.addColumn(fieldNameColumn, EnumEditorConstants.INSTANCE.FieldColumnHeader()); cellTable.addColumn(contextColumn, EnumEditorConstants.INSTANCE.ContextColumnHeader()); cellTable.addColumn(deleteEnumColumn); cellTable.setColumnWidth(deleteEnumColumn, 100.0, Style.Unit.PX); dataProvider.addDataDisplay(cellTable); addButton.setText(EnumEditorConstants.INSTANCE.AddEnum()); addButton.addClickHandler(clickEvent -> { final EnumRow enumRow = new EnumRow(); dataProvider.getList().add(enumRow); }); panel.add(addButton); panel.add(cellTable); initWidget(panel); } @Inject  EnumEditorViewImpl(final ListDataProvider<EnumRow> dataProvider,
                              final Button addButton); @PostConstruct void init(); @Override void setContent(final List<EnumRow> content); @Override List<EnumRow> getContent();  }
@Test public void testClickCauseAdditionOfRow() throws Exception { view.init(); Assertions.assertThat(dataProvider.getList()).hasSize(0); verify(dataProvider).addDataDisplay(any(CellTable.class)); verify(addButton).addClickHandler(clickHandlerCaptor.capture()); clickHandlerCaptor.getValue().onClick(mock(ClickEvent.class)); Assertions.assertThat(dataProvider.getList()).hasSize(1); final EnumRow newRow = dataProvider.getList().get(0); Assertions.assertThat(newRow.getContext()).isEmpty(); Assertions.assertThat(newRow.getFactName()).isEmpty(); Assertions.assertThat(newRow.getFieldName()).isEmpty(); Assertions.assertThat(newRow.getRaw()).isEmpty(); }