Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yingjian Wu committed Apr 9, 2024
1 parent 00d3176 commit 7a8f360
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,18 @@ class MetacatSmokeSpec extends Specification {
def nestedFieldDto = tableDTO.getFields().find { it.pos == 1 }
// assert that the type field also keeps the name fidelity
assert nestedFieldDto.type == "(name: chararray,address: (NAME: chararray),nestedArray: {(FIELD1: chararray,field2: chararray)})" : "The type differ from the expected. They are: $nestedFieldDto.type"

// assert that the json representation keeps the name fidelity

// 1. assert the first level fieldName fidelity
def firstLevelFieldsNames = nestedFieldDto.jsonType.fields
assert ["name", "address", "nestedArray"] == firstLevelFieldsNames.collect { it.name } : "The first level nested fields names differ from the expected. They are: $firstLevelFieldsNames.collect { it.name }"
def firstLevelFields = nestedFieldDto.jsonType.fields
def firstLevelFieldNames = firstLevelFields.collect { it.name }
assert ["name", "address", "nestedArray"] == firstLevelFieldNames : "The first level nested fields names differ from the expected. They are: $firstLevelFieldNames"

// 2. assert that the second level fieldName in address Struct keeps its fieldname fidelity
def addressStruct = nestedFieldDto.jsonType.fields[1]
assert addressStruct.type.fields[0].name == "NAME" : "The second level fieldName in address Struct differ from the expected. They are: $addressStruct.type.fields.name"

// 3. assert that the second level fieldName in nestedArray keeps its fieldname fidelity
def nestedArray = nestedFieldDto.jsonType.fields[2]
assert nestedArray.type.elementType.fields[0].name == "FIELD1" : "The second level fieldName in nestedArray differ from the expected. They are: $addressStruct.type.fields.name"
Expand Down

0 comments on commit 7a8f360

Please sign in to comment.