@Test
  public void testGetMatchedDevices() throws Exception {
    ISchemaTree schemaTree = new ClusterSchemaTree(generateSchemaTree());

    List<DeviceSchemaInfo> deviceSchemaInfoList =
        schemaTree.getMatchedDevices(new PartialPath("root.sg.d2.a"));
    Assert.assertEquals(1, deviceSchemaInfoList.size());
    DeviceSchemaInfo deviceSchemaInfo = deviceSchemaInfoList.get(0);
    Assert.assertEquals(new PartialPath("root.sg.d2.a"), deviceSchemaInfo.getDevicePath());
    Assert.assertTrue(deviceSchemaInfo.isAligned());
    Assert.assertEquals(2, deviceSchemaInfo.getMeasurements(Sets.newSet("*")).size());

    deviceSchemaInfoList = schemaTree.getMatchedDevices(new PartialPath("root.sg.*"));
    deviceSchemaInfoList.sort(Comparator.comparing(DeviceSchemaInfo::getDevicePath));
    Assert.assertEquals(2, deviceSchemaInfoList.size());
    Assert.assertEquals(new PartialPath("root.sg.d1"), deviceSchemaInfoList.get(0).getDevicePath());
    Assert.assertEquals(new PartialPath("root.sg.d2"), deviceSchemaInfoList.get(1).getDevicePath());

    deviceSchemaInfoList = schemaTree.getMatchedDevices(new PartialPath("root.sg.**"));
    deviceSchemaInfoList.sort(Comparator.comparing(DeviceSchemaInfo::getDevicePath));
    Assert.assertEquals(3, deviceSchemaInfoList.size());
    Assert.assertEquals(new PartialPath("root.sg.d1"), deviceSchemaInfoList.get(0).getDevicePath());
    Assert.assertEquals(new PartialPath("root.sg.d2"), deviceSchemaInfoList.get(1).getDevicePath());
    Assert.assertEquals(
        new PartialPath("root.sg.d2.a"), deviceSchemaInfoList.get(2).getDevicePath());

    deviceSchemaInfoList = schemaTree.getMatchedDevices(new PartialPath("root.**"));
    deviceSchemaInfoList.sort(Comparator.comparing(DeviceSchemaInfo::getDevicePath));
    Assert.assertEquals(3, deviceSchemaInfoList.size());
    Assert.assertEquals(new PartialPath("root.sg.d1"), deviceSchemaInfoList.get(0).getDevicePath());
    Assert.assertEquals(new PartialPath("root.sg.d2"), deviceSchemaInfoList.get(1).getDevicePath());
    Assert.assertEquals(
        new PartialPath("root.sg.d2.a"), deviceSchemaInfoList.get(2).getDevicePath());
  }
Generate complex schemaengine tree with specific deep and width. For example, if deep=2 and
width=3, the schemaengine tree contains timeseries: root.d0.s, root.d1.s, root.s2.s,
root.d0.d0.s, root.d0.d1.s, root.d0.d2.s, root.d1.d0.s, root.d1.d1.s, root.d1.d2.s,
root.d2.d0.s, root.d2.d1.s, root.d2.d2.s

@param deep deep
@param width width
@return root node
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/common/schematree/ClusterSchemaTreeTest.java