CallFunction implements DDMExpressionFieldAccessorAware,
			   DDMExpressionFunction.Function3<String, String, String, Boolean>,
			   DDMExpressionObserverAware { protected void setDDMFormFieldOptions( String field, List<KeyValuePair> options) { UpdateFieldPropertyRequest.Builder builder = UpdateFieldPropertyRequest.Builder.newBuilder( field, "options", options); _ddmExpressionObserver.updateFieldProperty(builder.build()); } CallFunction(
		DDMDataProviderInvoker ddmDataProviderInvoker,
		JSONFactory jsonFactory); @Override Boolean apply(
		String ddmDataProviderInstanceUUID, String paramsExpression,
		String resultMapExpression); @Override String getName(); @Override void setDDMExpressionFieldAccessor(
		DDMExpressionFieldAccessor ddmExpressionFieldAccessor); @Override void setDDMExpressionObserver(
		DDMExpressionObserver ddmExpressionObserver); static final String NAME; }
@Test public void testNotAutoSelectOption() throws Exception { DDMForm ddmForm = DDMFormTestUtil.createDDMForm("field0"); DDMFormValues ddmFormValues = DDMFormValuesTestUtil.createDDMFormValues( ddmForm); ddmFormValues.addDDMFormFieldValue( DDMFormValuesTestUtil.createDDMFormFieldValue( "1", "field0", new UnlocalizedValue("a"))); MockDDMExpressionObserver mockDDMExpressionObserver = mockDDMExpressionObserver(ddmFormValues); List<KeyValuePair> keyValuePairs = new ArrayList<>(); keyValuePairs.add(new KeyValuePair("key_1", "value_1")); keyValuePairs.add(new KeyValuePair("key_2", "value_2")); _callFunction.setDDMFormFieldOptions("field0", keyValuePairs); Assert.assertNull( mockDDMExpressionObserver.getFieldPropertyValue( "field0", "1", "value")); }
@Test public void testSetDDMFormFieldOptionsRepeatableFields() { DDMForm ddmForm = DDMFormTestUtil.createDDMForm("field0"); DDMFormValues ddmFormValues = DDMFormValuesTestUtil.createDDMFormValues( ddmForm); ddmFormValues.addDDMFormFieldValue( DDMFormValuesTestUtil.createDDMFormFieldValue( "1", "field0", new UnlocalizedValue("a"))); ddmFormValues.addDDMFormFieldValue( DDMFormValuesTestUtil.createDDMFormFieldValue( "2", "field0", new UnlocalizedValue("b"))); MockDDMExpressionObserver mockDDMExpressionObserver = mockDDMExpressionObserver(ddmFormValues); List<KeyValuePair> keyValuePairs = new ArrayList<>(); keyValuePairs.add(new KeyValuePair("key_1", "value_1")); keyValuePairs.add(new KeyValuePair("key_2", "value_2")); _callFunction.setDDMFormFieldOptions("field0", keyValuePairs); Assert.assertEquals( keyValuePairs, mockDDMExpressionObserver.getFieldPropertyValue( "field0", "1", "options")); Assert.assertEquals( keyValuePairs, mockDDMExpressionObserver.getFieldPropertyValue( "field0", "2", "options")); }