YamlUtils { public static <T> T readYamlFromString(String yamlStr, Class<T> clazz) { Yaml yaml = new Yaml(); return yaml.loadAs(yamlStr, clazz); }  static T readYamlFromString(String yamlStr, Class<T> clazz); static ChatAlyticsConfig readChatAlyticsConfigFromString(String yamlStr); static String writeYaml(T value); static T readYamlFromResource(String resource, Class<T> clazz); static ChatAlyticsConfig readChatAlyticsConfig(String resource);  }
@Test public void testReadYamlFromString() { ChatAlyticsConfig config = new ChatAlyticsConfig(); config.inputType = InputSourceType.SLACK; SlackConfig slackConfig = new SlackConfig(); slackConfig.baseAPIURL = "http: config.computeConfig.chatConfig = slackConfig; String configStr = YamlUtils.writeYaml(config); ChatAlyticsConfig readConfig = YamlUtils.readChatAlyticsConfigFromString(configStr); assertEquals(config.inputType, readConfig.inputType); assertEquals(config.timeZone, readConfig.timeZone); ChatConfig readChatConfig = readConfig.computeConfig.chatConfig; assertTrue(readChatConfig instanceof SlackConfig); assertEquals(slackConfig.getBaseAPIURL(), readChatConfig.getBaseAPIURL()); }