gpt4 book ai didi

com.cognifide.qa.bb.utils.YamlReader类的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 17:43:31 26 4
gpt4 key购买 nike

本文整理了Java中com.cognifide.qa.bb.utils.YamlReader类的一些代码示例,展示了YamlReader类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlReader类的具体详情如下:
包路径:com.cognifide.qa.bb.utils.YamlReader
类名称:YamlReader

YamlReader介绍

[英]This is a utility class for reading yaml configuration files.
[中]这是一个用于读取yaml配置文件的实用程序类。

代码示例

代码示例来源:origin: Cognifide/bobcat

@Override
protected void configure() {
 String runmodes = System.getProperty("runmode", "default");
 String[] separateRunModes = StringUtils.split(runmodes, ",");
 List<String> modules = new ArrayList<>();
 TypeReference typeReference = new TypeReference<List<String>>() {
 };
 Arrays.stream(separateRunModes).forEach(runmode ->
   modules.addAll(YamlReader.readFromTestResources("runmodes/" + runmode, typeReference))
 );
 modules.stream().forEach(this::installFromName);
}

代码示例来源:origin: com.cognifide.qa.bb/bb-core

Config readUserYaml() {
 return YamlReader.read(USER_CONFIG_NAME, Config.class);
}

代码示例来源:origin: com.cognifide.qa.bb/bb-core

/**
 * Reads yaml configuration file under given path and returns structure defined in {@link TypeReference}.
 *
 * @param path          path to yaml configuration file.
 * @param typeReference type reference which will be used to construct result.
 * @param <T>           type of the mapped object
 * @return YAML file mapped to an object defined by provided TypeReference
 */
public static <T> T read(String path, TypeReference typeReference) {
 try {
  return new ObjectMapper(new YAMLFactory()).readValue(readFile(path), typeReference);
 } catch (IOException e) {
  LOG.error(COULD_NOT_PARSE_YAML_FILE, path, e);
  throw new IllegalStateException(YAML_FILE_COULD_NOT_BE_READ, e);
 }
}

代码示例来源:origin: com.cognifide.qa.bb/bb-core

/**
 * Reads yaml configuration file under given path in test resources and returns structure defined in {@link TypeReference}.
 *
 * @param path path to yaml configuration file.
 * @param type type which will be used to construct result.
 * @param <T>  type of the mapped object
 * @return YAML file mapped to an object defined by provided TypeReference
 */
public static <T> T readFromTestResources(String path, Class<T> type) {
 try {
  return new ObjectMapper(new YAMLFactory()).readValue(readFileFromTestResource(path), type);
 } catch (IOException e) {
  LOG.error(COULD_NOT_PARSE_YAML_FILE, path, e);
  throw new IllegalStateException(YAML_FILE_COULD_NOT_BE_READ, e);
 }
}

代码示例来源:origin: com.cognifide.qa.bb/bb-core

/**
 * Reads yaml configuration file under given path and returns structure defined in {@link TypeReference}.
 *
 * @param path path to yaml configuration file.
 * @param type type which will be used to construct result.
 * @param <T>  type of the mapped object
 * @return YAML file mapped to an object defined by provided TypeReference
 */
public static <T> T read(String path, Class<T> type) {
 try {
  return new ObjectMapper(new YAMLFactory()).readValue(readFile(path), type);
 } catch (IOException e) {
  LOG.error(COULD_NOT_PARSE_YAML_FILE, path, e);
  throw new IllegalStateException(YAML_FILE_COULD_NOT_BE_READ, e);
 }
}

代码示例来源:origin: com.cognifide.qa.bb/bb-core

/**
 * Reads yaml configuration file under given path in test resources and returns structure defined in {@link TypeReference}.
 *
 * @param path          path to yaml configuration file.
 * @param typeReference type reference which will be used to construct result.
 * @param <T>           type of the mapped object
 * @return YAML file mapped to an object defined by provided TypeReference
 */
public static <T> T readFromTestResources(String path, TypeReference typeReference) {
 try {
  return new ObjectMapper(new YAMLFactory()).readValue(readFileFromTestResource(path), typeReference);
 } catch (IOException e) {
  LOG.error(COULD_NOT_PARSE_YAML_FILE, path, e);
  throw new IllegalStateException(YAML_FILE_COULD_NOT_BE_READ, e);
 }
}

代码示例来源:origin: com.cognifide.qa.bb/bb-core

@Override
protected void configure() {
 String runmodes = System.getProperty("runmode", "default");
 String[] separateRunModes = StringUtils.split(runmodes, ",");
 List<String> modules = new ArrayList<>();
 TypeReference typeReference = new TypeReference<List<String>>() {
 };
 Arrays.stream(separateRunModes).forEach(runmode ->
   modules.addAll(YamlReader.readFromTestResources("runmodes/" + runmode, typeReference))
 );
 modules.stream().forEach(this::installFromName);
}

代码示例来源:origin: Cognifide/bobcat

Config readDefaultYaml() {
 return YamlReader.read(DEFAULT_CONFIG_NAME, Config.class);
}

代码示例来源:origin: Cognifide/bobcat

/**
 * Reads yaml configuration file under given path and returns structure defined in {@link TypeReference}.
 *
 * @param path          path to yaml configuration file.
 * @param typeReference type reference which will be used to construct result.
 * @param <T>           type of the mapped object
 * @return YAML file mapped to an object defined by provided TypeReference
 */
public static <T> T read(String path, TypeReference typeReference) {
 try {
  return new ObjectMapper(new YAMLFactory()).readValue(readFile(path), typeReference);
 } catch (IOException e) {
  LOG.error(COULD_NOT_PARSE_YAML_FILE, path, e);
  throw new IllegalStateException(YAML_FILE_COULD_NOT_BE_READ, e);
 }
}

代码示例来源:origin: Cognifide/bobcat

/**
 * Reads yaml configuration file under given path in test resources and returns structure defined in {@link TypeReference}.
 *
 * @param path          path to yaml configuration file.
 * @param typeReference type reference which will be used to construct result.
 * @param <T>           type of the mapped object
 * @return YAML file mapped to an object defined by provided TypeReference
 */
public static <T> T readFromTestResources(String path, TypeReference typeReference) {
 try {
  return new ObjectMapper(new YAMLFactory()).readValue(readFileFromTestResource(path), typeReference);
 } catch (IOException e) {
  LOG.error(COULD_NOT_PARSE_YAML_FILE, path, e);
  throw new IllegalStateException(YAML_FILE_COULD_NOT_BE_READ, e);
 }
}

代码示例来源:origin: com.cognifide.qa.bb/bb-aem-core

/**
 * {@inheritDoc}
 */
@Override
public ComponentConfiguration readConfiguration(ResourceFileLocation resourceFileLocation) {
 TypeReference typeReference = new TypeReference<Map<String, List<FieldConfig>>>() {
 };
 Map<String, List<FieldConfig>> configData = Collections.unmodifiableMap(
   YamlReader.readFromTestResources(resourceFileLocation.getFileName(), typeReference));
 List<TabConfig> tabsConfig = configData.entrySet().stream()
   .map(entry -> new TabConfig(entry.getKey(), entry.getValue()))
   .collect(toList());
 return new ComponentConfiguration(tabsConfig);
}

代码示例来源:origin: com.cognifide.qa.bb/bb-core

Config readDefaultYaml() {
 return YamlReader.read(DEFAULT_CONFIG_NAME, Config.class);
}

代码示例来源:origin: Cognifide/bobcat

/**
 * Reads yaml configuration file under given path and returns structure defined in {@link TypeReference}.
 *
 * @param path path to yaml configuration file.
 * @param type type which will be used to construct result.
 * @param <T>  type of the mapped object
 * @return YAML file mapped to an object defined by provided TypeReference
 */
public static <T> T read(String path, Class<T> type) {
 try {
  return new ObjectMapper(new YAMLFactory()).readValue(readFile(path), type);
 } catch (IOException e) {
  LOG.error(COULD_NOT_PARSE_YAML_FILE, path, e);
  throw new IllegalStateException(YAML_FILE_COULD_NOT_BE_READ, e);
 }
}

代码示例来源:origin: Cognifide/bobcat

/**
 * Reads yaml configuration file under given path in test resources and returns structure defined in {@link TypeReference}.
 *
 * @param path path to yaml configuration file.
 * @param type type which will be used to construct result.
 * @param <T>  type of the mapped object
 * @return YAML file mapped to an object defined by provided TypeReference
 */
public static <T> T readFromTestResources(String path, Class<T> type) {
 try {
  return new ObjectMapper(new YAMLFactory()).readValue(readFileFromTestResource(path), type);
 } catch (IOException e) {
  LOG.error(COULD_NOT_PARSE_YAML_FILE, path, e);
  throw new IllegalStateException(YAML_FILE_COULD_NOT_BE_READ, e);
 }
}

代码示例来源:origin: Cognifide/bobcat

/**
 * {@inheritDoc}
 */
@Override
public ComponentConfiguration readConfiguration(ResourceFileLocation resourceFileLocation) {
 TypeReference typeReference = new TypeReference<Map<String, List<FieldConfig>>>() {
 };
 Map<String, List<FieldConfig>> configData = Collections.unmodifiableMap(
   YamlReader.readFromTestResources(resourceFileLocation.getFileName(), typeReference));
 List<TabConfig> tabsConfig = configData.entrySet().stream()
   .map(entry -> new TabConfig(entry.getKey(), entry.getValue()))
   .collect(toList());
 return new ComponentConfiguration(tabsConfig);
}

代码示例来源:origin: Cognifide/bobcat

Config readUserYaml() {
 return YamlReader.read(USER_CONFIG_NAME, Config.class);
}

代码示例来源:origin: Cognifide/bobcat

private Map<? extends String, ? extends Map<String, String>> getContextsFromYaml(Path path) {
 TypeReference<Map<String, Map<String, String>>> typeRef =
   new TypeReference<Map<String, Map<String, String>>>() {
   };
 return YamlReader
   .read(ADDITIONAL_CONTEXTS_FOLDER + StringUtils
       .substringAfter(path.toString(), ADDITIONAL_CONTEXTS_FOLDER_NAME),
     typeRef);
}

代码示例来源:origin: com.cognifide.qa.bb/bb-core

private Map<? extends String, ? extends Map<String, String>> getContextsFromYaml(Path path) {
 TypeReference<Map<String, Map<String, String>>> typeRef =
   new TypeReference<Map<String, Map<String, String>>>() {
   };
 return YamlReader
   .read(ADDITIONAL_CONTEXTS_FOLDER + StringUtils
       .substringAfter(path.toString(), ADDITIONAL_CONTEXTS_FOLDER_NAME),
     typeRef);
}

代码示例来源:origin: com.cognifide.qa.bb/bb-core

private List<CookieData> create() {
  return YamlReader
    .read(getPath(),
      CookiesData.class).getCookies();
 }
}

代码示例来源:origin: Cognifide/bobcat

private List<CookieData> create() {
  return YamlReader
    .read(getPath(),
      CookiesData.class).getCookies();
 }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com