@@ -0,0 +1,2387 @@
+/*******************************************************************************%0A * Copyright (c) 2015-2016 Oak Ridge National Laboratory.%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the Eclipse Public License v1.0%0A * which accompanies this distribution, and is available at%0A * http://www.eclipse.org/legal/epl-v10.html%0A *******************************************************************************/%0Apackage org.csstudio.display.builder.model.properties;%0A%0Aimport static org.hamcrest.CoreMatchers.containsString;%0Aimport static org.junit.Assert.assertThat;%0A%0Aimport java.util.Arrays;%0A%0Aimport org.csstudio.display.builder.model.Widget;%0Aimport org.csstudio.display.builder.model.WidgetProperty;%0Aimport org.csstudio.display.builder.model.widgets.plots.ImageWidget;%0Aimport org.junit.Test;%0A%0A/** JUnit test of Rules%0A *  @author Kay Kasemir%0A */%0A@SuppressWarnings(%22nls%22)%0Apublic class RulesTest%0A%7B%0A    /** Rule that checks pv0%3E10 and picks a certain value for that */%0A    @Test%0A    public void testValueForCondition() throws Exception%0A    %7B%0A        final ImageWidget widget = new ImageWidget();%0A%0A        final WidgetProperty%3CInteger%3E width = widget.propDataWidth().clone();%0A        width.setValue(47);%0A%0A        final RuleInfo rule = new RuleInfo(%22WidthBasedOnPV%22, %22data_width%22, true,%0A                Arrays.asList(new RuleInfo.ExprInfoValue%3CInteger%3E(%22pv0%3E10%22, width)),%0A                Arrays.asList(new ScriptPV(%22XSize%22)));%0A%0A        System.out.println(rule);%0A        final String script = RuleToScript.generatePy(widget, null, rule);%0A        System.out.println(script);%0A        // Script must read the PV%0A        assertThat(script, containsString(%22pv0 = PVUtil.getDouble(pvs%5B0%5D)%22));%0A    %7D%0A%0A    /** Rules that uses the value of a PV within an expression */%0A    @Test%0A    public void testValueAsExpression() throws Exception%0A    %7B%0A        final Widget widget = new ImageWidget();%0A        final RuleInfo rule = new RuleInfo(%22WidthFromPV%22, %22data_width%22, true,%0A                Arrays.asList(new RuleInfo.ExprInfoString(%22true%22, %22pv0%22)),%0A                Arrays.asList(new ScriptPV(%22XSize%22)));%0A%0A        System.out.println(rule);%0A        final String script = RuleToScript.generatePy(widget, null, rule);%0A        System.out.println(script);%0A        // Script must read the PV%0A        assertThat(script, containsString(%22PVUtil.get%22));%0A    %7D%0A%7D%0A

Add test for bug in handling of prop_as_expr_flag