ConfigurationTemplatesDao implements TemplatesDao, InitializingBean { protected TemplateDefinitionImpl loadTemplate(Path p) throws IOException { ObjectMapper mapper = new ObjectMapper(); TemplateDefinitionImpl t = mapper.readValue(p.toFile(), TemplateDefinitionImpl.class); return t; } ConfigurationTemplatesDao(Configuration config); @Override boolean hasTemplate(String id); @Override TemplateDefinition getTemplate(String id); @Override QueryResult<TemplateDefinition> getTemplates(); @Override void afterPropertiesSet(); @Override String createTemplate(TemplateDefinition def);  }
@Test public void testTemplateLoading() throws IOException, URISyntaxException { ConfigurationTemplatesDao dao = new ConfigurationTemplatesDao(null); TemplateDefinitionImpl t = dao.loadTemplate(Paths.get(getClass().getResource("/templates-test/overshootUndershoot.json").toURI())); MatcherAssert.assertThat(t.getId(), CoreMatchers.is("overshootUndershoot")); MatcherAssert.assertThat(t.getLabel(), CoreMatchers.is("Generic overshoot/undershoot pattern")); MatcherAssert.assertThat(t.getParameters().size(), CoreMatchers.is(2)); MatcherAssert.assertThat(t.getParameters().get("observedProperty").getType(), CoreMatchers.is("text")); ParameterDefinition thresholdValue = t.getParameters().get("thresholdValue"); MatcherAssert.assertThat(thresholdValue.getMin(), CoreMatchers.is(1.3)); MatcherAssert.assertThat(thresholdValue.getMax(), CoreMatchers.is(2.2)); MatcherAssert.assertThat(thresholdValue.getPattern(), CoreMatchers.is("regex")); }