LimitedEntryActionSetFieldCol52DefinitionBuilder extends BaseActionColumnDefinitionBuilder { @Override public void generateDefinition( final GuidedDecisionTableView.Presenter dtPresenter, final BaseColumn column, final Callback<String> afterGenerationCallback ) { if ( !( column instanceof LimitedEntryActionSetFieldCol52 ) ) { return; } generateActionColumn( dtPresenter, column, afterGenerationCallback ); } @Inject  LimitedEntryActionSetFieldCol52DefinitionBuilder( 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 ActionSetFieldCol52DefinitionBuilder"); }); }
@Test public void simpleActionSetField() { final AtomicBoolean calledBack = new AtomicBoolean(false); setupPatternAndCondition(); final LimitedEntryActionSetFieldCol52 asf = new LimitedEntryActionSetFieldCol52(); asf.setBoundName("$p"); asf.setFactField("name"); asf.setValue(new DTCellValue52("Michael")); model.getActionCols().add(asf); when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING); builder.generateDefinition(dtPresenter, asf, (String definition) -> { calledBack.set(true); assertEquals("$p.setName( \"Michael\" );", definition); }); assertTrue(calledBack.get()); }
@Test public void simpleActionUpdateField() { final AtomicBoolean calledBack = new AtomicBoolean(false); setupLimitedEntryPatternAndCondition(); final LimitedEntryActionSetFieldCol52 asf = new LimitedEntryActionSetFieldCol52(); asf.setBoundName("$p"); asf.setFactField("name"); asf.setValue(new DTCellValue52("Michael")); asf.setUpdate(true); model.getActionCols().add(asf); when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING); builder.generateDefinition(dtPresenter, asf, (String definition) -> { calledBack.set(true); assertEquals("modify( $p ) {<br/>" + "setName( \"Michael\" )<br/>" + "}", definition); }); assertTrue(calledBack.get()); }