SQLDataSetDefAttributesEditor implements IsWidget, org.dashbuilder.dataset.client.editor.SQLDataSetDefAttributesEditor { @PostConstruct public void init() { view.init(this); view.initWidgets(dataSource.view, dbSchema.view, dbTable.view, dbSQL.view); dataSource.setSelectHint(DataSetEditorConstants.INSTANCE.sql_datasource_selectHint()); sqlProviderServices.call((List<SQLDataSourceDef> list) -> onSqlDataSourcesLoad(list)).getDataSourceDefs(); dataSource.addHelpContent(DataSetEditorConstants.INSTANCE.sql_datasource(), DataSetEditorConstants.INSTANCE.sql_datasource_description(), Placement.RIGHT); dbSchema.addHelpContent(DataSetEditorConstants.INSTANCE.sql_schema(), DataSetEditorConstants.INSTANCE.sql_schema_description(), Placement.BOTTOM); dbTable.addHelpContent(DataSetEditorConstants.INSTANCE.sql_table(), DataSetEditorConstants.INSTANCE.sql_table_description(), Placement.BOTTOM); dbSQL.addHelpContent(DataSetEditorConstants.INSTANCE.sql_query(), DataSetEditorConstants.INSTANCE.sql_query_description(), Placement.BOTTOM); onSelectQuery(); } @Inject  SQLDataSetDefAttributesEditor(final DropDownEditor dataSource,
                                         final ValueBoxEditor<String> dbSchema,
                                         final ValueBoxEditor<String> dbTable,
                                         final ValueBoxEditor<String> dbSQL,
                                         final Caller<SQLProviderServices> sqlProviderServices,
                                         final View view); @PostConstruct void init(); @Override Widget asWidget(); @Override DropDownEditor dataSource(); @Override ValueBoxEditor<String> dbSchema(); @Override ValueBoxEditor<String> dbTable(); @Override ValueBoxEditor<String> dbSQL(); @Override void flush(); @Override void onPropertyChange(final String... paths); @Override void setValue(final SQLDataSetDef value); @Override void setDelegate(final EditorDelegate<SQLDataSetDef> delegate); boolean isUsingQuery(); public View view; }
@Test public void testInit() { presenter.init(); verify(view, times(1)).init(presenter); verify(view, times(1)).initWidgets(any(DropDownEditor.View.class), any(ValueBoxEditor.View.class), any(ValueBoxEditor.View.class) ,any(ValueBoxEditor.View.class)); verify(dataSource, times(1)).addHelpContent(anyString(), anyString(), any(Placement.class)); verify(dbSchema, times(1)).addHelpContent(anyString(), anyString(), any(Placement.class)); verify(dbTable, times(1)).addHelpContent(anyString(), anyString(), any(Placement.class)); verify(dbSQL, times(1)).addHelpContent(anyString(), anyString(), any(Placement.class)); verify(view, times(1)).query(); verify(view, times(0)).table(); verify(sqlProviderServices).getDataSourceDefs(); verify(dataSource).setEntries(any()); verify(dataSource).setSelectHint(anyString()); }