LayoutModelImpl extends ComponentModelImpl implements LayoutModel { @Override public ComponentModel getChild(String path) { if (children.containsKey(path)) { return children.get(path); } return layouts.values().stream() .map(l -> l.getChild(path)) .filter(Objects::nonNull) .findFirst() .orElse(null); } LayoutModelImpl(String path, ParentModel parent, String displayType);   LayoutModelImpl(String path, ParentModel parent, String displayType, Map<String, Object> properties); @Override LayoutModel getLayout(String path, String layoutType); @Override ComponentModel getChild(String path); @Override void addChild(ComponentModel component); @Override Map<String, ComponentModel> getChildren();  }
@Test public void testGetChildNotPresent() { LayoutModel layout = new LayoutModelImpl("Layout", parent, "List"); String path = "/Shuffleboard/Tab/Foo"; ComponentModel child = layout.getChild(path); assertNull(child); }
@Test public void testGetOrCreate() { LayoutModel layout = new LayoutModelImpl("Layout", parent, "List"); WidgetModel widget = layout.getOrCreate("/Shuffleboard/Tab/Foo", DataSource::none, "", Collections.emptyMap()); assertSame(widget, layout.getChild("/Shuffleboard/Tab/Foo")); }