Skip to content

Commit 871095b

Browse files
authored
Merge pull request #974 from NASA-PDS/i967
NASA-PDS/PDS4-CCB#28 Test cases for allowing whitespace in numeric fields in delimited tables
2 parents e8af0fd + e80257a commit 871095b

File tree

6 files changed

+955
-40
lines changed

6 files changed

+955
-40
lines changed

model-lddtool/src/site/markdown/developer/contribute.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,25 @@ A recording of a meeting where we went through tutorial can be [found here](http
2727
```
2828
@my_tutorial
2929
Examples:
30-
| testId | testName | testDir | messageCount | messageText | problemEnum | commandArgs | ingestLDDFileName |
30+
| testId | testName | testDir | messageCount | problemEnum | commandArgs | ingestLDDFileName | pds4Version | enableContentValidation |
3131
```
3232
* Add new line(s) for test cases to `src/test/resources/features/validate.feature`: (NOTE: This feature file is organized by minor versions, 15.2.x, 15.3.x, etc. based upon the next expected minor version. If the next minor version is not included create a new section of the document. Contact Jordan for more details if needed.)
3333
*
3434
* **testId** - this should be the GitHub reference to the applicable Github ticket. For this use case, that should be set to `NASA-PDS/pds4-information-model#753`
3535
* **testName** - title for the test that would be useful from someone trying to review a test plan with that title. For this use case, that should be set to `My test for new Current units nA, microA`
3636
* **testDir** - directory under `odel-lddtool/src/test/resources/` where your test data exists. For this use case, that should be set to `github753b`
3737
* **messageCount** - number of expected errors or warnings. For this use case, that should be set to `0` (success).
38-
* **messageText** - the expected output should match very closely to messageCount, e.g. `4 errors expected`, `8 warnings expected` (not sure how this is really used or why we have this right now...). For this use case, that should be set to `0 errors expected` (success).
39-
* **problemEnum** - `totalErrors`, `totalWarnings`, or specific error you expect from validate output. For this use case, that should be set to `SCHEMATRON_ERROR`
38+
* **problemEnum** - `totalErrors`, `totalWarnings`, or specific error you expect from validate output. For this use case, that should be set to `totalErrors`
4039
* for specific error, search [Validate ProblemTypes](https://github.com/NASA-PDS/validate/blob/main/src/main/java/gov/nasa/pds/tools/validate/ProblemType.java) for the error identifier, and put the ALL CAPS value in the file, e.g. for `error.label.schematron`, if I search the file I see this line `SCHEMATRON_ERROR("error.label.schematron")`, so the problemEnum value == `SCHEMATRON_ERROR`
4140
* **commandArgs** - these are the Validate Tool command-line arguments. For this example, let's set the target directory `--target {resourceDir}/github753/pc__d139.xml`. By default, the following are already included for validate under the hood of the test code:
4241
* `--disable-context-mismatch-warnings`
4342
* `--report-style json`
44-
* `--skip-content-validation`
43+
* `--skip-content-validation` (unless `enableContentValidation` is set to `"true"`)
44+
* `--skip-context-validation`
4545
* `--report-file {reportDir}/...`
4646
* **ingestLDDFileName** - the IngestLDD filenames you would like to have LDDTool generate the schema/schmematron for testing. These files should be in the test directory created earlier.
47+
* **pds4Version** - the PDS4 Information Model version to use (e.g., `"1C00"`, `"1D00"`). Leave empty (`""`) to use the latest version.
48+
* **enableContentValidation** - set to `"true"` to enable content validation for this test case (e.g., when testing table content validation). Default is `"false"`.
4749
* Now run the test(s):
4850
* Via Eclipse: right-click `Run as` -> `Cucumber Feature`
4951
* Via Maven (replace with applicable tag for this build):

model-lddtool/src/test/java/cucumber/ValidateStepDefs.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ public class ValidateStepDefs {
2929

3030
private static final Logger LOG = LoggerFactory.getLogger(ValidateStepDefs.class);
3131
private static final String DEFAULT_REPORT_FILENAME = "report_{testDir}.json";
32-
private static final String DEFAULT_VALIDATE_ARGS =
33-
"--disable-context-mismatch-warnings --report-style json --skip-content-validation --skip-context-validation --report-file {reportDir}/"
34-
+ DEFAULT_REPORT_FILENAME + " ";
32+
private static final String DEFAULT_VALIDATE_ARGS_BASE =
33+
"--disable-context-mismatch-warnings --report-style json ";
34+
private static final String DEFAULT_VALIDATE_SKIP_CONTENT = "--skip-content-validation ";
35+
private static final String DEFAULT_VALIDATE_ARGS_SUFFIX =
36+
"--skip-context-validation --report-file {reportDir}/" + DEFAULT_REPORT_FILENAME + " ";
3537
private static final String DEFAULT_CORE_ARGS = "-p";
3638
private static final String DEFAULT_LDDTOOL_ARGS = "-lp";
3739
private static final String PINNED_VERSION_DIR = "pinned_version";
@@ -72,6 +74,7 @@ public class ValidateStepDefs {
7274
private String reportDir;
7375
private String commandArgs;
7476
private String refOutputValue;
77+
private boolean enableContentValidation;
7578

7679

7780
@Before
@@ -195,6 +198,12 @@ public void with_test_property(int messageCount, String problemEnum) {
195198
+ "]");
196199
}
197200

201+
@Given("content validation is enabled {string}")
202+
public void content_validation_is_enabled(String enableContentValidation) {
203+
this.enableContentValidation = enableContentValidation.equalsIgnoreCase("true");
204+
LOG.debug("content_validation_is_enabled: " + this.enableContentValidation);
205+
}
206+
198207
@Given("the latest PDS4 schema\\/schematron is generated for IM Version {string}")
199208
public void generate_pds4_schema(String pds4Version) throws Exception {
200209
String lddtoolArgs = DEFAULT_CORE_ARGS;
@@ -348,7 +357,15 @@ private String getAbsolutePath(String path) throws Exception {
348357

349358
private String[] getDefaultValidateArguments(String commandArgs) throws URISyntaxException {
350359
List<String> argsList = new ArrayList<String>();
351-
String[] args = DEFAULT_VALIDATE_ARGS.concat(this.commandArgs).split("\\s+");
360+
361+
// Build validate args conditionally based on enableContentValidation
362+
String validateArgs = DEFAULT_VALIDATE_ARGS_BASE;
363+
if (!this.enableContentValidation) {
364+
validateArgs += DEFAULT_VALIDATE_SKIP_CONTENT;
365+
}
366+
validateArgs += DEFAULT_VALIDATE_ARGS_SUFFIX;
367+
368+
String[] args = validateArgs.concat(this.commandArgs).split("\\s+");
352369

353370
// Get schema
354371
String[] schemas = Utility

0 commit comments

Comments
 (0)