TabModelImpl implements TabModel { @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); } TabModelImpl(String title); @Override String getTitle(); @Override Map<String, Object> getProperties(); @Override void setProperties(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() { TabModel tab = new TabModelImpl("Tab"); String path = "/Shuffleboard/Tab/Foo"; ComponentModel child = tab.getChild(path); assertNull(child); }
@Test public void testGetOrCreate() { TabModel tab = new TabModelImpl("Tab"); WidgetModel widget = tab.getOrCreate("/Shuffleboard/Tab/Foo", DataSource::none, "", Collections.emptyMap()); assertSame(widget, tab.getChild("/Shuffleboard/Tab/Foo")); }