@Test
  public void testDeleteSchemaWithTemplate() throws Exception {
    final ISchemaRegion schemaRegion = getSchemaRegion("root.db", 0);
    final int templateId = 1;
    final Template template =
        new Template(
            "t1",
            Arrays.asList("s1", "s2"),
            Arrays.asList(TSDataType.DOUBLE, TSDataType.INT32),
            Arrays.asList(TSEncoding.RLE, TSEncoding.RLE),
            Arrays.asList(CompressionType.SNAPPY, CompressionType.SNAPPY));
    template.setId(templateId);
    ClusterTemplateManager.getInstance().putTemplate(template);
    schemaRegion.activateSchemaTemplate(
        SchemaRegionWritePlanFactory.getActivateTemplateInClusterPlan(
            new PartialPath("root.db.d1"), 3, templateId),
        template);

    Assert.assertEquals(
        new Pair<>(0L, true),
        SchemaRegionTestUtil.deleteTimeSeries(schemaRegion, new PartialPath("root.db.d1.s1")));
    Assert.assertEquals(
        new Pair<>(0L, true),
        SchemaRegionTestUtil.deleteTimeSeries(schemaRegion, new PartialPath("root.db.d1.s3")));

    PathPatternTree patternTree = new PathPatternTree();
    patternTree.appendFullPath(new PartialPath("root.db.d1.s1"));

    ClusterSchemaTree schemaTree =
        schemaRegion.fetchSeriesSchema(
            patternTree, Collections.singletonMap(templateId, template), false, false, true, false);
    schemaTree.setTemplateMap(Collections.singletonMap(templateId, template));
    Assert.assertEquals(
        1, schemaTree.searchMeasurementPaths(new PartialPath("root.db.d1.s1")).left.size());
    patternTree = new PathPatternTree();
    patternTree.appendFullPath(new PartialPath("root.db.d1.s3"));
    schemaTree =
        schemaRegion.fetchSeriesSchema(
            patternTree, Collections.singletonMap(templateId, template), false, false, true, false);
    schemaTree.setTemplateMap(Collections.singletonMap(templateId, template));
    Assert.assertEquals(
        0, schemaTree.searchMeasurementPaths(new PartialPath("root.db.d1.s3")).left.size());
  }
Test {@link ISchemaRegion#constructSchemaBlackListWithTemplate}, {@link
ISchemaRegion#rollbackSchemaBlackListWithTemplate} and {@link
ISchemaRegion#deactivateTemplateInBlackList}
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionTemplateTest.java