@Test public void testOnChangeCallbackRegisteredForActionValueEditor() throws Exception { final ActionFieldValue value = new ActionFieldValue(); value.setNature(FieldNatureType.TYPE_LITERAL); value.setField("a"); final ActionValueEditor editor = mock(ActionValueEditor.class); doReturn(editor).when(testedWidget).actionValueEditor(anyString(), eq(value), any(), eq(readOnly)); final ActionFieldValue valueTwo = new ActionFieldValue(); valueTwo.setNature(FieldNatureType.TYPE_LITERAL); valueTwo.setField("b"); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); doReturn(editorTwo).when(testedWidget).actionValueEditor(anyString(), eq(valueTwo), any(), eq(readOnly)); testedWidget.valueEditor(value); testedWidget.valueEditor(valueTwo); verify(editor).setOnChangeCommand(commandCaptor.capture()); commandCaptor.getValue().execute(); verify(testedWidget).setModified(true); verify(editorTwo).refresh(); } }
@Test public void testOnChangeCallbackRegisteredForActionValueEditor() throws Exception { final ActionFieldValue value = new ActionFieldValue(); value.setNature(FieldNatureType.TYPE_LITERAL); value.setField("a"); final ActionValueEditor editor = mock(ActionValueEditor.class); doReturn(editor).when(testedWidget).actionValueEditor(anyString(), eq(value), any(), eq(readOnly)); final ActionFieldValue valueTwo = new ActionFieldValue(); valueTwo.setNature(FieldNatureType.TYPE_LITERAL); valueTwo.setField("b"); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); doReturn(editorTwo).when(testedWidget).actionValueEditor(anyString(), eq(valueTwo), any(), eq(readOnly)); testedWidget.valueEditor(value); testedWidget.valueEditor(valueTwo); verify(editor).setOnChangeCommand(commandCaptor.capture()); commandCaptor.getValue().execute(); verify(testedWidget).setModified(true); verify(editorTwo).refresh(); } }
private ActionFieldValue cloneActionFieldValue(ActionFieldValue afv) { ActionFieldValue clone = new ActionFieldValue(); clone.setField(afv.getField()); clone.setNature(afv.getNature()); clone.setType(afv.getType()); clone.setValue(afv.getValue()); return clone; }
@Test public void testOnChangeCallbackRegisteredForActionValueEditor() throws Exception { final ActionFieldValue value = new ActionFieldValue(); value.setNature(FieldNatureType.TYPE_LITERAL); value.setField("a"); final ActionValueEditor editor = mock(ActionValueEditor.class); doReturn(editor).when(testedWidget).actionValueEditor(any(), eq(value), any(), anyBoolean()); final ActionFieldValue valueTwo = new ActionFieldValue(); valueTwo.setNature(FieldNatureType.TYPE_LITERAL); valueTwo.setField("b"); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); doReturn(editorTwo).when(testedWidget).actionValueEditor(any(), eq(valueTwo), any(), anyBoolean()); testedWidget.valueEditor(value); testedWidget.valueEditor(valueTwo); verify(editor).setOnChangeCommand(commandCaptor.capture()); commandCaptor.getValue().execute(); verify(testedWidget).setModified(true); verify(editorTwo).refresh(); } }
@Test public void testOnChangeCallbackRegisteredForActionValueEditor() throws Exception { final ActionFieldValue value = new ActionFieldValue(); value.setNature(FieldNatureType.TYPE_LITERAL); value.setField("a"); final ActionValueEditor editor = mock(ActionValueEditor.class); doReturn(editor).when(testedWidget).actionValueEditor(any(), eq(value), any(), anyBoolean()); final ActionFieldValue valueTwo = new ActionFieldValue(); valueTwo.setNature(FieldNatureType.TYPE_LITERAL); valueTwo.setField("b"); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); doReturn(editorTwo).when(testedWidget).actionValueEditor(any(), eq(valueTwo), any(), anyBoolean()); testedWidget.valueEditor(value); testedWidget.valueEditor(valueTwo); verify(editor).setOnChangeCommand(commandCaptor.capture()); commandCaptor.getValue().execute(); verify(testedWidget).setModified(true); verify(editorTwo).refresh(); } }
private ActionFieldValue cloneActionFieldValue(ActionFieldValue afv) { ActionFieldValue clone = new ActionFieldValue(); clone.setField(afv.getField()); clone.setNature(afv.getNature()); clone.setType(afv.getType()); clone.setValue(afv.getValue()); return clone; }
public ActionInsertFactCol52ActionInsertLogicalFactAdaptor(final ActionInsertFactCol52 action) { PortablePreconditions.checkNotNull("action", action); this.action = action; this.setFactType(action.getFactType()); final ActionFieldValue afv = new ActionFieldValue(); afv.setField(action.getFactField()); afv.setNature(BaseSingleFieldConstraint.TYPE_LITERAL); afv.setType(action.getType()); super.addFieldValue(afv); }
public ActionInsertFactCol52ActionInsertFactAdaptor(final ActionInsertFactCol52 action) { PortablePreconditions.checkNotNull("action", action); this.action = action; this.setFactType(action.getFactType()); final ActionFieldValue afv = new ActionFieldValue(); afv.setField(action.getFactField()); afv.setNature(BaseSingleFieldConstraint.TYPE_LITERAL); afv.setType(action.getType()); super.addFieldValue(afv); }
private static ActionFieldValue buildActionFieldValue() { ActionFieldValue afv = new ActionFieldValue(); afv.setField( "field" ); afv.setNature( FieldNatureType.TYPE_LITERAL ); afv.setType( "Type" ); afv.setValue( "value" ); return afv; }
@Test public void filtering() { when(field1.getName()).thenReturn("field1"); when(field2.getName()).thenReturn("field2"); final ActionFieldList afl = new ActionInsertFact(); final ActionFieldValue afv = new ActionFieldValue(); afv.setField("field1"); afl.addFieldValue(afv); final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[]{field1, field2}, afl); assertEquals(1, result.length); assertEquals(field2, result[0]); } }
@Test public void filtering() { when(field1.getName()).thenReturn("field1"); when(field2.getName()).thenReturn("field2"); final ActionFieldList afl = new ActionInsertFact(); final ActionFieldValue afv = new ActionFieldValue(); afv.setField("field1"); afl.addFieldValue(afv); final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[]{field1, field2}, afl); assertEquals(1, result.length); assertEquals(field2, result[0]); } }
private void setupBRLActionColumn() { final BRLActionColumn brl = new BRLActionColumn(); final ActionInsertFact ifc1 = new ActionInsertFact(); ifc1.setFactType("Person"); ifc1.setBoundName("$a"); final ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("name"); afv1.setValue("f1"); ifc1.addFieldValue(afv1); final ActionFieldValue afv2 = new ActionFieldValue(); afv2.setNature(FieldNatureType.TYPE_TEMPLATE); afv2.setField("age"); afv2.setValue("f2"); ifc1.addFieldValue(afv2); brl.getDefinition().add(ifc1); brl.getChildColumns().add(new BRLActionVariableColumn("f1", DataType.TYPE_STRING)); brl.getChildColumns().add(new BRLActionVariableColumn("f2", DataType.TYPE_NUMERIC_INTEGER)); model.getActionCols().add(brl); when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING); when(dmo.getFieldType(eq("Person"), eq("age"))).thenReturn(DataType.TYPE_NUMERIC_INTEGER); } }
private ActionInsertFact visitActionFieldList(ActionInsertFact afl) { ActionInsertFact clone = new ActionInsertFact(); clone.setFactType(afl.getFactType()); clone.setBoundName(afl.getBoundName()); for (ActionFieldValue afv : afl.getFieldValues()) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField(afv.getField()); afvClone.setNature(afv.getNature()); afvClone.setType(afv.getType()); afvClone.setValue(afv.getValue()); clone.addFieldValue(afvClone); } return clone; }
private ActionInsertFact visitActionFieldList(ActionInsertFact afl) { ActionInsertFact clone = new ActionInsertFact(); clone.setFactType(afl.getFactType()); clone.setBoundName(afl.getBoundName()); for (ActionFieldValue afv : afl.getFieldValues()) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField(afv.getField()); afvClone.setNature(afv.getNature()); afvClone.setType(afv.getType()); afvClone.setValue(afv.getValue()); clone.addFieldValue(afvClone); } return clone; }
@Test public void testActionUpdateFactFirstValue() { TemplateModel m = new TemplateModel(); m.name = "r1"; FactPattern fp = new FactPattern("Person"); fp.setBoundName("$p"); m.addLhsItem(fp); ActionSetField asf = new ActionSetField("$p"); ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE); afv0.setField("field1"); afv0.setValue("$f1"); asf.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("field2"); afv1.setValue("$f2"); asf.addFieldValue(afv1); m.addRhsItem(asf); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "$p : Person()\n" + "then\n" + "$p.setField1(\"foo\");\n" + "end"; m.addRow(new String[]{"foo", null}); checkMarshall(expected, m); }
ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE); afv0.setField("field1"); afv0.setValue("$f1"); auf1.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("field2"); afv1.setValue("$f2"); auf1.addFieldValue(afv1);
ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE); afv0.setField("field1"); afv0.setValue("$f1"); auf1.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_LITERAL); afv1.setField("field2"); afv1.setValue("bar"); auf1.addFieldValue(afv1);
ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_LITERAL); afv0.setField("field1"); afv0.setValue("foo"); auf1.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("field2"); afv1.setValue("$f2"); auf1.addFieldValue(afv1);
ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_LITERAL); afv0.setField("field1"); afv0.setValue("foo"); auf1.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("field2"); afv1.setValue("$f2"); auf1.addFieldValue(afv1);
ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE); afv0.setField("field1"); afv0.setValue("$f1"); aif.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("field2"); afv1.setValue("$f2"); aif.addFieldValue(afv1);