CallFunction implements DDMExpressionFieldAccessorAware,
			   DDMExpressionFunction.Function3<String, String, String, Boolean>,
			   DDMExpressionObserverAware { protected String getDDMFormFieldValue(String ddmFormFieldName) { GetFieldPropertyRequest.Builder builder = GetFieldPropertyRequest.Builder.newBuilder( ddmFormFieldName, "value"); GetFieldPropertyResponse getFieldPropertyResponse = _ddmExpressionFieldAccessor.getFieldProperty(builder.build()); Object value = getFieldPropertyResponse.getValue(); if (Validator.isNull(value)) { return StringPool.BLANK; } Class<?> clazz = value.getClass(); if (clazz.isArray()) { Object[] valueArray = (Object[])value; if (ArrayUtil.isNotEmpty(valueArray)) { value = ((Object[])value)[0]; } } try { JSONArray jsonArray = jsonFactory.createJSONArray( String.valueOf(value)); return (String)jsonArray.get(0); } catch (JSONException jsonException) { if (_log.isDebugEnabled()) { _log.debug(jsonException, jsonException); } return String.valueOf(value); } } 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 testGetFieldValueFromJSONArray() { JSONArray jsonArray = _jsonFactory.createJSONArray(); jsonArray.put("test"); mockDDMExpressionFieldAccessor(jsonArray); Assert.assertEquals( "test", _callFunction.getDDMFormFieldValue("field0")); }
@Test public void testGetFieldValueFromString() { mockDDMExpressionFieldAccessor("test"); Assert.assertEquals( "test", _callFunction.getDDMFormFieldValue("field0")); }