MTree implements Serializable { private void checkStorageGroup(String storageGroup) throws IllegalPathException { if (!IoTDBConfig.STORAGE_GROUP_PATTERN.matcher(storageGroup).matches()) { throw new IllegalPathException(String .format("The storage group name can only be characters, numbers and underscores. %s", storageGroup)); } } MTree(); private  MTree(MNode root); void serializeTo(String snapshotPath); @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning static MTree deserializeFrom(File mtreeSnapshot); @Override String toString(); static final Gson GSON; }
@Test public void testCheckStorageGroup() { MTree root = new MTree(); try { assertFalse(root.isStorageGroup(new PartialPath("root"))); assertFalse(root.isStorageGroup(new PartialPath("root1.laptop.d2"))); root.setStorageGroup(new PartialPath("root.laptop.d1")); assertTrue(root.isStorageGroup(new PartialPath("root.laptop.d1"))); assertFalse(root.isStorageGroup(new PartialPath("root.laptop.d2"))); assertFalse(root.isStorageGroup(new PartialPath("root.laptop"))); assertFalse(root.isStorageGroup(new PartialPath("root.laptop.d1.s1"))); root.setStorageGroup(new PartialPath("root.laptop.d2")); assertTrue(root.isStorageGroup(new PartialPath("root.laptop.d1"))); assertTrue(root.isStorageGroup(new PartialPath("root.laptop.d2"))); assertFalse(root.isStorageGroup(new PartialPath("root.laptop.d3"))); root.setStorageGroup(new PartialPath("root.1")); assertTrue(root.isStorageGroup(new PartialPath("root.1"))); } catch (MetadataException e) { e.printStackTrace(); fail(e.getMessage()); } }