Skip to content

Commit

Permalink
Add additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanpadams committed May 23, 2024
1 parent 79a613c commit fb8b28a
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ private void checkFormat(String value, String format, int fieldIndex, RecordLoca
addTableProblem(asError ? ExceptionType.ERROR : ExceptionType.WARNING,
asError ? ProblemType.FIELD_VALID_FORMAT_PRECISION_MISMATCH : ProblemType.FIELD_VALUE_FORMAT_PRECISION_MISMATCH,
"The number of digits to the right of the decimal point " + "in the value '"
+ value.trim() + "' must be <= the precision set in the defined field format '"
+ value.trim() + "' should be <= the precision set in the defined field format '"
+ format+ "' (Expected: <=" + precision + ", Actual: " + actual_precision + ").",
recordLocation, fieldIndex);
}
Expand Down
7 changes: 5 additions & 2 deletions src/test/resources/features/developer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Scenario Outline: Execute validate command for tests below.
Given a test <testName> at dir <testDir> at resource <resourceDir> sending report to <reportDir> with <commandArgs> as arguments
When with test property count <messageCount> text <messageText> problem <problemEnum> reference <refOutputValue>
When execute a validate command
Then produced output from validate command should be similiar to reference <refOutputValue> or no error reported.
Then produced output from validate command should be similar to reference <refOutputValue> or no error reported.

Examples:
| testName | testDir | messageCount | messageText | problemEnum | resourceDir | reportDir | commandArgs | refOutputValue |
Expand Down Expand Up @@ -44,7 +44,10 @@ Scenario Outline: Execute validate command for tests below.

# Validate#681
|"NASA-PDS/validate#681 Success ASCII table with extra whitespace, valid precision" | "github681" | 0 | "0 errors expected" | "FIELD_VALUE_FORMAT_PRECISION_MISMATCH" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github681_1.json -s json -t {resourceDir}/github681/ff_char.xml {resourceDir}/github681/ff_del.xml" | "report_github681_1.json" |
|"NASA-PDS/validate#681 Failure of ASCII table invalid precision" | "github681" | 2 | "2 errors expected" | "FIELD_VALUE_FORMAT_PRECISION_MISMATCH" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github681_2.json -s json -t {resourceDir}/github681/ff_char_fail.xml {resourceDir}/github681/ff_del_fail.xml" | "report_github681_2.json" |
|"NASA-PDS/validate#681 Failure of ASCII table invalid precision" | "github681" | 2 | "2 warnings expected" | "FIELD_VALUE_FORMAT_PRECISION_MISMATCH" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github681_2.json -s json -t {resourceDir}/github681/ff_char_fail.xml {resourceDir}/github681/ff_del_fail.xml" | "report_github681_2.json" |

# Validate#817
|"NASA-PDS/validate#817 Failure of ASCII table invalid precision" | "github681" | 1 | "1 error expected" | "FIELD_VALID_FORMAT_PRECISION_MISMATCH" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github817_1.json -s json -t {resourceDir}/github681/ff_char_fail.xml" | "report_github817_1.json" |

# Validate#680
|"NASA-PDS/validate#680 Success char table correct length" | "github680" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github680.1.json -s json --skip-context-validation -t {resourceDir}/github680/ORB12_EUR_EPHIO_reclen96.xml" | "report_github680.1.json" |
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/github681/ff_char_fail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<data_type>ASCII_Real</data_type>
<field_length unit="byte">4</field_length>
<field_format>%4.2f</field_format>
<validation_format>%4.2f</validation_format>
</Field_Character>
<Field_Character>
<name>field 3</name>
Expand Down
74 changes: 74 additions & 0 deletions src/test/resources/github681/ff_char_warn.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1K00.sch" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<Product_Observational xmlns="http://pds.nasa.gov/pds4/pds/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pds.nasa.gov/pds4/pds/v1 https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1K00.xsd">
<Identification_Area>
<logical_identifier>urn:nasa:pds:bundle:collection:ff_char_test</logical_identifier>
<version_id>1.0</version_id>
<title>Field Format Character Test</title>
<information_model_version>1.20.0.0</information_model_version>
<product_class>Product_Observational</product_class>
</Identification_Area>
<Observation_Area>
<Time_Coordinates>
<start_date_time>2023Z</start_date_time>
<stop_date_time>2023Z</stop_date_time>
</Time_Coordinates>
<Investigation_Area>
<name>None</name>
<type>Other Investigation</type>
<Internal_Reference>
<lid_reference>urn:nasa:pds:context:investigation:individual.none</lid_reference>
<reference_type>data_to_investigation</reference_type>
</Internal_Reference>
</Investigation_Area>
<Observing_System>
<Observing_System_Component>
<name>telescope</name>
<type>Instrument</type>
</Observing_System_Component>
</Observing_System>
<Target_Identification>
<name>target</name>
<type>Comet</type>
</Target_Identification>
</Observation_Area>
<File_Area_Observational>
<File>
<file_name>ff_test_fail.csv</file_name>
</File>
<Table_Character>
<offset unit="byte">0</offset>
<records>3</records>
<record_delimiter>Carriage-Return Line-Feed</record_delimiter>
<Record_Character>
<fields>3</fields>
<groups>0</groups>
<record_length unit="byte">22</record_length>
<Field_Character>
<name>field 1</name>
<field_number>1</field_number>
<field_location unit="byte">1</field_location>
<data_type>ASCII_Real</data_type>
<field_length unit="byte">6</field_length>
<field_format>%6.2f</field_format>
</Field_Character>
<Field_Character>
<name>field 2</name>
<field_number>2</field_number>
<field_location unit="byte">8</field_location>
<data_type>ASCII_Real</data_type>
<field_length unit="byte">4</field_length>
<field_format>%4.2f</field_format>
</Field_Character>
<Field_Character>
<name>field 3</name>
<field_number>3</field_number>
<field_location unit="byte">13</field_location>
<data_type>ASCII_Real</data_type>
<field_length unit="byte">8</field_length>
<field_format>%8.3e</field_format>
</Field_Character>
</Record_Character>
</Table_Character>
</File_Area_Observational>
</Product_Observational>

0 comments on commit fb8b28a

Please sign in to comment.