diff --git a/qc_openscenario/checks/reference_checker/uniquely_resolvable_entity_references.py b/qc_openscenario/checks/reference_checker/uniquely_resolvable_entity_references.py
index a6148ad..de06904 100644
--- a/qc_openscenario/checks/reference_checker/uniquely_resolvable_entity_references.py
+++ b/qc_openscenario/checks/reference_checker/uniquely_resolvable_entity_references.py
@@ -61,29 +61,29 @@ def check_rule(checker_data: models.CheckerData) -> None:
root = checker_data.input_file_xml_root
- # List to store problematic vehicle nodes
+ # List to store problematic nodes
errors = []
# Iterate over each 'Catalog' node
for catalog_node in root.findall(".//Catalog"):
- # Dictionary to track 'vehicle' nodes by 'name' attribute
- vehicle_names = {}
+ # Dictionary to track child nodes by 'name' attribute
+ child_names = {}
- # Iterate over 'Vehicle' nodes within current 'Catalog' node
- for vehicle_node in catalog_node.findall(".//Vehicle"):
- name_attr = vehicle_node.attrib.get("name")
+ # Iterate catalog children within current 'Catalog' node
+ for child_node in catalog_node.iterchildren():
+ name_attr = child_node.attrib.get("name")
if name_attr:
- if name_attr in vehicle_names:
+ if name_attr in child_names:
errors.append(
{
"name": name_attr,
- "tag": vehicle_node.tag,
- "first_xpath": get_xpath(root, vehicle_names[name_attr]),
- "duplicate_xpath": get_xpath(root, vehicle_node),
+ "tag": child_node.tag,
+ "first_xpath": get_xpath(root, child_names[name_attr]),
+ "duplicate_xpath": get_xpath(root, child_node),
}
)
else:
- vehicle_names[name_attr] = vehicle_node
+ child_names[name_attr] = child_node
if len(errors) > 0:
issue_id = checker_data.result.register_issue(
@@ -98,7 +98,9 @@ def check_rule(checker_data: models.CheckerData) -> None:
error_name = error["name"]
error_first_xpath = error["first_xpath"]
error_duplicate_xpath = error["duplicate_xpath"]
- error_msg = f"Duplicate vehicle name {error_name}. First occurrence at {error_first_xpath} duplicate at {error_duplicate_xpath}"
+ error_msg = f"Duplicate name {error_name}. First occurrence at {error_first_xpath} duplicate at {error_duplicate_xpath}"
+ logging.error(f"- Error: {error_msg}")
+ logging.error(f"- Duplicate xpath: {error_duplicate_xpath}")
checker_data.result.add_xml_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=reference_constants.CHECKER_ID,
diff --git a/qc_openscenario/checks/schema_checker/schema_is_valid.py b/qc_openscenario/checks/schema_checker/schema_is_valid.py
index 12c63c3..6dcbd73 100644
--- a/qc_openscenario/checks/schema_checker/schema_is_valid.py
+++ b/qc_openscenario/checks/schema_checker/schema_is_valid.py
@@ -75,15 +75,15 @@ def check_rule(checker_data: models.CheckerData) -> None:
)
if not schema_compliant:
- issue_id = checker_data.result.register_issue(
- checker_bundle_name=constants.BUNDLE_NAME,
- checker_id=schema_constants.CHECKER_ID,
- description="Issue flagging when input file does not follow its version schema",
- level=IssueSeverity.ERROR,
- rule_uid=rule_uid,
- )
for error in errors:
+ issue_id = checker_data.result.register_issue(
+ checker_bundle_name=constants.BUNDLE_NAME,
+ checker_id=schema_constants.CHECKER_ID,
+ description="Issue flagging when input file does not follow its version schema",
+ level=IssueSeverity.ERROR,
+ rule_uid=rule_uid,
+ )
checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=schema_constants.CHECKER_ID,
diff --git a/tests/data/uniquely_resolvable_entity_references/long_catalog_negative.xosc b/tests/data/uniquely_resolvable_entity_references/long_catalog_negative.xosc
new file mode 100644
index 0000000..30ef6de
--- /dev/null
+++ b/tests/data/uniquely_resolvable_entity_references/long_catalog_negative.xosc
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/data/uniquely_resolvable_entity_references/long_catalog_positive.xosc b/tests/data/uniquely_resolvable_entity_references/long_catalog_positive.xosc
new file mode 100644
index 0000000..f29cf82
--- /dev/null
+++ b/tests/data/uniquely_resolvable_entity_references/long_catalog_positive.xosc
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/test_reference_checks.py b/tests/test_reference_checks.py
index 6bdb0e0..5f7c688 100644
--- a/tests/test_reference_checks.py
+++ b/tests/test_reference_checks.py
@@ -86,3 +86,57 @@ def test_uniquely_resolvable_negative(
assert len(reference_issues) == 1
assert reference_issues[0].level == IssueSeverity.WARNING
test_utils.cleanup_files()
+
+
+def test_long_catalog_negative(
+ monkeypatch,
+) -> None:
+ base_path = "tests/data/uniquely_resolvable_entity_references/"
+ target_file_name = f"long_catalog_negative.xosc"
+ target_file_path = os.path.join(base_path, target_file_name)
+
+ test_utils.create_test_config(target_file_path)
+
+ test_utils.launch_main(monkeypatch)
+
+ result = Result()
+ result.load_from_file(test_utils.REPORT_FILE_PATH)
+
+ _ = result.get_checker_result(
+ checker_bundle_name=constants.BUNDLE_NAME,
+ checker_id=reference_constants.CHECKER_ID,
+ )
+ reference_issues = result.get_issues_by_rule_uid(
+ "asam.net:xosc:1.2.0:reference_control.uniquely_resolvable_entity_references"
+ )
+ assert len(reference_issues) == 1
+ assert reference_issues[0].level == IssueSeverity.WARNING
+ test_utils.cleanup_files()
+
+
+def test_long_catalog_positive(
+ monkeypatch,
+) -> None:
+ base_path = "tests/data/uniquely_resolvable_entity_references/"
+ target_file_name = f"long_catalog_positive.xosc"
+ target_file_path = os.path.join(base_path, target_file_name)
+
+ test_utils.create_test_config(target_file_path)
+
+ test_utils.launch_main(monkeypatch)
+
+ result = Result()
+ result.load_from_file(test_utils.REPORT_FILE_PATH)
+
+ _ = result.get_checker_result(
+ checker_bundle_name=constants.BUNDLE_NAME,
+ checker_id=reference_constants.CHECKER_ID,
+ )
+ assert (
+ len(
+ result.get_issues_by_rule_uid(
+ "asam.net:xosc:1.2.0:reference_control.uniquely_resolvable_entity_references"
+ )
+ )
+ == 0
+ )