use of org.csstudio.display.builder.model.widgets.GroupWidget in project org.csstudio.display.builder by kasemir.
the class PersistenceUnitTest method testWidgetReading.
/**
* Read widgets from XML
* @throws Exception on error
*/
@Test
public void testWidgetReading() throws Exception {
final String xml = getExampleFile();
final InputStream stream = new ByteArrayInputStream(xml.getBytes());
final ModelReader reader = new ModelReader(stream);
final DisplayModel model = reader.readModel();
final List<Widget> widgets = model.getChildren();
for (final Widget widget : widgets) {
System.out.println(widget);
System.out.println(widget.getProperties().stream().map(Object::toString).collect(Collectors.joining("\n")));
}
assertThat(widgets.size(), equalTo(2));
final List<String> names = widgets.stream().map(Widget::getName).collect(Collectors.toList());
assertThat(names, equalTo(Arrays.asList("Demo", "My Group")));
assertThat(widgets.get(1), instanceOf(GroupWidget.class));
assertThat(((GroupWidget) widgets.get(1)).runtimeChildren().getValue().get(0).getName(), equalTo("Jänner"));
}
Aggregations