Skip to content

Commit

Permalink
[FIXED JENKINS-37788] Use isLiteral instead of isConstant.
Browse files Browse the repository at this point in the history
  • Loading branch information
abayer committed Sep 30, 2016
1 parent a8693ca commit 670ecdb
Show file tree
Hide file tree
Showing 40 changed files with 118 additions and 118 deletions.
Expand Up @@ -47,7 +47,7 @@ public abstract class ModelASTValue extends ModelASTElement {
* If the value can be determined without side-effect at AST parsing time,
* this method returns true, and {@Link #getValue()} returns its value.
*/
public abstract boolean isConstant();
public abstract boolean isLiteral();

/**
* Returns a value or an expression that represents this value.
Expand All @@ -69,14 +69,14 @@ public abstract class ModelASTValue extends ModelASTElement {
@Override
public JSONObject toJSON() {
return new JSONObject()
.accumulate("isConstant", isConstant())
.accumulate("isLiteral", isLiteral())
.accumulate("value", getValue())
}

public static final ModelASTValue fromConstant(final Object o, Object sourceLocation) {
return new ModelASTValue(sourceLocation, o) {
@Override
boolean isConstant() {
boolean isLiteral() {
return true;
}

Expand All @@ -94,7 +94,7 @@ public abstract class ModelASTValue extends ModelASTElement {
public static final ModelASTValue fromGString(String gstring, Object sourceLocation) {
return new ModelASTValue(sourceLocation, gstring) {
@Override
boolean isConstant() {
boolean isLiteral() {
return false;
}

Expand Down
Expand Up @@ -240,7 +240,7 @@ class JSONParser {
}

public @CheckForNull ModelASTValue parseValue(JSONObject o) {
if (o.getBoolean("isConstant")) {
if (o.getBoolean("isLiteral")) {
return ModelASTValue.fromConstant(o.get("value"), o)
} else {
return ModelASTValue.fromGString(o.getString("value"), o)
Expand Down
Expand Up @@ -274,7 +274,7 @@ class ModelValidator {
}

private boolean validateParameterType(ModelASTValue v, Class erasedType, ModelASTKey k = null) {
if (v.isConstant()) {
if (v.isLiteral()) {
try {
ScriptBytecodeAdapter.castToType(v.value, erasedType);
} catch (Exception e) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/ast-schema.json
Expand Up @@ -5,7 +5,7 @@
"description": "The raw value of an argument, including whether it's a constant",
"type": "object",
"properties": {
"isConstant": { "type": "boolean" },
"isLiteral": { "type": "boolean" },
"value": {
"type": [
"number",
Expand All @@ -15,7 +15,7 @@
}
},

"required": ["isConstant", "value"],
"required": ["isLiteral", "value"],

"additionalProperties": false

Expand Down
Expand Up @@ -130,14 +130,14 @@ public static Iterable<Object[]> configsWithErrors() {
" \"steps\": [ {\n" +
" \"name\": \"echo\",\n" +
" \"arguments\": {\n" +
" \"isConstant\": true,\n" +
" \"isLiteral\": true,\n" +
" \"value\": \"hello\"\n" +
"\n" +
" }]\n" +
" }]\n" +
" }],\n" +
" \"agent\": {\n" +
" \"isConstant\": true,\n" +
" \"isLiteral\": true,\n" +
" \"value\": \"none\"\n" +
" }\n" +
"}}"});
Expand Down
Expand Up @@ -59,7 +59,7 @@ public void scriptBlockIsAString() throws Exception {

JSONObject arg = scriptStep.getJSONObject("arguments");
assertNotNull(arg);
assertTrue(arg.getBoolean("isConstant"));
assertTrue(arg.getBoolean("isLiteral"));
assertEquals("echo \"In a script step\"", arg.getString("value"));

}
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/json/agentAny.json
Expand Up @@ -6,14 +6,14 @@
"steps": [ {
"name": "sh",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "echo \"THIS WORKS\""
}
}]
}]
}],
"agent": {
"isConstant": true,
"isLiteral": true,
"value": "any"
}
}}
6 changes: 3 additions & 3 deletions src/test/resources/json/agentDocker.json
Expand Up @@ -7,14 +7,14 @@
{
"name": "sh",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "cat /usr/local/apache2/conf/extra/httpd-userdir.conf"
}
},
{
"name": "sh",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "echo \"The answer is 42\""
}
}
Expand All @@ -24,7 +24,7 @@
"agent": [ {
"key": "docker",
"value": {
"isConstant": true,
"isLiteral": true,
"value": "httpd:2.4.12"
}
}]
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/json/agentLabel.json
Expand Up @@ -6,7 +6,7 @@
"steps": [ {
"name": "sh",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "echo ONSLAVE=$ONSLAVE"
}
}]
Expand All @@ -15,7 +15,7 @@
"agent": [ {
"key": "label",
"value": {
"isConstant": true,
"isLiteral": true,
"value": "some-label"
}
}]
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/json/agentNoneWithNode.json
Expand Up @@ -6,21 +6,21 @@
"steps": [ {
"name": "node",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "some-label"
},
"children": [ {
"name": "sh",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "echo ONSLAVE=$ONSLAVE"
}
}]
}]
}]
}],
"agent": {
"isConstant": true,
"isLiteral": true,
"value": "none"
}
}}
4 changes: 2 additions & 2 deletions src/test/resources/json/errors/emptyEnvironment.json
Expand Up @@ -6,7 +6,7 @@
"steps": [ {
"name": "sh",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "echo \"FOO is $FOO\""
}
}]
Expand All @@ -16,7 +16,7 @@
"agent": [ {
"key": "label",
"value": {
"isConstant": true,
"isLiteral": true,
"value": "some-label"
}
}]
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/json/errors/emptyNotifications.json
Expand Up @@ -6,7 +6,7 @@
"steps": [ {
"name": "sh",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "echo \"FOO is $FOO\""
}
}]
Expand All @@ -16,7 +16,7 @@
"agent": [ {
"key": "label",
"value": {
"isConstant": true,
"isLiteral": true,
"value": "some-label"
}
}]
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/json/errors/emptyParallel.json
Expand Up @@ -4,7 +4,7 @@
"branches": []
}],
"agent": {
"isConstant": true,
"isLiteral": true,
"value": "none"
}
}}
4 changes: 2 additions & 2 deletions src/test/resources/json/errors/emptyPostBuild.json
Expand Up @@ -6,7 +6,7 @@
"steps": [ {
"name": "sh",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "echo \"FOO is $FOO\""
}
}]
Expand All @@ -16,7 +16,7 @@
"agent": [ {
"key": "label",
"value": {
"isConstant": true,
"isLiteral": true,
"value": "some-label"
}
}]
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/json/errors/emptyStages.json
@@ -1,7 +1,7 @@
{"pipeline": {
"stages": [ ],
"agent": {
"isConstant": true,
"isLiteral": true,
"value": "none"
}
}}
10 changes: 5 additions & 5 deletions src/test/resources/json/errors/invalidBuildCondition.json
Expand Up @@ -6,7 +6,7 @@
"steps": [ {
"name": "echo",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "hello"
}
}]
Expand All @@ -20,7 +20,7 @@
"steps": [ {
"name": "echo",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "I HAVE SUCCEEDED"
}
}]
Expand All @@ -33,7 +33,7 @@
"steps": [ {
"name": "echo",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "I HAVE FAILED"
}
}]
Expand All @@ -47,14 +47,14 @@
"steps": [ {
"name": "error",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "I AM FAILING"
}
}]
}
}]},
"agent": {
"isConstant": true,
"isLiteral": true,
"value": "none"
}
}}
4 changes: 2 additions & 2 deletions src/test/resources/json/errors/malformed.json
Expand Up @@ -6,14 +6,14 @@
"steps": [ {
"name": "echo",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "hello"

}]
}]
}],
"agent": {
"isConstant": true,
"isLiteral": true,
"value": "none"
}
}}
2 changes: 1 addition & 1 deletion src/test/resources/json/errors/missingAgent.json
Expand Up @@ -6,7 +6,7 @@
"steps": [ {
"name": "echo",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "hello"
}
}]
Expand Down
Expand Up @@ -9,23 +9,23 @@
{
"key": "unit",
"value": {
"isConstant": true,
"isLiteral": true,
"value": "SECONDS"
}
}
],
"children": [ {
"name": "echo",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "hello"
}
}]
}]
}]
}],
"agent": {
"isConstant": true,
"isLiteral": true,
"value": "none"
}
}}
2 changes: 1 addition & 1 deletion src/test/resources/json/errors/missingStages.json
@@ -1,6 +1,6 @@
{"pipeline": {
"agent": {
"isConstant": true,
"isLiteral": true,
"value": "none"
}
}}
6 changes: 3 additions & 3 deletions src/test/resources/json/errors/notInstalledToolType.json
Expand Up @@ -6,7 +6,7 @@
"steps": [ {
"name": "sh",
"arguments": {
"isConstant": true,
"isLiteral": true,
"value": "mvn -version"
}
}]
Expand All @@ -15,14 +15,14 @@
"agent": [ {
"key": "label",
"value": {
"isConstant": true,
"isLiteral": true,
"value": "some-label"
}
}],
"tools": [ {
"key": "gradle",
"value": {
"isConstant": true,
"isLiteral": true,
"value": "apache-maven-3.0.1"
}
}]
Expand Down

0 comments on commit 670ecdb

Please sign in to comment.