@Test public void testExtractNoOOBE() { YamlExtract r1 = Yamls.getTextOfYamlAtPath( "items:\n- id: sample2\n itemType: location\n item:\n type: jclouds:aws-ec2\n brooklyn.config:\n key2: value2\n\n", "item"); r1.getMatchedYamlTextOrWarn(); try { r1.getMatchedYamlText(); Assert.fail(); } catch (UserFacingException e) { } }
public static YamlExtract getTextOfYamlAtPath(String yaml, Object ...path) { YamlExtract result = new YamlExtract(); if (yaml==null) return result; try { int pathIndex = 0; result.yaml = yaml; result.focus = new Yaml().compose(new StringReader(yaml)); findTextOfYamlAtPath(result, pathIndex, path); return result; } catch (NoSuchMethodError e) { throw new IllegalStateException("Class version error. This can happen if using a TestNG plugin in your IDE " + "which is an older version, dragging in an older version of SnakeYAML which does not support Mark.getIndex.", e); } catch (Exception e) { Exceptions.propagateIfFatal(e); log.debug("Unable to find element in yaml (setting in result): "+e); result.error = e; return result; } }
Yamls { public static YamlExtract getTextOfYamlAtPath(String yaml, Object ...path) { YamlExtract result = new YamlExtract(); if (yaml==null) return result; try { int pathIndex = 0; result.yaml = yaml; result.focus = new Yaml().compose(new StringReader(yaml)); findTextOfYamlAtPath(result, pathIndex, path); return result; } catch (NoSuchMethodError e) { throw new IllegalStateException("Class version error. This can happen if using a TestNG plugin in your IDE " + "which is an older version, dragging in an older version of SnakeYAML which does not support Mark.getIndex.", e); } catch (Exception e) { Exceptions.propagateIfFatal(e); log.debug("Unable to find element in yaml (setting in result): "+e); result.error = e; return result; } } }
Yamls { public static YamlExtract getTextOfYamlAtPath(String yaml, Object ...path) { YamlExtract result = new YamlExtract(); if (yaml==null) return result; try { int pathIndex = 0; result.yaml = yaml; result.focus = new Yaml().compose(new StringReader(yaml)); findTextOfYamlAtPath(result, pathIndex, path); return result; } catch (NoSuchMethodError e) { throw new IllegalStateException("Class version error. This can happen if using a TestNG plugin in your IDE " + "which is an older version, dragging in an older version of SnakeYAML which does not support Mark.getIndex.", e); } catch (Exception e) { Exceptions.propagateIfFatal(e); log.debug("Unable to find element in yaml (setting in result): "+e); result.error = e; return result; } }  }
Yamls { public static YamlExtract getTextOfYamlAtPath(String yaml, Object ...path) { YamlExtract result = new YamlExtract(); if (yaml==null) return result; try { int pathIndex = 0; result.yaml = yaml; result.focus = new Yaml().compose(new StringReader(yaml)); findTextOfYamlAtPath(result, pathIndex, path); return result; } catch (NoSuchMethodError e) { throw new IllegalStateException("Class version error. This can happen if using a TestNG plugin in your IDE " + "which is an older version, dragging in an older version of SnakeYAML which does not support Mark.getIndex.", e); } catch (Exception e) { Exceptions.propagateIfFatal(e); log.debug("Unable to find element in yaml (setting in result): "+e); result.error = e; return result; } }  @SuppressWarnings({ "unchecked", "rawtypes" }) static T getAs(Object x, Class<T> type); @Beta static Object getAt(String yaml, List<String> path); @Beta @SuppressWarnings("unchecked") static Object getAtPreParsed(Object current, List<String> path); @SuppressWarnings("rawtypes") static void dump(int depth, Object r); @SuppressWarnings("unchecked") static Iterable<Object> parseAll(String yaml); @SuppressWarnings("unchecked") static Iterable<Object> parseAll(Reader yaml); static Object removeMultinameAttribute(Map<String,Object> obj, String ...equivalentNames); static Object getMultinameAttribute(Map<String,Object> obj, String ...equivalentNames); static YamlExtract getTextOfYamlAtPath(String yaml, Object ...path); }
Yamls { public static YamlExtract getTextOfYamlAtPath(String yaml, Object ...path) { YamlExtract result = new YamlExtract(); if (yaml==null) return result; try { int pathIndex = 0; result.yaml = yaml; result.focus = new Yaml().compose(new StringReader(yaml)); findTextOfYamlAtPath(result, pathIndex, path); return result; } catch (NoSuchMethodError e) { throw new IllegalStateException("Class version error. This can happen if using a TestNG plugin in your IDE " + "which is an older version, dragging in an older version of SnakeYAML which does not support Mark.getIndex.", e); } catch (Exception e) { Exceptions.propagateIfFatal(e); log.debug("Unable to find element in yaml (setting in result): "+e); result.error = e; return result; } }  @SuppressWarnings({ "unchecked", "rawtypes" }) static T getAs(Object x, Class<T> type); @Beta static Object getAt(String yaml, List<String> path); @Beta @SuppressWarnings("unchecked") static Object getAtPreParsed(Object current, List<String> path); @SuppressWarnings("rawtypes") static void dump(int depth, Object r); @SuppressWarnings("unchecked") static Iterable<Object> parseAll(String yaml); @SuppressWarnings("unchecked") static Iterable<Object> parseAll(Reader yaml); static Object removeMultinameAttribute(Map<String,Object> obj, String ...equivalentNames); static Object getMultinameAttribute(Map<String,Object> obj, String ...equivalentNames); static YamlExtract getTextOfYamlAtPath(String yaml, Object ...path);  }