|
| 1 | +Feature: Semantic Validation for CTO Class Declarations |
| 2 | + |
| 3 | + Scenario: Property name uses system-reserved name |
| 4 | + Given I load the following models: |
| 5 | + | model_file | alias | |
| 6 | + | concepts/models/CLASS_DECLARATION_001/class_declaration_001_system_property_name.cto | main | |
| 7 | + Then an error should be thrown with message "Invalid field name '$class'" |
| 8 | + |
| 9 | + Scenario: Valid property names that are not system-reserved |
| 10 | + Given I load the following models: |
| 11 | + | model_file | alias | |
| 12 | + | concepts/models/CLASS_DECLARATION_001/class_declaration_001_valid_property_name.cto | main | |
| 13 | + Then no error should be thrown |
| 14 | + |
| 15 | + Scenario: $class property with invalid type |
| 16 | + Given I load the following models: |
| 17 | + | model_file | alias | |
| 18 | + | concepts/models/CLASS_DECLARATION_002/class_declaration_002_invalid_$class_type.cto | main | |
| 19 | + Then an error should be thrown with message "Invalid field name '$class'" |
| 20 | + |
| 21 | + Scenario: Model without explicit $class declaration |
| 22 | + Given I load the following models: |
| 23 | + | model_file | alias | |
| 24 | + | concepts/models/CLASS_DECLARATION_002/class_declaration_002_valid_$class_type.cto | main | |
| 25 | + Then no error should be thrown |
| 26 | + |
| 27 | + Scenario: Duplicate concept declarations in the same file |
| 28 | + Given I load the following models: |
| 29 | + | model_file | alias | |
| 30 | + | concepts/models/CLASS_DECLARATION_003/class_declaration_003_duplicate_class_name.cto | main | |
| 31 | + When I validate the models |
| 32 | + Then an error should be thrown with message "Duplicate class name" |
| 33 | + |
| 34 | + Scenario: Uniquely named concept declarations |
| 35 | + Given I load the following models: |
| 36 | + | model_file | alias | |
| 37 | + | concepts/models/CLASS_DECLARATION_003/class_declaration_003_unique_class_name.cto | main | |
| 38 | + When I validate the models |
| 39 | + Then no error should be thrown |
| 40 | + |
| 41 | + Scenario: Supertype does not exist |
| 42 | + Given I load the following models: |
| 43 | + | model_file | alias | |
| 44 | + | concepts/models/CLASS_DECLARATION_004/class_declaration_004_supertype_not_exist.cto | main | |
| 45 | + When I validate the models |
| 46 | + Then an error should be thrown with message "Could not find super type" |
| 47 | + |
| 48 | + Scenario: Supertype is declared correctly |
| 49 | + Given I load the following models: |
| 50 | + | model_file | alias | |
| 51 | + | concepts/models/CLASS_DECLARATION_004/class_declaration_004_supertype_exist.cto | main | |
| 52 | + When I validate the models |
| 53 | + Then no error should be thrown |
| 54 | + |
| 55 | + Scenario: Identifier field is not of type String or scalar |
| 56 | + Given I load the following models: |
| 57 | + | model_file | alias | |
| 58 | + | concepts/models/CLASS_DECLARATION_005/class_declaration_005_invalid_identifier_type.cto | main | |
| 59 | + When I validate the models |
| 60 | + Then an error should be thrown with message 'Class \"Entity\" is identified by field \"id\", but the type of the field is not \"String\"' |
| 61 | + |
| 62 | + Scenario: Identifier field is of type String |
| 63 | + Given I load the following models: |
| 64 | + | model_file | alias | |
| 65 | + | concepts/models/CLASS_DECLARATION_005/class_declaration_005_valid_identifier_type_string.cto | main | |
| 66 | + When I validate the models |
| 67 | + Then no error should be thrown |
| 68 | + |
| 69 | + Scenario: Identifier field is a String-based scalar |
| 70 | + Given I load the following models: |
| 71 | + | model_file | alias | |
| 72 | + | concepts/models/CLASS_DECLARATION_005/class_declaration_005_valid_identifier_type_scalar.cto | main | |
| 73 | + When I validate the models |
| 74 | + Then no error should be thrown |
| 75 | + |
| 76 | + Scenario: Identifier field is optional |
| 77 | + Given I load the following models: |
| 78 | + | model_file | alias | |
| 79 | + | concepts/models/CLASS_DECLARATION_006/class_declaration_006_optional_identifier.cto | main | |
| 80 | + When I validate the models |
| 81 | + Then an error should be thrown with message "Identifying fields cannot be optional" |
| 82 | + |
| 83 | + Scenario: Identifier field is required |
| 84 | + Given I load the following models: |
| 85 | + | model_file | alias | |
| 86 | + | concepts/models/CLASS_DECLARATION_006/class_declaration_006_required_identifier.cto | main | |
| 87 | + When I validate the models |
| 88 | + Then no error should be thrown |
| 89 | + |
| 90 | + Scenario: Supertype is not system-identified |
| 91 | + Given I load the following models: |
| 92 | + | model_file | alias | |
| 93 | + | concepts/models/CLASS_DECLARATION_007/class_declaration_007_supertype_not_system_identified.cto | main | |
| 94 | + Then an error should be thrown with message 'Expected \"{\", comment, end of line, or whitespace but \"i\" found' |
| 95 | + |
| 96 | + Scenario: Supertype is system-identified |
| 97 | + Given I load the following models: |
| 98 | + | model_file | alias | |
| 99 | + | concepts/models/CLASS_DECLARATION_007/class_declaration_007_supertype_system_identified.cto | main | |
| 100 | + When I validate the models |
| 101 | + Then no error should be thrown |
| 102 | + |
| 103 | + Scenario: Property name duplicated from supertype |
| 104 | + Given I load the following models: |
| 105 | + | model_file | alias | |
| 106 | + | concepts/models/CLASS_DECLARATION_008/class_declaration_008_duplicate_property_from_super.cto | main | |
| 107 | + When I validate the models |
| 108 | + Then an error should be thrown with message "has more than one field named" |
| 109 | + |
| 110 | + Scenario: Unique property names across inheritance |
| 111 | + Given I load the following models: |
| 112 | + | model_file | alias | |
| 113 | + | concepts/models/CLASS_DECLARATION_008/class_declaration_008_unique_property_from_super.cto | main | |
| 114 | + When I validate the models |
| 115 | + Then no error should be thrown |
| 116 | + |
| 117 | + Scenario: Duplicate declarations should throw |
| 118 | + Given I load the following models: |
| 119 | + | model_file | alias | |
| 120 | + | concepts/models/DECLARATION_001/declaration_001_duplicate_within_model.cto | main | |
| 121 | + When I validate the models |
| 122 | + Then an error should be thrown with message "has more than one field named" |
| 123 | + |
| 124 | + Scenario: Unique declarations should pass |
| 125 | + Given I load the following models: |
| 126 | + | model_file | alias | |
| 127 | + | concepts/models/DECLARATION_001/declaration_001_unique_within_model.cto | main | |
| 128 | + When I validate the models |
| 129 | + Then no error should be thrown |
| 130 | + |
| 131 | + Scenario: Invalid identifier should throw |
| 132 | + Given I load the following models: |
| 133 | + | model_file | alias | |
| 134 | + | concepts/models/MODEL_ELEMENT_002/model_element_002_invalid_identifier_name.cto | main | |
| 135 | + Then an error should be thrown with message "" |
| 136 | + |
| 137 | + Scenario: Valid identifier should pass |
| 138 | + Given I load the following models: |
| 139 | + | model_file | alias | |
| 140 | + | concepts/models/MODEL_ELEMENT_002/model_element_002_valid_identifier_name.cto | main | |
| 141 | + When I validate the models |
| 142 | + Then no error should be thrown |
| 143 | + |
| 144 | + Scenario: Relationship to primitive should throw |
| 145 | + Given I load the following models: |
| 146 | + | model_file | alias | |
| 147 | + | concepts/models/RELATIONSHIP_001/relationship_001_non-primitive_type_relationship.cto | main | |
| 148 | + When I validate the models |
| 149 | + Then an error should be thrown with message "cannot be to the primitive type" |
| 150 | + |
| 151 | + Scenario: Valid relationship to non-primitive should pass |
| 152 | + Given I load the following models: |
| 153 | + | model_file | alias | |
| 154 | + | concepts/models/RELATIONSHIP_001/relationship_001_primitive_type_relationship.cto | main | |
| 155 | + When I validate the models |
| 156 | + Then no error should be thrown |
| 157 | + |
| 158 | + Scenario: Missing relationship type should throw |
| 159 | + Given I load the following models: |
| 160 | + | model_file | alias | |
| 161 | + | concepts/models/RELATIONSHIP_002/relationship_002_type_not_exist.cto | main | |
| 162 | + When I validate the models |
| 163 | + Then an error should be thrown with message "Undeclared type" |
| 164 | + |
| 165 | + Scenario: Existing relationship type should pass |
| 166 | + Given I load the following models: |
| 167 | + | model_file | alias | |
| 168 | + | concepts/models/RELATIONSHIP_002/relationship_002_existing_type.cto | main | |
| 169 | + When I validate the models |
| 170 | + Then no error should be thrown |
| 171 | + |
| 172 | + Scenario: Non-identified relationship target should throw |
| 173 | + Given I load the following models: |
| 174 | + | model_file | alias | |
| 175 | + | concepts/models/RELATIONSHIP_003/relationship_003_not_identified_type.cto | main | |
| 176 | + When I validate the models |
| 177 | + Then an error should be thrown with message "must be to a class that has an identifier" |
| 178 | + |
| 179 | + Scenario: Identified relationship target should pass |
| 180 | + Given I load the following models: |
| 181 | + | model_file | alias | |
| 182 | + | concepts/models/RELATIONSHIP_003/relationship_003_identified_type.cto | main | |
| 183 | + When I validate the models |
| 184 | + Then no error should be thrown |
| 185 | + |
| 186 | + Scenario: Undeclared non-primitive type should throw |
| 187 | + Given I load the following models: |
| 188 | + | model_file | alias | |
| 189 | + | concepts/models/PROPERTY_002/property_002_type_does_not_exist.cto | main | |
| 190 | + When I validate the models |
| 191 | + Then an error should be thrown with message "Undeclared type" |
| 192 | + |
| 193 | + Scenario: Declared non-primitive type should pass |
| 194 | + Given I load the following models: |
| 195 | + | model_file | alias | |
| 196 | + | concepts/models/PROPERTY_002/property_002_type_exist.cto | main | |
| 197 | + When I validate the models |
| 198 | + Then no error should be thrown |
| 199 | + |
| 200 | + Scenario: Invalid property meta type should throw |
| 201 | + Given I load the following models: |
| 202 | + | model_file | alias | |
| 203 | + | concepts/models/PROPERTY_003/property_003_meta_type_invalid.cto | main | |
| 204 | + Then an error should be thrown with message "" |
| 205 | + |
| 206 | + Scenario: Valid property meta type should pass |
| 207 | + Given I load the following models: |
| 208 | + | model_file | alias | |
| 209 | + | concepts/models/PROPERTY_003/property_003_meta_type_valid.cto | main | |
| 210 | + When I validate the models |
| 211 | + Then no error should be thrown |
| 212 | + |
| 213 | + Scenario: Duplicate decorator should throw |
| 214 | + Given I load the following models: |
| 215 | + | model_file | alias | |
| 216 | + | concepts/models/DECORATED_001/decorated_001_duplicate_decorator.cto | main | |
| 217 | + When I validate the models |
| 218 | + Then an error should be thrown with message "Duplicate decorator" |
| 219 | + |
| 220 | + Scenario: Single decorator should pass |
| 221 | + Given I load the following models: |
| 222 | + | model_file | alias | |
| 223 | + | concepts/models/DECORATED_001/decorated_001_unique_decorator.cto | main | |
| 224 | + When I validate the models |
| 225 | + Then no error should be thrown |
0 commit comments