Search in sources :

Example 1 with MultiStateLEDWidget

use of org.csstudio.display.builder.model.widgets.MultiStateLEDWidget in project org.csstudio.display.builder by kasemir.

the class WidgetPropertiesUnitTest method testPropertyListing.

@Test
public void testPropertyListing() {
    final Widget led = new MultiStateLEDWidget();
    final List<String> names = new ArrayList<>();
    for (WidgetProperty<?> property : led.getProperties()) names.addAll(Widget.expandPropertyNames(property));
    System.out.println("Properties of " + led.getType());
    for (String name : names) System.out.println(name);
    assertThat(names, hasItem("name"));
    assertThat(names, hasItem("states[1].color"));
    // Check that all listed properties are actually found
    for (String name : names) {
        WidgetProperty<?> property = led.getProperty(name);
        assertThat(name, property, not(nullValue()));
    }
}
Also used : MultiStateLEDWidget(org.csstudio.display.builder.model.widgets.MultiStateLEDWidget) XYPlotWidget(org.csstudio.display.builder.model.widgets.plots.XYPlotWidget) MultiStateLEDWidget(org.csstudio.display.builder.model.widgets.MultiStateLEDWidget) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 2 with MultiStateLEDWidget

use of org.csstudio.display.builder.model.widgets.MultiStateLEDWidget in project org.csstudio.display.builder by kasemir.

the class WidgetPropertiesUnitTest method testPropertyPath.

@Test
public void testPropertyPath() {
    final Widget led = new MultiStateLEDWidget();
    final WidgetProperty<?> color1 = led.getProperty("states[1].color");
    System.out.println(color1.getValue());
    assertThat(color1.getValue().toString(), equalTo("On"));
    try {
        led.getProperty("states[1].bogus");
        fail("Accessed bogus element");
    } catch (IllegalArgumentException ex) {
        System.out.println("Properly detected " + ex.getMessage());
        assertThat(ex.getMessage(), containsString("bogus"));
    }
}
Also used : MultiStateLEDWidget(org.csstudio.display.builder.model.widgets.MultiStateLEDWidget) XYPlotWidget(org.csstudio.display.builder.model.widgets.plots.XYPlotWidget) MultiStateLEDWidget(org.csstudio.display.builder.model.widgets.MultiStateLEDWidget) Test(org.junit.Test)

Aggregations

MultiStateLEDWidget (org.csstudio.display.builder.model.widgets.MultiStateLEDWidget)2 XYPlotWidget (org.csstudio.display.builder.model.widgets.plots.XYPlotWidget)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1