Skip to content

Commit

Permalink
[rewrite] wip set / remove / table and started js bridge #1281
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Oct 3, 2020
1 parent 44c73bb commit 9353824
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 79 deletions.
13 changes: 9 additions & 4 deletions karate-core2/src/main/java/com/intuit/karate/data/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Json() {

public Json(String json) {
this(JsonPath.parse(json));
}
}

public Json(Map o) {
this(JsonPath.parse(o));
Expand Down Expand Up @@ -113,14 +113,19 @@ public Json set(String path, String s) {
if (JsonUtils.isJson(s)) {
setInternal(path, new Json(s).asMapOrList());
} else {
if (s.charAt(0) == '\\') {
if (s != null && s.charAt(0) == '\\') {
s = s.substring(1);
}
setInternal(path, s);
}
return this;
}

public Json remove(String path) {
doc.delete(path);
return this;
}

public Json set(String path, Object o) {
setInternal(path, o);
return this;
Expand Down Expand Up @@ -222,7 +227,7 @@ private void createPath(String path, boolean array) {
}
}
}

public static StringUtils.Pair toParentAndLeaf(String path) {
int pos = path.lastIndexOf('.');
int temp = path.lastIndexOf("['");
Expand All @@ -235,6 +240,6 @@ public static StringUtils.Pair toParentAndLeaf(String path) {
}
String left = path.substring(0, pos == -1 ? 0 : pos);
return StringUtils.pair(left, right);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public MatchResult isEqualTo(String s) {
if (JsonUtils.isJson(s)) {
return is(MatchType.EQUALS, new Json(s).asMapOrList());
} else {
if (s.charAt(0) == '\\') {
if (s != null && s.charAt(0) == '\\') {
s = s.substring(1);
}
return is(MatchType.EQUALS, s);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* The MIT License
*
* Copyright 2020 Intuit Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.intuit.karate.runtime;

/**
*
* @author pthomas3
*/
public class ScenarioBridge {

public final ScenarioRuntime runtime;

public ScenarioBridge(ScenarioRuntime runtime) {
this.runtime = runtime;
}

public void sayHello() {
System.out.println("*** hello");
}

}
Loading

0 comments on commit 9353824

Please sign in to comment.