public static String renderTemplate(String template, Map<String, Object> newContext)
      throws IOException, ClassNotFoundException {
    Map<String, Object> contextMap = getDefaultContextMap();
    contextMap.putAll(newContext);
    String templateRendered = GROOVY_TEMPLATE_ENGINE.createTemplate(template).make(contextMap).toString();
    GROOVY_SHELL.resetLoadedClasses();
    return templateRendered;
  }
@Test
  public void testRenderTemplateWithGivenContextMap()
      throws IOException, ClassNotFoundException {
    Map<String, Object> contextMap = new HashMap<>();
    contextMap.put("first_date_2020", "2020-01-01");
    contextMap.put("name", "xiang");
    contextMap.put("ts", 1577836800);
    contextMap.put("yyyy", "2020");
    contextMap.put("YYYY", "1919");
    contextMap.put("MM", "05");
    contextMap.put("dd", "06");
    Assert.assertEquals(GroovyTemplateUtils.renderTemplate("$first_date_2020", contextMap), "2020-01-01");
    Assert.assertEquals(GroovyTemplateUtils.renderTemplate("${first_date_2020}", contextMap), "2020-01-01");
    Assert.assertEquals(GroovyTemplateUtils.renderTemplate("${ name }", contextMap), "xiang");
    Assert.assertEquals(GroovyTemplateUtils.renderTemplate("${ ts }", contextMap), "1577836800");
    Assert.assertEquals(GroovyTemplateUtils.renderTemplate("/var/rawdata/${ yyyy }/${ MM }/${ dd }", contextMap),
        "/var/rawdata/2020/05/06");
    Assert.assertEquals(GroovyTemplateUtils.renderTemplate("/var/rawdata/${yyyy}/${MM}/${dd}", contextMap),
        "/var/rawdata/2020/05/06");
    Assert.assertEquals(GroovyTemplateUtils.renderTemplate("/var/rawdata/${YYYY}/${MM}/${dd}", contextMap),
        "/var/rawdata/1919/05/06");
  }