LimitedEntryActionInsertFactCol52DefinitionBuilder extends BaseActionColumnDefinitionBuilder { @Override public void generateDefinition( final GuidedDecisionTableView.Presenter dtPresenter, final BaseColumn column, final Callback<String> afterGenerationCallback ) { if ( !( column instanceof LimitedEntryActionInsertFactCol52 ) ) { return; } generateActionColumn( dtPresenter, column, afterGenerationCallback ); } @Inject  LimitedEntryActionInsertFactCol52DefinitionBuilder( final Caller<GuidedDecisionTableEditorService> service ); @Override Class getSupportedColumnType(); @Override void generateDefinition( final GuidedDecisionTableView.Presenter dtPresenter,
                                    final BaseColumn column,
                                    final Callback<String> afterGenerationCallback );  }
@Test public void unknownColumnTypeDoesNotTriggerBuilder() { final BaseColumn column = new RowNumberCol52(); builder.generateDefinition(dtPresenter, column, (String definition) -> { fail("RowNumberCol52 should not be handled by ActionInsertFactCol52DefinitionBuilder"); }); }
@Test public void simpleAction() { final AtomicBoolean calledBack = new AtomicBoolean(false); final LimitedEntryActionInsertFactCol52 aif = new LimitedEntryActionInsertFactCol52(); aif.setFactType("Person"); aif.setFactField("name"); aif.setValue(new DTCellValue52("Michael")); model.getActionCols().add(aif); when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING); builder.generateDefinition(dtPresenter, aif, (String definition) -> { calledBack.set(true); assertEquals("Person fact0 = new Person();<br/>" + "fact0.setName( \"Michael\" );<br/>" + "insert( fact0 );", definition); }); assertTrue(calledBack.get()); }