Class: Lutaml::Qea::Verification::DocumentVerifier
- Inherits:
-
Object
- Object
- Lutaml::Qea::Verification::DocumentVerifier
- Defined in:
- lib/lutaml/qea/verification/document_verifier.rb
Overview
Main orchestrator for document verification Verifies that QEA-parsed documents contain at least as much information as XMI-parsed equivalents
Instance Attribute Summary collapse
-
#comparator ⇒ Object
readonly
Returns the value of attribute comparator.
-
#matcher ⇒ Object
readonly
Returns the value of attribute matcher.
-
#normalizer ⇒ Object
readonly
Returns the value of attribute normalizer.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize ⇒ DocumentVerifier
constructor
A new instance of DocumentVerifier.
-
#reset_cache ⇒ Object
Reset cached match results (call between verifications).
-
#verify(xmi_path, qea_path) ⇒ ComparisonResult
Main verification method.
-
#verify_documents(xmi_doc, qea_doc) ⇒ ComparisonResult
Verify document with already loaded documents.
-
#verify_names(xmi_doc, qea_doc) ⇒ void
Verify element names are preserved.
-
#verify_properties(xmi_doc, qea_doc) ⇒ void
Verify properties of matched elements.
-
#verify_relationships(xmi_doc, qea_doc) ⇒ void
Verify relationships (associations, generalizations).
-
#verify_structure(xmi_doc, qea_doc) ⇒ void
Compare element counts.
Constructor Details
#initialize ⇒ DocumentVerifier
Returns a new instance of DocumentVerifier.
19 20 21 22 23 24 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 19 def initialize @normalizer = DocumentNormalizer.new @matcher = StructureMatcher.new @comparator = ElementComparator.new @result = ComparisonResult.new end |
Instance Attribute Details
#comparator ⇒ Object (readonly)
Returns the value of attribute comparator.
17 18 19 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 17 def comparator @comparator end |
#matcher ⇒ Object (readonly)
Returns the value of attribute matcher.
17 18 19 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 17 def matcher @matcher end |
#normalizer ⇒ Object (readonly)
Returns the value of attribute normalizer.
17 18 19 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 17 def normalizer @normalizer end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
17 18 19 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 17 def result @result end |
Instance Method Details
#reset_cache ⇒ Object
Reset cached match results (call between verifications)
69 70 71 72 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 69 def reset_cache @cached_class_matches = nil @cached_package_matches = nil end |
#verify(xmi_path, qea_path) ⇒ ComparisonResult
Main verification method
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 31 def verify(xmi_path, qea_path) # rubocop:disable Metrics/MethodLength # Parse documents xmi_doc = parse_xmi(xmi_path) qea_doc = parse_qea(qea_path) # Normalize documents xmi_normalized = normalizer.normalize(xmi_doc) qea_normalized = normalizer.normalize(qea_doc) # Perform verification verify_structure(xmi_normalized, qea_normalized) verify_names(xmi_normalized, qea_normalized) verify_properties(xmi_normalized, qea_normalized) verify_relationships(xmi_normalized, qea_normalized) result end |
#verify_documents(xmi_doc, qea_doc) ⇒ ComparisonResult
Verify document with already loaded documents
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 54 def verify_documents(xmi_doc, qea_doc) # Normalize documents xmi_normalized = normalizer.normalize(xmi_doc) qea_normalized = normalizer.normalize(qea_doc) # Perform verification verify_structure(xmi_normalized, qea_normalized) verify_names(xmi_normalized, qea_normalized) verify_properties(xmi_normalized, qea_normalized) verify_relationships(xmi_normalized, qea_normalized) result end |
#verify_names(xmi_doc, qea_doc) ⇒ void
This method returns an undefined value.
Verify element names are preserved
127 128 129 130 131 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 127 def verify_names(xmi_doc, qea_doc) # Package names verified in match_packages # Class names verified in match_classes # Additional verification could be added here end |
#verify_properties(xmi_doc, qea_doc) ⇒ void
This method returns an undefined value.
Verify properties of matched elements
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 138 def verify_properties(xmi_doc, qea_doc) # Verify class properties (reuse cached matches from verify_structure) class_matches = @cached_class_matches || matcher.match_classes( xmi_doc, qea_doc ) verify_class_properties(class_matches[:matches]) # Verify package properties (reuse cached matches from verify_structure) package_matches = @cached_package_matches || matcher.match_packages( xmi_doc, qea_doc ) verify_package_properties(package_matches[:matches]) end |
#verify_relationships(xmi_doc, qea_doc) ⇒ void
This method returns an undefined value.
Verify relationships (associations, generalizations)
157 158 159 160 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 157 def verify_relationships(xmi_doc, qea_doc) # Verify associations are preserved verify_associations(xmi_doc, qea_doc) end |
#verify_structure(xmi_doc, qea_doc) ⇒ void
This method returns an undefined value.
Compare element counts
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 79 def verify_structure(xmi_doc, qea_doc) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength # Compare package counts (cache for reuse in verify_properties) @cached_package_matches = matcher.match_packages(xmi_doc, qea_doc) result.add_matches(:packages, @cached_package_matches[:matches].size) result.add_xmi_only(:packages, @cached_package_matches[:xmi_only]) result.add_qea_only(:packages, @cached_package_matches[:qea_only]) # Compare class counts (cache for reuse in verify_properties) @cached_class_matches = matcher.match_classes(xmi_doc, qea_doc) result.add_matches(:classes, @cached_class_matches[:matches].size) result.add_xmi_only(:classes, @cached_class_matches[:xmi_only]) result.add_qea_only(:classes, @cached_class_matches[:qea_only]) # Compare enum counts xmi_enums = count_all_enums(xmi_doc) qea_enums = count_all_enums(qea_doc) if qea_enums < xmi_enums result.add_difference( "Enums: #{xmi_enums} (XMI) vs #{qea_enums} (QEA) - QEA has fewer", ) end # Compare data type counts xmi_dt = count_all_data_types(xmi_doc) qea_dt = count_all_data_types(qea_doc) if qea_dt < xmi_dt result.add_difference( "Data types: #{xmi_dt} (XMI) vs #{qea_dt} (QEA) - QEA has fewer", ) end # Compare association counts xmi_assocs = count_all_associations(xmi_doc) qea_assocs = count_all_associations(qea_doc) result.add_matches(:associations, [xmi_assocs, qea_assocs].min) if qea_assocs < xmi_assocs result.add_difference( "Associations: #{xmi_assocs} (XMI) " \ "vs #{qea_assocs} (QEA) - QEA has fewer", ) end end |