add description field in yaml

This commit is contained in:
Jonathan Shook
2020-04-16 05:47:02 -05:00
parent c5f4373232
commit 0477d5ae19
5 changed files with 27 additions and 1 deletions

View File

@@ -24,11 +24,23 @@ import java.util.Map;
public class BlockParams extends Tags {
private String name = "";
private String desc = "";
private Map<String, String> bindings = new LinkedHashMap<>();
private Map<String, String> params = new LinkedHashMap<>();
public BlockParams() {}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public void setDescription(String desc) {
this.desc = desc;
}
public String getName() {
return name;
}

View File

@@ -39,10 +39,14 @@ public class RawStmtDef extends BlockParams {
Optional.ofNullable((String) map.remove("stmt")).ifPresent(this::setStmt);
Optional.ofNullable((String) map.remove("statement")).ifPresent(this::setStmt);
Optional.ofNullable((String) map.remove("name")).ifPresent(this::setName);
Optional.ofNullable((String) map.remove("desc")).ifPresent(this::setDesc);
Optional.ofNullable((String) map.remove("description")).ifPresent(this::setDesc);
Optional.ofNullable((Map<String, String>) map.remove("tags")).ifPresent(this::setTags);
Optional.ofNullable((Map<String, String>) map.remove("bindings")).ifPresent(this::setBindings);
Optional.ofNullable((Map<String, String>) map.remove("params")).ifPresent(this::setParams);
// Depends on order stability, relying on LinkedHashMap -- Needs stability unit tests
if (this.statement == null) {
Iterator<Map.Entry<String, Object>> iterator = map.entrySet().iterator();
@@ -79,7 +83,7 @@ public class RawStmtDef extends BlockParams {
private void setStmt(String statement) {
this.statement = statement;
}
public String getName() {
return getParams().getOrDefault("name", super.getName());
}

View File

@@ -67,4 +67,8 @@ public class StmtDef implements Tagged {
public ParsedStmt getParsed() {
return new ParsedStmt(this);
}
public String getDesc() {
return rawStmtDef.getDesc();
}
}

View File

@@ -63,6 +63,9 @@ public class RawYamlStatementLoaderTest {
assertThat(rawStmtsDocs).hasSize(2);
RawStmtsDoc rawStmtsDoc = rawStmtsDocs.get(0);
List<RawStmtsBlock> blocks = rawStmtsDoc.getBlocks();
assertThat(rawStmtsDoc.getDesc()).isEqualTo("a quintessential" +
" description");
RawScenarios rawScenarios = rawStmtsDoc.getRawScenarios();
assertThat(rawScenarios.getScenarioNames()).containsExactly("default", "schema-only");
List<String> defaultScenario = rawScenarios.getNamedScenario("default");
@@ -75,6 +78,7 @@ public class RawYamlStatementLoaderTest {
RawStmtsBlock rawStmtsBlock = blocks.get(0);
assertThat(rawStmtsBlock.getName()).isEqualTo("block0");
}
}

View File

@@ -1,3 +1,5 @@
description: a quintessential description
scenarios:
default:
- run driver=stdout alias=step1