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.
-
#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
#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
121 122 123 124 125 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 121 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
132 133 134 135 136 137 138 139 140 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 132 def verify_properties(xmi_doc, qea_doc) # Verify class properties class_matches = matcher.match_classes(xmi_doc, qea_doc) verify_class_properties(class_matches[:matches]) # Verify package properties 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)
147 148 149 150 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 147 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
73 74 75 76 77 78 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 |
# File 'lib/lutaml/qea/verification/document_verifier.rb', line 73 def verify_structure(xmi_doc, qea_doc) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength # Compare package counts match_result = matcher.match_packages(xmi_doc, qea_doc) result.add_matches(:packages, match_result[:matches].size) result.add_xmi_only(:packages, match_result[:xmi_only]) result.add_qea_only(:packages, match_result[:qea_only]) # Compare class counts match_result = matcher.match_classes(xmi_doc, qea_doc) result.add_matches(:classes, match_result[:matches].size) result.add_xmi_only(:classes, match_result[:xmi_only]) result.add_qea_only(:classes, match_result[: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 |