### Question:
FormFieldValuesUtil { protected List<Expression> getExpressionsToEvaluation(final List<FormWidget> widgets, final Map<String, Serializable> resolvedDisplayExp, final Map<String, Object> context) { final List<Expression> expressionsToEvaluate = new ArrayList<Expression>(); for (final FormWidget formWidget : widgets) { if (isAuthorized(resolvedDisplayExp, formWidget.getId())) { expressionsToEvaluate.addAll(getWidgetExpressions(formWidget, context)); } } return expressionsToEvaluate; }  FormFieldValue getFieldValue(final Object value, final FormWidget formWidget, final Locale locale); List<ReducedFormFieldAvailableValue> getAvailableValues(final Object availableValuesObject, final String widgetId); List<List<ReducedFormFieldAvailableValue>> getTableAvailableValues(final Object tableAvailableValuesObject, final String widgetId); void setFormWidgetValues(final long tenantID, final FormWidget formWidget, final Map<String, Serializable> evaluatedExpressions,
            final Map<String, Object> context); @SuppressWarnings("unchecked") void setTablesParams(final FormWidget formWidget, final Map<String, Serializable> evaluatedExpressions, final Map<String, Object> context); void setFormWidgetsValues(final long tenantID,
            final List<FormWidget> widgets,
            final Map<String, Object> context); void storeWidgetsInCacheAndSetCacheID(final long tenantID, final String formID, final String pageID, final String locale,
            final Date processDeployementDate, final List<FormWidget> formWidgets); static final String EXPRESSION_KEY_SEPARATOR; }### Answer:
@Test public void testWeRetrieveExpressionOfDisplayedWidgetOnly() throws Exception { final List<FormWidget> widgets = Arrays.asList( aWidgetWithLabelExpression("widget1"), aWidgetWithLabelExpression("widget2")); final Map<String, Serializable> resolvedDisplayExp = new HashMap<String, Serializable>(); resolvedDisplayExp.put(new WidgetExpressionEntry("widget1", ExpressionId.WIDGET_DISPLAY_CONDITION) .toString(), true); resolvedDisplayExp.put(new WidgetExpressionEntry("widget2", ExpressionId.WIDGET_DISPLAY_CONDITION) .toString(), false); final List<Expression> expressions = util.getExpressionsToEvaluation( widgets, resolvedDisplayExp, new HashMap<String, Object>()); assertEquals(1, expressions.size()); assertEquals("widget1:label", expressions.get(0).getName()); }
@Test public void testWeRetrieveExpressionOfWidgetWithoutDisplayExpressions() throws Exception { final List<FormWidget> widgets = Arrays.asList(aWidgetWithLabelExpression("widget")); final List<Expression> expressions = util.getExpressionsToEvaluation( widgets, new HashMap<String, Serializable>(), new HashMap<String, Object>()); assertEquals(1, expressions.size()); assertEquals("widget:label", expressions.get(0).getName()); }
@Test public void testWeDoNotRetrieveDisplayExpressionOfWidgetNotDisplayed() { final FormWidget widget = new FormWidget(); widget.setId("widget"); final Expression expression = new Expression(); expression.setName("expression"); widget.setDisplayConditionExpression(expression); final Map<String, Serializable> resolvedDisplayExp = new HashMap<String, Serializable>(); resolvedDisplayExp.put(new WidgetExpressionEntry("widget", ExpressionId.WIDGET_DISPLAY_CONDITION) .toString(), false); final List<Expression> expressions = util.getExpressionsToEvaluation( Arrays.asList(widget), resolvedDisplayExp, new HashMap<String, Object>()); assertTrue(expressions.isEmpty()); }