diff --git a/.github/workflows/push_request_check.yml b/.github/workflows/push_request_check.yml index 08a1d72..797c520 100644 --- a/.github/workflows/push_request_check.yml +++ b/.github/workflows/push_request_check.yml @@ -35,6 +35,7 @@ jobs: cd core/esmf-aspect-meta-model-python poetry install poetry run download-samm-release + poetry run download-samm-cli poetry build - name: run tests diff --git a/.gitignore b/.gitignore index e1dfed0..e698e86 100644 --- a/.gitignore +++ b/.gitignore @@ -69,5 +69,5 @@ dmypy.json # SAMM core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_aspect_meta_model/samm/ -/core/esmf-aspect-meta-model-python/samm-cli/ +core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/samm-cli/ /core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/java_models/resources/ diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/adaptive_graph.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/adaptive_graph.py new file mode 100644 index 0000000..be721b8 --- /dev/null +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/adaptive_graph.py @@ -0,0 +1,131 @@ +import pathlib +import subprocess +import tempfile + +from typing import Optional, Union + +from rdflib import Graph + +from esmf_aspect_meta_model_python import utils +from esmf_aspect_meta_model_python.constants import SAMM_VERSION +from esmf_aspect_meta_model_python.samm_cli import SammCli + + +class AdaptiveGraph(Graph): # TODO: avoid double parsing when an upgrade is not performed + """An RDF graph that can adaptively upgrade SAMM files using the SAMM CLI.""" + + _samm_cli = SammCli() + + def __init__(self, samm_version: str = SAMM_VERSION, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self._samm_version = samm_version + + def _upgrade_ttl_file(self, file_path: pathlib.Path) -> str: + """Run SAMM CLI prettyprint to upgrade a TTL file to the latest version.""" + try: + return self._samm_cli.prettyprint(str(file_path), capture=True) + except subprocess.CalledProcessError as e: + raise RuntimeError(f"SAMM CLI failed for {file_path}:\n{e.stdout}\n{e.stderr}") from e + + def _upgrade_source(self, source_path: pathlib.Path) -> str: + print(f"[INFO] SAMM version mismatch detected in {source_path}. Upgrading...") + + return self._upgrade_ttl_file(source_path) + + def _upgrade_data(self, data: str | bytes) -> str: + print( # TODO: improve logging + f"[INFO] SAMM version mismatch detected in provided data (target v{self._samm_version}) Upgrading..." + ) + + with tempfile.NamedTemporaryFile("wb", suffix=".ttl", delete=False) as tmp: + tmp.write(data.encode("utf-8") if isinstance(data, str) else data) + tmp_path = pathlib.Path(tmp.name) + + try: + return self._upgrade_ttl_file(tmp_path) + finally: + tmp_path.unlink(missing_ok=True) + + def set_samm_version(self, samm_version: str) -> None: + """Set the SAMM version for this graph.""" + self._samm_version = samm_version + + def parse( # type: ignore[override] + self, + *, + source: Optional[str | pathlib.Path] = None, + data: Optional[str | bytes] = None, + **kwargs, + ) -> "AdaptiveGraph": + """ + Parse a TTL file into this graph, upgrading via SAMM CLI if version mismatch detected. + + If a SAMM version mismatch is detected, the TTL file will be upgraded using the SAMM CLI prettyprint + before parsing into this graph. + + Args: + source: Path to the TTL file as pathlib.Path or str. + data: RDF content as string or bytes. + **kwargs: Additional arguments passed to rdflib.Graph.parse(). + + Returns: + self (AdaptiveGraph): The current graph instance with parsed data. + + Raises: + RuntimeError: If the SAMM CLI fails during the upgrade process. + ValueError: If neither 'source' nor 'data' is provided, or if both are provided. + """ + if (source is None) == (data is None): + raise ValueError("Either 'source' or 'data' must be provided.") + + if source: + input_source = source = pathlib.Path(source) + upgrade_method = self._upgrade_source + else: + input_source = data # type: ignore[assignment] + upgrade_method = self._upgrade_data # type: ignore[assignment] + + if utils.has_version_mismatch_from_input(input_source, samm_version=self._samm_version): + data = upgrade_method(input_source) + source = None + + super().parse(source=source, data=data, **kwargs) + + return self + + def __add__(self, other: Union["Graph", "AdaptiveGraph"]) -> "AdaptiveGraph": + """Override addition to propagate SAMM version to the resulting graph.""" + retval = super().__add__(other) + + if isinstance(retval, AdaptiveGraph): + if isinstance(other, AdaptiveGraph) and other._samm_version != self._samm_version: + raise ValueError("SAMM version mismatch during addition.") + + retval.set_samm_version(self._samm_version) + + return retval # type: ignore[return-value] + + def __sub__(self, other: Union["Graph", "AdaptiveGraph"]) -> "AdaptiveGraph": + """Override subtraction to propagate SAMM version to the resulting graph.""" + retval = super().__sub__(other) + + if isinstance(retval, AdaptiveGraph): + if isinstance(other, AdaptiveGraph) and other._samm_version != self._samm_version: + raise ValueError("SAMM version mismatch during subtraction.") + + retval.set_samm_version(self._samm_version) + + return retval # type: ignore[return-value] + + def __mul__(self, other: Union["Graph", "AdaptiveGraph"]) -> "AdaptiveGraph": + """Override multiplication to propagate SAMM version to the resulting graph.""" + retval = super().__mul__(other) + + if isinstance(retval, AdaptiveGraph): + if isinstance(other, AdaptiveGraph) and other._samm_version != self._samm_version: + raise ValueError("SAMM version mismatch during multiplication.") + + retval.set_samm_version(self._samm_version) + + return retval # type: ignore[return-value] diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/constants.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/constants.py index b021688..a728e7d 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/constants.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/constants.py @@ -11,4 +11,7 @@ SAMM_VERSION = "2.2.0" -JAVA_CLI_VERSION = "2.11.1" +JAVA_CLI_VERSION = "2.12.0" + +SAMM_NAMESPACE_PREFIX = "samm" +SAMM_ORG_IDENTIFIER = "org.eclipse.esmf.samm" diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/loader/samm_graph.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/loader/samm_graph.py index 546f2a9..a0ac8e9 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/loader/samm_graph.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/loader/samm_graph.py @@ -8,12 +8,15 @@ # file, You can obtain one at https://mozilla.org/MPL/2.0/. # # SPDX-License-Identifier: MPL-2.0 - from pathlib import Path from typing import List, Optional, Union from rdflib import RDF, Graph, Node +import esmf_aspect_meta_model_python.constants as const + +from esmf_aspect_meta_model_python import utils +from esmf_aspect_meta_model_python.adaptive_graph import AdaptiveGraph from esmf_aspect_meta_model_python.base.aspect import Aspect from esmf_aspect_meta_model_python.base.base import Base from esmf_aspect_meta_model_python.base.property import Property @@ -28,14 +31,12 @@ class SAMMGraph: """Class representing the SAMM graph and its operations.""" - samm_namespace_prefix = "samm" - def __init__(self): - self.rdf_graph = Graph() + self.rdf_graph = AdaptiveGraph() self.samm_graph = Graph() self._cache = DefaultElementCache() - self.samm_version = None + self.samm_version = const.SAMM_VERSION self.aspect = None self.model_elements = None self._samm = None @@ -43,11 +44,7 @@ def __init__(self): def __str__(self) -> str: """Object string representation.""" - str_data = "SAMMGraph" - if self.samm_version: - str_data += f" v{self.samm_version}" - - return str_data + return f"SAMMGraph v{self.samm_version}" def __repr__(self) -> str: """Object representation.""" @@ -71,40 +68,6 @@ def _get_rdf_graph(self, input_data: Union[str, Path], input_type: Optional[str] self._reader = InputHandler(input_data, input_type).get_reader() self.rdf_graph = self._reader.read(input_data) - def _get_samm_version_from_rdf_graph(self) -> str: - """Extracts the SAMM version from the RDF graph. - - This method searches through the RDF graph namespaces to find a prefix that indicates the SAMM version. - - Returns: - str: The SAMM version as a string extracted from the graph. Returns an empty string if no version - can be conclusively identified. - """ - version = "" - - for prefix, namespace in self.rdf_graph.namespace_manager.namespaces(): - if prefix == self.samm_namespace_prefix: - urn_parts = namespace.split(":") - version = urn_parts[-1].replace("#", "") - - return version - - def _get_samm_version(self): - """Retrieve and set the SAMM version from the RDF graph. - - This method extracts the SAMM version from the RDF graph and assigns it to the `samm_version` attribute. - If the SAMM version is not found, it raises a ValueError. - - Raises: - ValueError: If the SAMM version is not found in the RDF graph. - """ - self.samm_version = self._get_samm_version_from_rdf_graph() - - if not self.samm_version: - raise ValueError( - f"SAMM version number was not found in graph. Could not process RDF graph {self.rdf_graph}." - ) - def _get_samm(self): """Initialize the SAMM object with the current SAMM version.""" self._samm = SAMM(self.samm_version) @@ -132,7 +95,6 @@ def parse(self, input_data: Union[str, Path], input_type: Optional[str] = None): SAMMGraph: The instance of the SAMMGraph with the parsed data. """ self._get_rdf_graph(input_data, input_type) - self._get_samm_version() self._get_samm() self._get_samm_graph() @@ -213,12 +175,30 @@ def load_aspect_model(self) -> Aspect: graph = self.rdf_graph + self.samm_graph self._reader.prepare_aspect_model(graph) + self._validate_samm_namespace_version(graph) model_element_factory = ModelElementFactory(self.samm_version, graph, self._cache) self.aspect = model_element_factory.create_element(aspect_urn) return self.aspect + def _validate_samm_namespace_version(self, graph: AdaptiveGraph) -> None: + """ + Validate that the SAMM version in the graph's namespace matches the detected SAMM version. + + Args: + graph: The RDF graph whose namespaces are to be validated. + + Raises: + ValueError: If the SAMM version in the graph's namespace does not match the detected SAMM version. + """ + for version in utils.get_samm_versions_from_graph(graph): + if version != self.samm_version: + raise ValueError( + f"SAMM version mismatch. Found '{version}', but expected '{self.samm_version}'. " + "Ensure all RDF files use a single, consistent SAMM version" + ) + def _get_aspect_from_elements(self): """Geta and save the Aspect element from the model elements.""" if self.model_elements: diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/base.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/base.py index 0d3971c..0bf2b9c 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/base.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/base.py @@ -13,8 +13,9 @@ from pathlib import Path from typing import Union -from rdflib import Graph +import esmf_aspect_meta_model_python.constants as const +from esmf_aspect_meta_model_python.adaptive_graph import AdaptiveGraph from esmf_aspect_meta_model_python.samm_meta_model import SammUnitsGraph @@ -33,9 +34,9 @@ class ResolverInterface(ABC): """ def __init__(self): - self.graph = Graph() + self.graph = AdaptiveGraph() self.samm_graph = None - self.samm_version = "" + self.samm_version = const.SAMM_VERSION @abstractmethod def read(self, input_data: Union[str, Path]): @@ -70,46 +71,5 @@ def _validate_samm_version(samm_version: str): elif samm_version > SammUnitsGraph.SAMM_VERSION: raise ValueError(f"{samm_version} is not supported SAMM version.") - def _get_samm_version_from_graph(self) -> str: - """ - Extracts the SAMM version from the RDF graph. - - This method searches through the RDF graph namespaces to find a prefix that indicate the SAMM version. - - Returns: - str: The SAMM version as a string extracted from the graph. Returns an empty string if no version - can be conclusively identified. - """ - version = "" - - for prefix, namespace in self.graph.namespace_manager.namespaces(): - if prefix == "samm": - urn_parts = namespace.split(":") - version = urn_parts[-1].replace("#", "") - - return version - - def get_samm_version(self) -> str: - """ - Retrieves and validates the specified SAMM version from the provided Aspect model graph. - - This method attempts to extract the version information of the SAMM from a graph. There is also a validation - against known SAMM versions to ensure the version is supported and recognized. - - - Returns: - str: The validated version of SAMM if it is recognized and supported. If the version is not valid, - an appropriate message or value indicating non-recognition is returned. - - Raises: - ValueError: If the extracted version is not supported or if it is not found in the Graph. - - """ - version = self._get_samm_version_from_graph() - self._validate_samm_version(version) - self.samm_version = version - - return version - - def prepare_aspect_model(self, graph: Graph): + def prepare_aspect_model(self, graph: AdaptiveGraph): """Resolve all additional graph elements if needed.""" diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/data_string.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/data_string.py index 541e903..841409a 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/data_string.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/data_string.py @@ -12,8 +12,7 @@ from pathlib import Path from typing import Union -from rdflib import Graph - +from esmf_aspect_meta_model_python.adaptive_graph import AdaptiveGraph from esmf_aspect_meta_model_python.resolver.base import ResolverInterface @@ -33,7 +32,7 @@ def read(self, data_string: Union[str, Path]): Returns: RDFGraph: An object representing the RDF graph constructed from the input data. """ - self.graph = Graph() + self.graph = AdaptiveGraph() self.graph.parse(data=str(data_string) if isinstance(data_string, Path) else data_string) return self.graph diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/local_file.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/local_file.py index e4dadfe..bdbdfbb 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/local_file.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/local_file.py @@ -13,16 +13,14 @@ from pathlib import Path from typing import Dict, List, Optional, Tuple, Union -from rdflib import Graph - +from esmf_aspect_meta_model_python.adaptive_graph import AdaptiveGraph +from esmf_aspect_meta_model_python.constants import SAMM_NAMESPACE_PREFIX, SAMM_ORG_IDENTIFIER from esmf_aspect_meta_model_python.resolver.base import ResolverInterface class LocalFileResolver(ResolverInterface): """Local storage aspect model file resolver.""" - samm_namespace_prefix = "samm" - def __init__(self): super().__init__() @@ -37,7 +35,7 @@ def validate_file(file_path: Union[str, Path]): if not exists(file_path): raise FileNotFoundError(f"Could not find a file {file_path}") - def read(self, file_path: Union[str, Path]) -> Graph: + def read(self, file_path: Union[str, Path]) -> AdaptiveGraph: """ Read an RDF graph stored in the local file. @@ -53,8 +51,8 @@ def read(self, file_path: Union[str, Path]) -> Graph: self.file_path = file_path self.validate_file(self.file_path) - self.graph = Graph() - self.graph.parse(self.file_path) + self.graph = AdaptiveGraph() + self.graph.parse(source=self.file_path) return self.graph @@ -73,8 +71,8 @@ def _parse_namespace(prefix_namespace: str) -> Tuple[Optional[str], Optional[str if len(namespace_info) == 4: urn, namespace_id, namespace_specific_str, version = namespace_info - if urn == "urn" and namespace_id == "samm": - if namespace_specific_str == "org.eclipse.esmf.samm": + if urn == "urn" and namespace_id == SAMM_NAMESPACE_PREFIX: + if namespace_specific_str == SAMM_ORG_IDENTIFIER: namespace_specific_str = None version = None else: @@ -106,7 +104,7 @@ def _get_dependency_folders(self, file_path: str) -> List[str]: :return: list of dependency folders """ if file_path != self.file_path: - self.graph.parse(file_path, format="turtle") + self.graph.parse(source=file_path, format="turtle") dependency_folders = self._get_dirs_for_advanced_loading(file_path) @@ -161,7 +159,7 @@ def _get_dependency_files( return file_dependencies - def prepare_aspect_model(self, graph: Graph): + def prepare_aspect_model(self, graph: AdaptiveGraph): """Parse namespaces from the Aspect model. :param graph: RDF Graph diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/base.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/base.py index d5fba53..a3e864b 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/base.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/base.py @@ -8,6 +8,7 @@ # file, You can obtain one at https://mozilla.org/MPL/2.0/. # # SPDX-License-Identifier: MPL-2.0 +import platform import subprocess from os.path import exists, join @@ -33,9 +34,14 @@ def __init__(self): def _get_client_path(): """Get path to the SAMM CLI executable file.""" base_path = Path(__file__).resolve() - cli_path = join(base_path.parents[0], "samm-cli", "samm.exe") + cli_dir = join(base_path.parents[0], "samm-cli") - return cli_path + if platform.system() == "Windows": + cli_file = "samm.exe" + else: + cli_file = "samm" # Unix-like systems + + return join(cli_dir, cli_file) @staticmethod def _format_argument(key: str, value: Any) -> str: @@ -74,7 +80,7 @@ def _validate_client(self): if not exists(self._samm): download_samm_cli() - def _call_function(self, function_name, path_to_model, *args, command_type=None, **kwargs): + def _call_function(self, function_name, path_to_model, *args, command_type=None, capture=False, **kwargs): """Run a SAMM CLI function as a subprocess. Args: @@ -82,14 +88,20 @@ def _call_function(self, function_name, path_to_model, *args, command_type=None, path_to_model: Path to the model file *args: Positional arguments (flags) command_type: Command type (must be one of SAMMCLICommandTypes values) + capture: If True, run with capture_output=True, text=True, check=True and return stdout **kwargs: Keyword arguments Raises: ValueError: If command_type is not one of the allowed types + [subprocess.CalledProcessError]: If capture is True and the subprocess call fails + + Returns: + The stdout of the subprocess if capture is True, otherwise None """ if command_type is None: command_type = SAMMCLICommandTypes.ASPECT + call_kwargs = {} call_args = [self._samm, command_type, path_to_model] + function_name.split() if args: @@ -98,18 +110,23 @@ def _call_function(self, function_name, path_to_model, *args, command_type=None, if kwargs: call_args.extend(self._process_kwargs(kwargs)) - subprocess.run(call_args) + if capture: + call_kwargs.update(capture_output=True, text=True, check=True) + + result = subprocess.run(call_args, **call_kwargs) - def validate(self, path_to_model, *args, **kwargs): + return result.stdout + + def validate(self, path_to_model, *args, capture=False, **kwargs): """Validate Aspect Model. param path_to_model: local path to the aspect model file (*.ttl) possible arguments: custom-resolver: use an external resolver for the resolution of the model elements """ - self._call_function(SAMMCLICommands.VALIDATE, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.VALIDATE, path_to_model, *args, capture=capture, **kwargs) - def prettyprint(self, path_to_model, *args, **kwargs): + def prettyprint(self, path_to_model, *args, capture=False, **kwargs): """Pretty-print Aspect Model. Formats the Aspect Model file with proper indentation and structure. @@ -120,9 +137,9 @@ def prettyprint(self, path_to_model, *args, **kwargs): - overwrite, w: overwrite the input file (use as flag without value) - custom-resolver: use an external resolver for the resolution of the model elements """ - self._call_function(SAMMCLICommands.PRETTYPRINT, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.PRETTYPRINT, path_to_model, *args, capture=capture, **kwargs) - def usage(self, path_to_model, *args, **kwargs): + def usage(self, path_to_model, *args, capture=False, **kwargs): """Shows where model elements are used in an Aspect. param path_to_model: local path to the aspect model file (*.ttl) or an element URN @@ -137,9 +154,9 @@ def usage(self, path_to_model, *args, **kwargs): # Show usage for an element URN with models root samm_cli.usage("urn:samm:org.eclipse.example:1.0.0#MyElement", models_root="/path/to/models") """ - self._call_function(SAMMCLICommands.USAGE, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.USAGE, path_to_model, *args, capture=capture, **kwargs) - def to_openapi(self, path_to_model, *args, **kwargs): + def to_openapi(self, path_to_model, *args, capture=False, **kwargs): """Generate OpenAPI specification for an Aspect Model. param path_to_model: local path to the aspect model file (*.ttl) @@ -162,9 +179,9 @@ def to_openapi(self, path_to_model, *args, **kwargs): - language, l: the language from the model for which an OpenAPI specification should be generated (default: en) custom-resolver: use an external resolver for the resolution of the model elements """ - self._call_function(SAMMCLICommands.TO_OPENAPI, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.TO_OPENAPI, path_to_model, *args, capture=capture, **kwargs) - def to_schema(self, path_to_model, *args, **kwargs): + def to_schema(self, path_to_model, *args, capture=False, **kwargs): """Generate JSON schema for an Aspect Model. param path_to_model: local path to the aspect model file (*.ttl) @@ -173,9 +190,9 @@ def to_schema(self, path_to_model, *args, **kwargs): - language, -l: the language from the model for which a JSON schema should be generated (default: en) - custom-resolver: use an external resolver for the resolution of the model elements """ - self._call_function(SAMMCLICommands.TO_SCHEMA, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.TO_SCHEMA, path_to_model, *args, capture=capture, **kwargs) - def to_json(self, path_to_model, *args, **kwargs): + def to_json(self, path_to_model, *args, capture=False, **kwargs): """Generate example JSON payload data for an Aspect Model. param path_to_model: local path to the aspect model file (*.ttl) @@ -183,9 +200,9 @@ def to_json(self, path_to_model, *args, **kwargs): - output, -o: output file path (default: stdout) - custom-resolver: use an external resolver for the resolution of the model elements """ - self._call_function(SAMMCLICommands.TO_JSON, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.TO_JSON, path_to_model, *args, capture=capture, **kwargs) - def to_html(self, path_to_model, *args, **kwargs): + def to_html(self, path_to_model, *args, capture=False, **kwargs): """Generate HTML documentation for an Aspect Model. param path_to_model: local path to the aspect model file (*.ttl) @@ -195,9 +212,9 @@ def to_html(self, path_to_model, *args, **kwargs): - language, -l: the language from the model for which the HTML should be generated (default: en) - custom-resolver: use an external resolver for the resolution of the model elements """ - self._call_function(SAMMCLICommands.TO_HTML, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.TO_HTML, path_to_model, *args, capture=capture, **kwargs) - def to_png(self, path_to_model, *args, **kwargs): + def to_png(self, path_to_model, *args, capture=False, **kwargs): """Generate PNG diagram for Aspect Model. param path_to_model: local path to the aspect model file (*.ttl) @@ -208,9 +225,9 @@ def to_png(self, path_to_model, *args, **kwargs): - language, -l: the language from the model for which the diagram should be generated (default: en) - custom-resolver: use an external resolver for the resolution of the model elements """ - self._call_function(SAMMCLICommands.TO_PNG, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.TO_PNG, path_to_model, *args, capture=capture, **kwargs) - def to_svg(self, path_to_model, *args, **kwargs): + def to_svg(self, path_to_model, *args, capture=False, **kwargs): """Generate SVG diagram for Aspect Model. param path_to_model: local path to the aspect model file (*.ttl) @@ -219,9 +236,9 @@ def to_svg(self, path_to_model, *args, **kwargs): - language, -l: the language from the model for which the diagram should be generated (default: en) - custom-resolver: use an external resolver for the resolution of the model elements """ - self._call_function(SAMMCLICommands.TO_SVG, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.TO_SVG, path_to_model, *args, capture=capture, **kwargs) - def to_java(self, path_to_model, *args, **kwargs): + def to_java(self, path_to_model, *args, capture=False, **kwargs): """Generate Java classes from an Aspect Model. param path_to_model: local path to the aspect model file (*.ttl) @@ -242,9 +259,9 @@ def to_java(self, path_to_model, *args, **kwargs): - name_prefix, namePrefix: name prefix for generated Aspect, Entity Java classes - name_postfix, namePostfix: name postfix for generated Aspect, Entity Java classes """ - self._call_function(SAMMCLICommands.TO_JAVA, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.TO_JAVA, path_to_model, *args, capture=capture, **kwargs) - def to_asyncapi(self, path_to_model, *args, **kwargs): + def to_asyncapi(self, path_to_model, *args, capture=False, **kwargs): """Generate AsyncAPI specification for an Aspect Model. param path_to_model: local path to the aspect model file (*.ttl) @@ -259,9 +276,9 @@ def to_asyncapi(self, path_to_model, *args, **kwargs): - separate_files, sf: create separate files for each schema (use as flag without value) - custom_resolver: use an external resolver for the resolution of the model elements """ - self._call_function(SAMMCLICommands.TO_ASYNCAPI, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.TO_ASYNCAPI, path_to_model, *args, capture=capture, **kwargs) - def to_jsonld(self, path_to_model, *args, **kwargs): + def to_jsonld(self, path_to_model, *args, capture=False, **kwargs): """Generate JSON-LD representation of an Aspect Model. param path_to_model: local path to the aspect model file (*.ttl) @@ -269,9 +286,9 @@ def to_jsonld(self, path_to_model, *args, **kwargs): - output, o: output file path (default: stdout) - custom_resolver: use an external resolver for the resolution of the model elements """ - self._call_function(SAMMCLICommands.TO_JSONLD, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.TO_JSONLD, path_to_model, *args, capture=capture, **kwargs) - def to_sql(self, path_to_model, *args, **kwargs): + def to_sql(self, path_to_model, *args, capture=False, **kwargs): """Generate SQL script that sets up a table for data for this Aspect. param path_to_model: local path to the aspect model file (*.ttl) @@ -314,9 +331,10 @@ def to_sql(self, path_to_model, *args, **kwargs): # or call the CLI directly. Current implementation supports single custom column. samm_cli.to_sql("AspectModel.ttl", custom_column=("column1 STRING", "column2 INT")) """ - self._call_function(SAMMCLICommands.TO_SQL, path_to_model, *args, **kwargs) + return self._call_function(SAMMCLICommands.TO_SQL, path_to_model, *args, capture=capture, **kwargs) - # def to_aas(self, path_to_model, *args, **kwargs): # FIXME: https://github.com/eclipse-esmf/esmf-sdk/issues/802 + # FIXME: https://github.com/eclipse-esmf/esmf-sdk/issues/802 + # def to_aas(self, path_to_model, *args, capture=False, **kwargs): # """Generate an Asset Administration Shell (AAS) submodel template from an Aspect Model. # # param path_to_model: local path to the aspect model file (*.ttl) @@ -326,9 +344,9 @@ def to_sql(self, path_to_model, *args, **kwargs): # - aspect_data, a: path to a JSON file containing aspect data corresponding to the Aspect Model # - custom_resolver: use an external resolver for the resolution of the model elements # """ - # self._call_function(SAMMCLICommands.AAS_TO_ASPECT, path_to_model, *args, **kwargs) + # return self._call_function(SAMMCLICommands.AAS_TO_ASPECT, path_to_model, *args, capture=capture, **kwargs) - def edit_move(self, path_to_model, element, namespace=None, *args, **kwargs): + def edit_move(self, path_to_model, element, namespace=None, *args, capture=False, **kwargs): """Move a model element definition from its current place to another existing or new file in the same or another namespace. @@ -364,9 +382,9 @@ def edit_move(self, path_to_model, element, namespace=None, *args, **kwargs): if namespace: function_name += f" {namespace}" - self._call_function(function_name, path_to_model, *args, **kwargs) + return self._call_function(function_name, path_to_model, *args, capture=capture, **kwargs) - def edit_newversion(self, path_to_model, version_type=None, *args, **kwargs): + def edit_newversion(self, path_to_model, version_type=None, *args, capture=False, **kwargs): """Create a new version of an existing file or a complete namespace. param path_to_model: local path to the aspect model file (*.ttl) or a namespace URN @@ -405,10 +423,11 @@ def edit_newversion(self, path_to_model, version_type=None, *args, **kwargs): args_list = list(args) if version_type and version_type in ("major", "minor", "micro"): args_list.insert(0, version_type) + return self._call_function( + SAMMCLICommands.EDIT_NEWVERSION, path_to_model, *args_list, capture=capture, **kwargs + ) - self._call_function(SAMMCLICommands.EDIT_NEWVERSION, path_to_model, *args_list, **kwargs) - - def aas_to_aspect(self, aas_file, *args, **kwargs): + def aas_to_aspect(self, aas_file, *args, capture=False, **kwargs): """Translate Asset Administration Shell (AAS) Submodel Templates to Aspect Models. param aas_file: path to the AAS file (*.aasx, *.xml, *.json) @@ -434,11 +453,16 @@ def aas_to_aspect(self, aas_file, *args, **kwargs): # or using short form samm_cli.aas_to_aspect("AssetAdminShell.aasx", s=["1", "2"]) """ - self._call_function( - SAMMCLICommands.AAS_TO_ASPECT, aas_file, *args, command_type=SAMMCLICommandTypes.AAS, **kwargs + return self._call_function( + SAMMCLICommands.AAS_TO_ASPECT, + aas_file, + *args, + command_type=SAMMCLICommandTypes.AAS, + capture=capture, + **kwargs, ) - def aas_list(self, aas_file, *args, **kwargs): + def aas_list(self, aas_file, *args, capture=False, **kwargs): """Retrieve a list of submodel templates contained within the provided Asset Administration Shell (AAS) file. param aas_file: path to the AAS file (*.aasx, *.xml, *.json) @@ -447,9 +471,16 @@ def aas_list(self, aas_file, *args, **kwargs): # List all submodel templates in an AAS file samm_cli.aas_list("AssetAdminShell.aasx") """ - self._call_function(SAMMCLICommands.AAS_LIST, aas_file, *args, command_type=SAMMCLICommandTypes.AAS, **kwargs) + return self._call_function( + SAMMCLICommands.AAS_LIST, + aas_file, + *args, + command_type=SAMMCLICommandTypes.AAS, + capture=capture, + **kwargs, + ) - def package_import(self, namespace_package, *args, **kwargs): + def package_import(self, namespace_package, *args, capture=False, **kwargs): """Imports a Namespace Package (file or URL) into a given models' directory. param namespace_package: path to the namespace package file (.zip) or URL @@ -474,11 +505,16 @@ def package_import(self, namespace_package, *args, **kwargs): # Force import samm_cli.package_import("MyPackage.zip", "force", models_root="c:\\models") """ - self._call_function( - SAMMCLICommands.PACKAGE_IMPORT, namespace_package, *args, command_type=SAMMCLICommandTypes.PACKAGE, **kwargs + return self._call_function( + SAMMCLICommands.PACKAGE_IMPORT, + namespace_package, + *args, + command_type=SAMMCLICommandTypes.PACKAGE, + capture=capture, + **kwargs, ) - def package_export(self, model_or_urn, *args, **kwargs): + def package_export(self, model_or_urn, *args, capture=False, **kwargs): """Exports an Aspect Model with its dependencies or a complete namespace to a Namespace Package (.zip). param model_or_urn: path to aspect model file (*.ttl) or namespace URN @@ -503,6 +539,11 @@ def package_export(self, model_or_urn, *args, **kwargs): # Export to specific location samm_cli.package_export("AspectModel.ttl", output="c:\\exports\\my-package.zip") """ - self._call_function( - SAMMCLICommands.PACKAGE_EXPORT, model_or_urn, *args, command_type=SAMMCLICommandTypes.PACKAGE, **kwargs + return self._call_function( + SAMMCLICommands.PACKAGE_EXPORT, + model_or_urn, + *args, + command_type=SAMMCLICommandTypes.PACKAGE, + capture=capture, + **kwargs, ) diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/constants.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/constants.py index 57f93a9..1889e75 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/constants.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/constants.py @@ -16,11 +16,14 @@ class SAMMCliConstants: - BASE_PATH = Template("https://github.com/eclipse-esmf/esmf-sdk/releases/download/v$version_number/$file_name") - JAVA_CLI_VERSION = JAVA_CLI_VERSION - LINUX_FILE_NAME = Template("samm-cli-$version_number-linux-x86_64.tar.gz") SAMM_VERSION = SAMM_VERSION + JAVA_CLI_VERSION = JAVA_CLI_VERSION + + BASE_PATH = Template("https://github.com/eclipse-esmf/esmf-sdk/releases/download/v$version_number/$file_name") + WIN_FILE_NAME = Template("samm-cli-$version_number-windows-x86_64.zip") + LINUX_FILE_NAME = Template("samm-cli-$version_number-linux-x86_64.tar.gz") + MAC_FILE_NAME = Template("samm-cli-$version_number-macos-x86_64.tar.gz") class SAMMCLICommands: diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/download.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/download.py index 2686376..aa40971 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/download.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli/download.py @@ -1,13 +1,14 @@ """Download SAMM CLI. -Windows: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.10.2/samm-cli-2.10.2-windows-x86_64.zip - Linux: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.10.2/samm-cli-2.10.2-linux-x86_64.tar.gz - JAR: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.10.2/samm-cli-2.10.2.jar +Windows: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.12.0/samm-cli-2.12.0-windows-x86_64.zip + Linux: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.12.0/samm-cli-2.12.0-linux-x86_64.tar.gz + JAR: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.12.0/samm-cli-2.12.0.jar """ import os import platform import sys +import tarfile import zipfile from pathlib import Path @@ -24,6 +25,8 @@ def get_samm_cli_file_name(): file_name = Const.WIN_FILE_NAME.substitute(version_number=Const.JAVA_CLI_VERSION) elif platform.system() == "Linux": file_name = Const.LINUX_FILE_NAME.substitute(version_number=Const.JAVA_CLI_VERSION) + elif platform.system() == "Darwin": # macOS + file_name = Const.MAC_FILE_NAME.substitute(version_number=Const.JAVA_CLI_VERSION) else: raise NotImplementedError( f"Please download a SAMM CLI manually for your operation system from '{Const.BASE_PATH}'" @@ -37,6 +40,8 @@ def download_archive_file(url, archive_file): with open(archive_file, "wb") as f: print("Downloading %s" % archive_file) response = requests.get(url, allow_redirects=True, stream=True) + response.raise_for_status() # Fail fast if HTTP error + content_len = response.headers.get("content-length") if content_len is None: @@ -57,6 +62,18 @@ def download_archive_file(url, archive_file): sys.stdout.flush() +def extract_archive(archive_file, dest_dir): + """Extract archive depending on its file type.""" + if archive_file.endswith(".zip"): + with zipfile.ZipFile(archive_file) as archive: + archive.extractall(dest_dir) + elif archive_file.endswith((".tar.gz", ".tgz")): + with tarfile.open(archive_file, mode="r:gz") as archive: + archive.extractall(dest_dir) + else: + raise ValueError(f"Unsupported archive format: {archive_file}") + + def download_samm_cli(): try: samm_cli_file_name = get_samm_cli_file_name() @@ -72,11 +89,7 @@ def download_samm_cli(): print("\nSAMM CLI archive file downloaded") print("Start extracting files") - archive = zipfile.ZipFile(archive_file) - extracted_files_path = os.path.join(dir_path, "samm-cli") - for file in archive.namelist(): - archive.extract(file, extracted_files_path) - archive.close() + extract_archive(archive_file, dest_dir=os.path.join(dir_path, "samm-cli")) print("Done extracting files") print("Deleting SAMM CLI archive file") diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/utils.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/utils.py new file mode 100644 index 0000000..db5643e --- /dev/null +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/utils.py @@ -0,0 +1,39 @@ +import pathlib + +from typing import Iterator, Union + +from rdflib import Graph + +from esmf_aspect_meta_model_python.constants import SAMM_NAMESPACE_PREFIX, SAMM_ORG_IDENTIFIER + + +def _parse_graph_from_input(input_source: Union[str, pathlib.Path]) -> Graph: + """Create and populate an RDF graph from a path or Turtle string.""" + graph = Graph() + + if isinstance(input_source, pathlib.Path): + graph.parse(input_source) + else: # str containing turtle data + graph.parse(data=input_source, format="turtle") + + return graph + + +def get_samm_versions_from_graph(graph: Graph) -> Iterator[str]: + """Yield all SAMM versions found in the RDF graph namespaces.""" + for prefix, namespace in graph.namespace_manager.namespaces(): + if prefix.startswith(SAMM_NAMESPACE_PREFIX): + parts = namespace.split(":") + + if len(parts) >= 5 and parts[2] == SAMM_ORG_IDENTIFIER: + yield parts[-1].strip("#") + + +def has_version_mismatch_in_graph(graph: Graph, samm_version: str) -> bool: + """Check if there is a SAMM version mismatch in the provided RDF graph.""" + return any(v != samm_version for v in get_samm_versions_from_graph(graph)) + + +def has_version_mismatch_from_input(input_source: Union[str, pathlib.Path], samm_version: str) -> bool: + """Detect SAMM version mismatch from an input source (path or Turtle string).""" + return has_version_mismatch_in_graph(_parse_graph_from_input(input_source), samm_version=samm_version) diff --git a/core/esmf-aspect-meta-model-python/scripts/download_samm_cli.py b/core/esmf-aspect-meta-model-python/scripts/download_samm_cli.py index abd5c32..25bb83f 100644 --- a/core/esmf-aspect-meta-model-python/scripts/download_samm_cli.py +++ b/core/esmf-aspect-meta-model-python/scripts/download_samm_cli.py @@ -1,12 +1,11 @@ """Download SAMM CLI. -Windows: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.11.1/samm-cli-2.11.1-windows-x86_64.zip - Linux: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.11.1/samm-cli-2.11.1-linux-x86_64.tar.gz - JAR: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.11.1/samm-cli-2.11.1.jar +Windows: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.12.0/samm-cli-2.12.0-windows-x86_64.zip + Linux: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.12.0/samm-cli-2.12.0-linux-x86_64.tar.gz + JAR: https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.12.0/samm-cli-2.12.0.jar """ from esmf_aspect_meta_model_python.samm_cli.download import download_samm_cli - if __name__ == "__main__": download_samm_cli() diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithBlankNode.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithBlankNode.ttl similarity index 87% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithBlankNode.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithBlankNode.ttl index 6170a6d..0ef1fd3 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithBlankNode.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithBlankNode.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithBlankNode a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCode.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithCode.ttl similarity index 81% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCode.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithCode.ttl index 33a254f..510b866 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCode.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithCode.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithCode a samm:Aspect ; samm:properties ( :testProperty ) ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollection.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithCollection.ttl similarity index 86% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollection.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithCollection.ttl index 3f9d283..94c890d 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollection.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithCollection.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithCollection a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollectionWithElementCharacteristic.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithCollectionWithElementCharacteristic.ttl similarity index 86% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollectionWithElementCharacteristic.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithCollectionWithElementCharacteristic.ttl index 0c264e7..dbf9368 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollectionWithElementCharacteristic.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithCollectionWithElementCharacteristic.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithCollectionWithElementCharacteristic a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithDuration.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithDuration.ttl similarity index 82% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithDuration.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithDuration.ttl index 440f716..ce4199d 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithDuration.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithDuration.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithDuration a samm:Aspect ; samm:properties ( :testProperty ) ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithList.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithList.ttl similarity index 85% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithList.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithList.ttl index 4aa8f95..8a1fb21 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithList.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithList.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithList a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithMeasurement.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithMeasurement.ttl similarity index 82% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithMeasurement.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithMeasurement.ttl index d91bbff..32a5afb 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithMeasurement.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithMeasurement.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithMeasurement a samm:Aspect ; samm:properties ( :testProperty ) ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithQuantifiableAndUnit.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithQuantifiableAndUnit.ttl similarity index 82% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithQuantifiableAndUnit.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithQuantifiableAndUnit.ttl index 006c736..7d5c3ba 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithQuantifiableAndUnit.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithQuantifiableAndUnit.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithQuantifiableAndUnit a samm:Aspect ; samm:properties ( :testProperty ) ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSet.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithSet.ttl similarity index 85% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSet.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithSet.ttl index 28ec741..fbde8e1 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSet.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithSet.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithSet a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSimpleEnum.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithSimpleEnum.ttl similarity index 84% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSimpleEnum.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithSimpleEnum.ttl index f95014b..2d34c36 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSimpleEnum.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithSimpleEnum.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :TestAspect a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSortedSet.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithSortedSet.ttl similarity index 86% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSortedSet.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithSortedSet.ttl index c10c4a9..8df888a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSortedSet.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithSortedSet.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithSortedSet a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithState.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithState.ttl similarity index 84% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithState.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithState.ttl index 54635f4..72ef69c 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithState.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithState.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :TestAspect a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithStructuredValue.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithStructuredValue.ttl similarity index 86% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithStructuredValue.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithStructuredValue.ttl index f665b19..13d07bd 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithStructuredValue.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0/AspectWithStructuredValue.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithStructuredValue a samm:Aspect ; samm:properties ( :date ) ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithConstrainedCollection.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithConstrainedCollection.ttl similarity index 88% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithConstrainedCollection.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithConstrainedCollection.ttl index 4423134..bf8e55a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithConstrainedCollection.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithConstrainedCollection.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithConstrainedCollection a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithEncodingConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithEncodingConstraint.ttl similarity index 87% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithEncodingConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithEncodingConstraint.ttl index 2b6064c..6276edd 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithEncodingConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithEncodingConstraint.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithEncodingConstraint a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithFixedPoint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithFixedPoint.ttl similarity index 87% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithFixedPoint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithFixedPoint.ttl index 3251d9a..5bf72f0 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithFixedPoint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithFixedPoint.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithFixedPoint a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLanguageConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithLanguageConstraint.ttl similarity index 87% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLanguageConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithLanguageConstraint.ttl index 51f1011..fa7adf4 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLanguageConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithLanguageConstraint.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithLanguageConstraint a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLengthConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithLengthConstraint.ttl similarity index 87% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLengthConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithLengthConstraint.ttl index ada882b..2ea2b80 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLengthConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithLengthConstraint.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithLengthConstraint a samm:Aspect ; samm:preferredName "Test Aspect"@en ; @@ -40,4 +40,3 @@ samm-c:maxValue "10"^^xsd:nonNegativeInteger ; ] ; samm-c:baseCharacteristic samm-c:Text . - diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLocaleConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithLocaleConstraint.ttl similarity index 87% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLocaleConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithLocaleConstraint.ttl index a1c11e3..65e68a8 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLocaleConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithLocaleConstraint.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithLanguageConstraint a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithMultipleConstraints.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithMultipleConstraints.ttl similarity index 90% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithMultipleConstraints.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithMultipleConstraints.ttl index 5654a91..f14a8b8 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithMultipleConstraints.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithMultipleConstraints.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithRangeConstraint a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithMultipleOneValueConstraints.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithMultipleOneValueConstraints.ttl similarity index 90% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithMultipleOneValueConstraints.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithMultipleOneValueConstraints.ttl index 78f9eba..c398530 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithMultipleOneValueConstraints.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithMultipleOneValueConstraints.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithRangeConstraint a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithRangeConstraint.ttl similarity index 88% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithRangeConstraint.ttl index 8e8697b..f621cc4 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithRangeConstraint.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithRangeConstraint a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl similarity index 89% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl index 56ebaf0..45e71c7 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithRangeConstraintInclBoundDefinitionProperties a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRegularExpressionConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithRegularExpressionConstraint.ttl similarity index 87% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRegularExpressionConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithRegularExpressionConstraint.ttl index a7387e0..51d31b4 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRegularExpressionConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0/AspectWithRegularExpressionConstraint.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithRegularExpressionConstraint a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractEntity.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractEntity.ttl similarity index 93% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractEntity.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractEntity.ttl index 58856f5..53f948c 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractEntity.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractEntity.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithAbstractEntity a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractEntityMultipleAttributes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractEntityMultipleAttributes.ttl similarity index 92% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractEntityMultipleAttributes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractEntityMultipleAttributes.ttl index 74d9ea7..324d28a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractEntityMultipleAttributes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractEntityMultipleAttributes.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithAbstractEntity a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyBlankNode.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractPropertyBlankNode.ttl similarity index 90% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyBlankNode.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractPropertyBlankNode.ttl index 8dd7110..f635dfe 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyBlankNode.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractPropertyBlankNode.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithAbstractEntity a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl similarity index 89% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl index acee99b..59d6f18 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithAbstractEntity a samm:Aspect ; samm:properties ( :testProperty1 ) ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyMultipleAttributes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractPropertyMultipleAttributes.ttl similarity index 91% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyMultipleAttributes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractPropertyMultipleAttributes.ttl index f685e5a..654b06f 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyMultipleAttributes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithAbstractPropertyMultipleAttributes.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithAbstractEntity a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntity.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithEntity.ttl similarity index 91% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntity.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithEntity.ttl index 91e3eb9..33a3724 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntity.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithEntity.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithEntity a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntityEnum.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithEntityEnum.ttl similarity index 91% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntityEnum.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithEntityEnum.ttl index 6ed8b29..908917a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntityEnum.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithEntityEnum.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :TestAspect a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntityExtendingFileResource.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithEntityExtendingFileResource.ttl similarity index 83% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntityExtendingFileResource.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithEntityExtendingFileResource.ttl index f50b8f5..7004944 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntityExtendingFileResource.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithEntityExtendingFileResource.ttl @@ -9,10 +9,10 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . +@prefix : . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . @prefix xsd: . :AspectWithAbstractEntity a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithFileResourceEntity.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithFileResourceEntity.ttl similarity index 79% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithFileResourceEntity.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithFileResourceEntity.ttl index 47c1372..eb02d6b 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithFileResourceEntity.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithFileResourceEntity.ttl @@ -9,10 +9,10 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . +@prefix : . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . @prefix xsd: . :AspectWithAbstractEntity a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl similarity index 94% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl index 5eada1c..8dec0a6 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithAbstractEntity a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultipleEntitiesSameExtend.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithMultipleEntitiesSameExtend.ttl similarity index 90% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultipleEntitiesSameExtend.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithMultipleEntitiesSameExtend.ttl index 1c55104..5055202 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultipleEntitiesSameExtend.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithMultipleEntitiesSameExtend.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 # -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithAbstractEntity a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultiplePropertiesSameExtend.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithMultiplePropertiesSameExtend.ttl similarity index 92% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultiplePropertiesSameExtend.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithMultiplePropertiesSameExtend.ttl index 39d7993..b9543d2 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultiplePropertiesSameExtend.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithMultiplePropertiesSameExtend.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithAbstractEntity a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithPoint3d.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithPoint3d.ttl similarity index 85% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithPoint3d.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithPoint3d.ttl index 2bd5145..f76c813 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithPoint3d.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithPoint3d.ttl @@ -9,10 +9,10 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . +@prefix : . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . @prefix xsd: . :TestAspect a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeries.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithTimeSeries.ttl similarity index 85% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeries.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithTimeSeries.ttl index 644913e..eadddf5 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeries.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithTimeSeries.ttl @@ -9,12 +9,12 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . +@prefix : . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithTimeSeries a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeriesWithComplexType.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithTimeSeriesWithComplexType.ttl similarity index 88% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeriesWithComplexType.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithTimeSeriesWithComplexType.ttl index ccc72e0..4281527 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeriesWithComplexType.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithTimeSeriesWithComplexType.ttl @@ -9,12 +9,12 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . +@prefix : . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithTimeSeries a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithUnusedExtendingEntity.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithUnusedExtendingEntity.ttl similarity index 91% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithUnusedExtendingEntity.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithUnusedExtendingEntity.ttl index 811c752..26b20c0 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithUnusedExtendingEntity.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0/AspectWithUnusedExtendingEntity.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithAbstractEntity a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_event.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.2.0/aspect_with_event.ttl similarity index 78% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_event.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.2.0/aspect_with_event.ttl index 009858d..37ef934 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_event.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.2.0/aspect_with_event.ttl @@ -9,14 +9,14 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . -@prefix unit: . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . +@prefix unit: . @prefix rdf: . @prefix rdfs: . @prefix xsd: . -@prefix : . +@prefix : . :AspectDefault a samm:Aspect; samm:properties (:property1); diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_event_with_parameters.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.2.0/aspect_with_event_with_parameters.ttl similarity index 80% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_event_with_parameters.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.2.0/aspect_with_event_with_parameters.ttl index c972606..a72eeba 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_event_with_parameters.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.2.0/aspect_with_event_with_parameters.ttl @@ -9,14 +9,14 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . -@prefix unit: . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . +@prefix unit: . @prefix rdf: . @prefix rdfs: . @prefix xsd: . -@prefix : . +@prefix : . :AspectDefault a samm:Aspect ; samm:properties ( :property1 ) ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_multiple_event.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.2.0/aspect_with_multiple_event.ttl similarity index 85% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_multiple_event.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.2.0/aspect_with_multiple_event.ttl index 2e38212..e06d175 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_multiple_event.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.2.0/aspect_with_multiple_event.ttl @@ -9,14 +9,14 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . -@prefix unit: . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . +@prefix unit: . @prefix rdf: . @prefix rdfs: . @prefix xsd: . -@prefix : . +@prefix : . :AspectDefault a samm:Aspect; samm:properties (:property1); diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/Aspect.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/Aspect.ttl similarity index 78% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/Aspect.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/Aspect.ttl index 8f8dc30..07ce6e2 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/Aspect.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/Aspect.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :Aspect a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl similarity index 83% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl index c9fe26a..baa6b25 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithPropertyWithPayloadName a samm:Aspect ; samm:properties ( [ diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithDuplicatePropertyWithPayloadName.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithDuplicatePropertyWithPayloadName.ttl similarity index 81% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithDuplicatePropertyWithPayloadName.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithDuplicatePropertyWithPayloadName.ttl index 1ab1c68..bda9f2f 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithDuplicatePropertyWithPayloadName.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithDuplicatePropertyWithPayloadName.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithPropertyWithPayloadName a samm:Aspect ; samm:properties ( :testProperty diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithEither.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithEither.ttl similarity index 82% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithEither.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithEither.ttl index 234ccdc..ba337af 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithEither.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithEither.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithEither a samm:Aspect ; samm:properties ( :testProperty ) ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithExtendingPropertyWithPayloadName.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithExtendingPropertyWithPayloadName.ttl similarity index 83% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithExtendingPropertyWithPayloadName.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithExtendingPropertyWithPayloadName.ttl index 28aef6a..050de6d 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithExtendingPropertyWithPayloadName.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithExtendingPropertyWithPayloadName.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :TestAspect a samm:Aspect ; samm:properties ( :property1 ) . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithMultipleAttributes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithMultipleAttributes.ttl similarity index 81% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithMultipleAttributes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithMultipleAttributes.ttl index eef8a5b..aba24c6 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithMultipleAttributes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithMultipleAttributes.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :Aspect a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperation.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithOperation.ttl similarity index 87% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperation.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithOperation.ttl index b6307ed..274a78a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperation.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithOperation.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithOperation a samm:Aspect ; samm:properties ( ) ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperationNoOutput.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithOperationNoOutput.ttl similarity index 86% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperationNoOutput.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithOperationNoOutput.ttl index eba02f1..859053d 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperationNoOutput.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithOperationNoOutput.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithOperationNoOutput a samm:Aspect; samm:properties (); diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOptionalPropertyWithPayloadName.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithOptionalPropertyWithPayloadName.ttl similarity index 85% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOptionalPropertyWithPayloadName.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithOptionalPropertyWithPayloadName.ttl index 8b5472b..724106c 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOptionalPropertyWithPayloadName.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithOptionalPropertyWithPayloadName.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithOptionalPropertyWithPayloadName a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithProperties.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithProperties.ttl similarity index 84% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithProperties.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithProperties.ttl index 2d1dc93..d9d7941 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithProperties.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithProperties.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :TestAspect a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithProperty.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithProperty.ttl similarity index 84% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithProperty.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithProperty.ttl index 5eaddfe..f65a7c8 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithProperty.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithProperty.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithProperty a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyMultipleReferences.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithPropertyMultipleReferences.ttl similarity index 83% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyMultipleReferences.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithPropertyMultipleReferences.ttl index c375212..e998844 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyMultipleReferences.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithPropertyMultipleReferences.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :TestAspect a samm:Aspect ; samm:properties ( :testPropertyOne :testPropertyTwo) . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithAllBaseAttributes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithPropertyWithAllBaseAttributes.ttl similarity index 88% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithAllBaseAttributes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithPropertyWithAllBaseAttributes.ttl index 1c526a2..ff113a7 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithAllBaseAttributes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithPropertyWithAllBaseAttributes.ttl @@ -9,9 +9,9 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :AspectWithPropertyWithAllBaseAttributes a samm:Aspect ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithPayloadName.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithPropertyWithPayloadName.ttl similarity index 80% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithPayloadName.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithPropertyWithPayloadName.ttl index ebf7d89..50594aa 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithPayloadName.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/AspectWithPropertyWithPayloadName.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . -@prefix unit: . +@prefix unit: . :AspectWithPropertyWithPayloadName a samm:Aspect ; samm:properties ( [ diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/Movement.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/Movement.ttl similarity index 83% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/Movement.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/Movement.ttl index 4eadc1d..86bba91 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/Movement.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/Movement.ttl @@ -9,14 +9,14 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . -@prefix unit: . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . +@prefix unit: . @prefix rdf: . @prefix rdfs: . @prefix xsd: . -@prefix : . +@prefix : . :Movement a samm:Aspect; samm:name "Movement"; @@ -30,19 +30,19 @@ samm:preferredName "Moving"@en; samm:description "Flag indicating whether the asset is currently moving"@en; samm:characteristic samm-c:Boolean; - samm-c:Boolean. + samm-c:Boolean. :speedLimitWarning a samm:Property; samm:name "speedLimitWarning"; samm:preferredName "Speed Limit Warning"@en; samm:description "Indicates if the speed limit is adhered to."@en; samm:characteristic :TrafficLight; - :TrafficLight. + :TrafficLight. :position a samm:Property; samm:name "position"; samm:preferredName "Position"@en; samm:description "Indicates a position"@en; samm:characteristic :SpatialPositionCharacteristic; - :SpatialPositionCharacteristic. + :SpatialPositionCharacteristic. :TrafficLight a samm-c:Enumeration; samm:name "TrafficLight"; samm:preferredName "Warning Level"@en; @@ -67,19 +67,19 @@ samm:preferredName "x"@en; samm:description "x coordinate in space"@en; samm:characteristic :Coordinate; - :Coordinate. + :Coordinate. :y a samm:Property; samm:name "y"; samm:preferredName "y"@en; samm:description "y coordinate in space"@en; samm:characteristic :Coordinate; - :Coordinate. + :Coordinate. :z a samm:Property; samm:name "z"; samm:preferredName "z"@en; samm:description "z coordinate in space"@en; samm:characteristic :Coordinate; - :Coordinate. + :Coordinate. :Coordinate a samm-c:Measurement; samm:name "Coordinate"; samm:preferredName "Coordinate"@en; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/ProductType_shared.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/ProductType_shared.ttl similarity index 85% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/ProductType_shared.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/ProductType_shared.ttl index 64a8da3..b329b26 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/ProductType_shared.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/ProductType_shared.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . -@prefix unit: . +@prefix : . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . +@prefix unit: . @prefix xsd: . :ProductType diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/ProductTypes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/ProductTypes.ttl similarity index 82% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/ProductTypes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/ProductTypes.ttl index 1c8b170..49d8d4f 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0/ProductTypes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0/ProductTypes.ttl @@ -9,11 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . -@prefix unit: . +@prefix : . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . +@prefix unit: . @prefix xsd: . :ProductTypes @@ -32,5 +32,4 @@ samm:description "Eine Liste mit chronologisch sortierten Produkttypen."@de ; samm:characteristic [ a samm-c:SortedSet ; samm:name "ProductTypes" ; - samm:dataType ] . - + samm:dataType ] . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_invalid_versions/2.2.0/AspectWithReferences.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_invalid_versions/2.2.0/AspectWithReferences.ttl new file mode 100644 index 0000000..98cc7e0 --- /dev/null +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_invalid_versions/2.2.0/AspectWithReferences.ttl @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved. +# + +@prefix : . +@prefix type: . +@prefix samm: . + +:AspectWithReferences a samm:Aspect ; + samm:preferredName "Aspect with references"@en ; + samm:description "Test aspect with references from different files."@en ; + samm:properties ( :property_1 ) ; + samm:operations ( ) . + +:property_1 a samm:Entity ; + samm:preferredName "Test property"@en ; + samm:description "Test property description."@en ; + samm:properties ( :ExternalPartId + type:TypeList ) . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.1.0/Part_shared.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_invalid_versions/2.2.0/Part_shared.ttl similarity index 91% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.1.0/Part_shared.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_invalid_versions/2.2.0/Part_shared.ttl index 2806c60..763ce0a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.1.0/Part_shared.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_invalid_versions/2.2.0/Part_shared.ttl @@ -2,7 +2,7 @@ # Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved. # -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.1.0/AspectWithReferences.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.2.0/AspectWithReferences.ttl similarity index 82% rename from core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.1.0/AspectWithReferences.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.2.0/AspectWithReferences.ttl index f4598ea..f76b254 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.1.0/AspectWithReferences.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.2.0/AspectWithReferences.ttl @@ -2,9 +2,9 @@ # Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved. # -@prefix : . -@prefix type: . -@prefix samm: . +@prefix : . +@prefix type: . +@prefix samm: . :test_aspect a samm:Aspect ; samm:preferredName "Aspect with references"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.2.0/Part_shared.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.2.0/Part_shared.ttl new file mode 100644 index 0000000..cea7797 --- /dev/null +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.2.0/Part_shared.ttl @@ -0,0 +1,26 @@ +# +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved. +# + +@prefix : . +@prefix samm: . +@prefix samm-c: . +@prefix xsd: . + +:ExternalPartId a samm:Property ; + samm:preferredName "External part id"@en ; + samm:description "External part id description."@en ; + samm:exampleValue "0123456789" ; + samm:characteristic :PartNumber . + +:PartNumber a samm-c:Trait ; + samm:see ; + samm-c:baseCharacteristic [ + a samm-c:Code ; + samm:preferredName "Part Number"@en ; + samm:dataType xsd:string + ] ; + samm-c:constraint [ + a samm-c:RegularExpressionConstraint ; + samm:value "[A-Z0-9-]{10,68}" + ] . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.types/2.2.0/type_shared.ttl b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.types/2.2.0/type_shared.ttl new file mode 100644 index 0000000..10be437 --- /dev/null +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.types/2.2.0/type_shared.ttl @@ -0,0 +1,15 @@ +# +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved. +# + +@prefix : . +@prefix samm: . +@prefix samm-c: . +@prefix xsd: . + + +:TypeList a samm-c:List ; + samm:preferredName "Test List"@en ; + samm:description "This is a test list."@en ; + samm:see ; + samm:dataType xsd:string . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_aspect_functionality.py b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_aspect_functionality.py index ffb8f4c..8899feb 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_aspect_functionality.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_aspect_functionality.py @@ -14,7 +14,7 @@ from esmf_aspect_meta_model_python import BaseImpl, SAMMGraph -RESOURCE_PATH = getcwd() / Path("tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0") def test_get_access_path(): @@ -63,7 +63,7 @@ def test_find_properties_by_name() -> None: assert len(result) == 1 assert isinstance(result[0], BaseImpl) assert result[0].name == "testPropertyOne" - assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyOne" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -73,7 +73,7 @@ def test_find_properties_by_name() -> None: assert len(result) == 1 assert isinstance(result[0], BaseImpl) assert result[0].name == "testPropertyTwo" - assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyTwo" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -94,7 +94,7 @@ def test_find_property_chaticaristic_by_name() -> None: assert len(result) == 1 assert isinstance(result[0], BaseImpl) assert result[0].name == "BooleanTestCharacteristic" - assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#BooleanTestCharacteristic" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#BooleanTestCharacteristic" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -105,21 +105,21 @@ def test_find_properties_by_urn() -> None: samm_graph = SAMMGraph() samm_graph.parse(file_path) _ = samm_graph.load_aspect_model() - element = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne") + element = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyOne") assert element is not None assert isinstance(element, BaseImpl) assert element.name == "testPropertyOne" - assert element.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne" + assert element.urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyOne" assert len(element.preferred_names) == 0 assert len(element.see) == 0 assert len(element.descriptions) == 0 - element = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo") + element = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyTwo") assert element is not None assert isinstance(element, BaseImpl) assert element.name == "testPropertyTwo" - assert element.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo" + assert element.urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyTwo" assert len(element.preferred_names) == 0 assert len(element.see) == 0 assert len(element.descriptions) == 0 @@ -134,12 +134,12 @@ def test_find_property_characteristic_by_urn() -> None: samm_graph.parse(file_path) aspect = samm_graph.load_aspect_model() _ = aspect.properties[0].characteristic - element = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.0#BooleanTestCharacteristic") + element = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.2.0#BooleanTestCharacteristic") assert element is not None assert isinstance(element, BaseImpl) assert element.name == "BooleanTestCharacteristic" - assert element.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#BooleanTestCharacteristic" + assert element.urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#BooleanTestCharacteristic" assert len(element.preferred_names) == 0 assert len(element.see) == 0 assert len(element.descriptions) == 0 diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_characteristics.py b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_characteristics.py index 3a74ebe..3fa624a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_characteristics.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_characteristics.py @@ -26,7 +26,7 @@ ) RESOURCE_PATH = getcwd() / Path( - "tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.1.0" + "tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.characteristics/2.2.0" ) @@ -47,7 +47,7 @@ def test_loading_aspect_with_collection(): assert aspect_property.get_preferred_name("en") == "Test Property" assert aspect_property.get_description("en") == "This is a test property." assert sorted(aspect_property.see) == ["http://example.com/", "http://example.com/me"] - assert aspect_property.urn == "urn:samm:org.eclipse.esmf.test.characteristics:2.1.0#testProperty" + assert aspect_property.urn == "urn:samm:org.eclipse.esmf.test.characteristics:2.2.0#testProperty" assert aspect_property.example_value == rdflib.Literal("Example Value") characteristic = aspect_property.characteristic @@ -103,10 +103,10 @@ def test_loading_aspect_with_collection_with_element_characteristic(): assert data_type.urn == "http://www.w3.org/2001/XMLSchema#string" element_characteristic = collection_characteristic.element_characteristic - assert element_characteristic.urn == "urn:samm:org.eclipse.esmf.samm:characteristic:2.1.0#Text" + assert element_characteristic.urn == "urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#Text" assert element_characteristic.parent_elements[0].urn == ( - "urn:samm:org.eclipse.esmf.test.characteristics:2.1.0#TestCollection" + "urn:samm:org.eclipse.esmf.test.characteristics:2.2.0#TestCollection" ) @@ -162,7 +162,7 @@ def test_loading_aspect_with_quantifiable(): assert isinstance(quantifiable_characteristic, Quantifiable) unit = quantifiable_characteristic.unit assert unit is not None - assert unit.urn == "urn:samm:org.eclipse.esmf.samm:unit:2.1.0#hertz" + assert unit.urn == "urn:samm:org.eclipse.esmf.samm:unit:2.2.0#hertz" assert unit.symbol == "Hz" assert unit.code == "HTZ" assert unit.reference_unit is None @@ -170,7 +170,7 @@ def test_loading_aspect_with_quantifiable(): assert len(unit.quantity_kinds) == 1 for quantity_kind in unit.quantity_kinds: assert quantity_kind.name == "frequency" - assert unit.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.characteristics:2.1.0#TestQuantifiable" + assert unit.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.characteristics:2.2.0#TestQuantifiable" def test_loading_aspect_with_duration(): @@ -184,7 +184,7 @@ def test_loading_aspect_with_duration(): assert isinstance(duration_characteristic, Duration) assert duration_characteristic.name == "TestDuration" - assert duration_characteristic.unit.urn == "urn:samm:org.eclipse.esmf.samm:unit:2.1.0#kilosecond" + assert duration_characteristic.unit.urn == "urn:samm:org.eclipse.esmf.samm:unit:2.2.0#kilosecond" def test_loading_aspect_with_measurement(): @@ -198,7 +198,7 @@ def test_loading_aspect_with_measurement(): assert isinstance(measurement_characteristic, Measurement) assert measurement_characteristic.name == "TestMeasurement" - assert measurement_characteristic.unit.urn == "urn:samm:org.eclipse.esmf.samm:unit:2.1.0#kelvin" + assert measurement_characteristic.unit.urn == "urn:samm:org.eclipse.esmf.samm:unit:2.2.0#kelvin" def test_loading_aspect_with_structured_value(): diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_constraints.py b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_constraints.py index 7f02894..312fb87 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_constraints.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_constraints.py @@ -28,7 +28,7 @@ ) RESOURCE_PATH = getcwd() / Path( - "tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.1.0" + "tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.constraints/2.2.0" ) @@ -167,7 +167,7 @@ def test_loading_aspect_with_range_constraint_incl_bound_definition(): assert isinstance(base_characteristic, Quantifiable) assert hasattr(base_characteristic, "unit") assert hasattr(base_characteristic.unit, "urn") - assert base_characteristic.unit.urn == "urn:samm:org.eclipse.esmf.samm:unit:2.1.0#metrePerSecond" + assert base_characteristic.unit.urn == "urn:samm:org.eclipse.esmf.samm:unit:2.2.0#metrePerSecond" def test_loading_aspect_with_language_constraint(): diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_entities.py b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_entities.py index cb3e5a5..22bb615 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_entities.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_entities.py @@ -14,7 +14,7 @@ from esmf_aspect_meta_model_python import AbstractEntity, ComplexType, Enumeration, Quantifiable, SAMMGraph -RESOURCE_PATH = getcwd() / Path("tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.1.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.entity/2.2.0") def test_loading_aspect_with_entity_enum(): @@ -101,7 +101,7 @@ def test_aspect_with_abstract_entity(): assert entity_property.get_preferred_name("en") == "Entity Property" entity_property_characteristic = entity_property.characteristic - assert entity_property_characteristic.urn == "urn:samm:org.eclipse.esmf.samm:characteristic:2.1.0#Text" + assert entity_property_characteristic.urn == "urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#Text" abstract_entity = entity.extends assert abstract_entity is not None @@ -193,14 +193,14 @@ def test_aspect_with_abstract_coordinate_properties_list() -> None: assert float_3d_coordinate_properties[0].name == "extending_x" assert float_3d_coordinate_properties[0].extends is not None assert float_3d_coordinate_properties[0].extends.name == "x" - assert float_3d_coordinate_properties[0].extends.urn == "urn:samm:org.eclipse.esmf.samm:entity:2.1.0#x" + assert float_3d_coordinate_properties[0].extends.urn == "urn:samm:org.eclipse.esmf.samm:entity:2.2.0#x" assert float_3d_coordinate_properties[0].characteristic is not None assert float_3d_coordinate_properties[0].characteristic.name == "FloatValue" assert float_3d_coordinate_properties[1].name == "extending_y" assert float_3d_coordinate_properties[1].extends is not None assert float_3d_coordinate_properties[1].extends.name == "y" - assert float_3d_coordinate_properties[1].extends.urn == "urn:samm:org.eclipse.esmf.samm:entity:2.1.0#y" + assert float_3d_coordinate_properties[1].extends.urn == "urn:samm:org.eclipse.esmf.samm:entity:2.2.0#y" assert float_3d_coordinate_properties[1].characteristic is not None assert float_3d_coordinate_properties[1].characteristic.name == "FloatValue" @@ -446,7 +446,7 @@ def test_aspect_with_time_series(): assert isinstance(time_series_entity, ComplexType) assert time_series_entity.is_complex is True assert time_series_entity.name == "TestTimeSeriesEntity" - assert time_series_entity.urn == "urn:samm:org.eclipse.esmf.test.entity:2.1.0#TestTimeSeriesEntity" + assert time_series_entity.urn == "urn:samm:org.eclipse.esmf.test.entity:2.2.0#TestTimeSeriesEntity" assert len(time_series_entity.properties) == 1 assert len(time_series_entity.all_properties) == 3 @@ -494,7 +494,7 @@ def test_aspect_with_time_series_with_complex_type() -> None: assert isinstance(data_type, ComplexType) assert data_type.is_complex is True assert data_type.name == "TestTimeSeriesEntity" - assert data_type.urn == "urn:samm:org.eclipse.esmf.test.entity:2.1.0#TestTimeSeriesEntity" + assert data_type.urn == "urn:samm:org.eclipse.esmf.test.entity:2.2.0#TestTimeSeriesEntity" assert len(data_type.properties) == 1 assert len(data_type.all_properties) == 3 @@ -527,7 +527,7 @@ def test_aspect_with_file_resource_entity() -> None: fileResource = characteristic.data_type assert isinstance(fileResource, ComplexType) assert fileResource.is_complex - assert fileResource.urn == "urn:samm:org.eclipse.esmf.samm:entity:2.1.0#FileResource" + assert fileResource.urn == "urn:samm:org.eclipse.esmf.samm:entity:2.2.0#FileResource" assert fileResource.name == "FileResource" assert fileResource.get_preferred_name("en") == "File Resource" assert fileResource.get_description("en") == "A file in a specific format" @@ -561,12 +561,12 @@ def test_aspect_with_entity_extending_file_resource() -> None: advancedFileResource = characteristic.data_type assert isinstance(advancedFileResource, ComplexType) assert advancedFileResource.is_complex - assert advancedFileResource.urn == "urn:samm:org.eclipse.esmf.test.entity:2.1.0#AdvancedFileResource" + assert advancedFileResource.urn == "urn:samm:org.eclipse.esmf.test.entity:2.2.0#AdvancedFileResource" assert advancedFileResource.name == "AdvancedFileResource" assert len(advancedFileResource.properties) == 1 assert len(advancedFileResource.all_properties) == 3 fileResource = advancedFileResource.extends assert fileResource is not None - assert fileResource.urn == "urn:samm:org.eclipse.esmf.samm:entity:2.1.0#FileResource" + assert fileResource.urn == "urn:samm:org.eclipse.esmf.samm:entity:2.2.0#FileResource" assert fileResource.name == "FileResource" diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_event.py b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_event.py index c2d6cb3..2918c8c 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_event.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_event.py @@ -14,7 +14,7 @@ from esmf_aspect_meta_model_python import Event, SAMMGraph -RESOURCE_PATH = getcwd() / Path("tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.1.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.event/2.2.0") def test_loading_aspect_with_event() -> None: diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_general.py b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_general.py index a033064..487265b 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_general.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_general.py @@ -14,7 +14,7 @@ from esmf_aspect_meta_model_python import BaseImpl, ComplexType, Either, SAMMGraph -RESOURCE_PATH = getcwd() / Path("tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.1.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general/2.2.0") def test_aspect_with_multiple_attributes(): @@ -39,14 +39,14 @@ def test_aspect(): samm_graph.parse(file_path) aspect = samm_graph.load_aspect_model() - assert aspect.meta_model_version == "2.1.0" + assert aspect.meta_model_version == "2.2.0" assert aspect.name == "TestAspect" assert len(aspect.preferred_names) == 2 assert aspect.get_preferred_name("en") == "Test Aspect" assert aspect.get_preferred_name("de") == "Test Aspekt" assert len(aspect.descriptions) == 1 assert aspect.get_description("en") == "This is a test description" - assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#TestAspect" + assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#TestAspect" assert len(aspect.properties) == 2 assert aspect.is_collection_aspect is False @@ -63,7 +63,7 @@ def test_aspect(): "Describes a Property which contains plain text. This is intended exclusively for human readable strings, " "not for identifiers, measurement values, etc." ) - assert characteristic.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo" + assert characteristic.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyTwo" data_type = characteristic.data_type assert data_type.is_scalar is True @@ -77,9 +77,9 @@ def test_aspect_with_operation(): samm_graph.parse(file_path) aspect = samm_graph.load_aspect_model() - assert aspect.meta_model_version == "2.1.0" + assert aspect.meta_model_version == "2.2.0" assert aspect.name == "AspectWithOperation" - assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#AspectWithOperation" + assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#AspectWithOperation" properties = aspect.properties assert len(properties) == 0 @@ -138,9 +138,9 @@ def test_aspect_with_operation_no_output(): samm_graph.parse(file_path) aspect = samm_graph.load_aspect_model() - assert aspect.meta_model_version == "2.1.0" + assert aspect.meta_model_version == "2.2.0" assert aspect.name == "AspectWithOperationNoOutput" - assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#AspectWithOperationNoOutput" + assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#AspectWithOperationNoOutput" properties = aspect.properties assert len(properties) == 0 @@ -288,7 +288,7 @@ def test_find_properties_by_name() -> None: assert len(result) == 1 assert isinstance(result[0], BaseImpl) assert result[0].name == "testPropertyOne" - assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyOne" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -298,7 +298,7 @@ def test_find_properties_by_name() -> None: assert len(result) == 1 assert isinstance(result[0], BaseImpl) assert result[0].name == "testPropertyTwo" - assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyTwo" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -319,7 +319,7 @@ def test_find_property_characteristic_by_name() -> None: assert len(result) == 1 assert isinstance(result[0], BaseImpl) assert result[0].name == "BooleanTestCharacteristic" - assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#BooleanTestCharacteristic" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#BooleanTestCharacteristic" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -331,20 +331,20 @@ def test_find_properties_by_urn() -> None: samm_graph.parse(file_path) _ = samm_graph.load_aspect_model() - result = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne") + result = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyOne") assert result is not None assert isinstance(result, BaseImpl) assert result.name == "testPropertyOne" - assert result.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne" + assert result.urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyOne" assert len(result.preferred_names) == 0 assert len(result.see) == 0 assert len(result.descriptions) == 0 - result = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo") + result = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyTwo") assert result is not None assert isinstance(result, BaseImpl) assert result.name == "testPropertyTwo" - assert result.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo" + assert result.urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#testPropertyTwo" assert len(result.preferred_names) == 0 assert len(result.see) == 0 assert len(result.descriptions) == 0 @@ -359,12 +359,12 @@ def test_find_property_characteristic_by_urn() -> None: samm_graph.parse(file_path) aspect = samm_graph.load_aspect_model() _ = aspect.properties[0].characteristic - result = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.0#BooleanTestCharacteristic") + result = samm_graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.2.0#BooleanTestCharacteristic") assert result is not None assert isinstance(result, BaseImpl) assert result.name == "BooleanTestCharacteristic" - assert result.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#BooleanTestCharacteristic" + assert result.urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#BooleanTestCharacteristic" assert len(result.preferred_names) == 0 assert len(result.see) == 0 assert len(result.descriptions) == 0 @@ -386,8 +386,8 @@ def test_loading_aspect_with_either(): left = either_characteristic.left assert left.name == "Text" - assert left.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#TestEither" + assert left.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#TestEither" right = either_characteristic.right assert right.name == "Boolean" - assert right.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#TestEither" + assert right.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.2.0#TestEither" diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_resolve_elements_referencies.py b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_resolve_elements_referencies.py index eed6f07..b2fc4c0 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_resolve_elements_referencies.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_resolve_elements_referencies.py @@ -15,7 +15,7 @@ from esmf_aspect_meta_model_python import SAMMGraph RESOURCE_PATH = getcwd() / Path( - "tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.1.0" + "tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_references/2.2.0" ) diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_upgrade_aspects.py b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_upgrade_aspects.py new file mode 100644 index 0000000..5e55cf2 --- /dev/null +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_upgrade_aspects.py @@ -0,0 +1,134 @@ +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH +# +# See the AUTHORS file(s) distributed with this work for additional +# information regarding authorship. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. +# +# SPDX-License-Identifier: MPL-2.0 +from pathlib import Path + +from esmf_aspect_meta_model_python import SAMMGraph + +ASPECT_MODELS_DIR = ( + Path.cwd() / "tests/integration/aspect_model_loader/resources/org.eclipse.esmf.test.general_with_invalid_versions" +) + +ASPECT_MODELS_V2_2_0 = ASPECT_MODELS_DIR / "2.2.0" + + +def test_upgrade_files(capsys): + file_path = ASPECT_MODELS_V2_2_0 / "AspectWithReferences.ttl" + samm_graph = SAMMGraph() + samm_graph.parse(file_path) + + aspect = samm_graph.load_aspect_model() + + # Asserts + out_lines = [line for line in capsys.readouterr().out.splitlines() if line.strip()] + paths = [ + ASPECT_MODELS_DIR.parent / "org.eclipse.esmf.test.types/2.1.0/type_shared.ttl", + ASPECT_MODELS_DIR.parent / "org.eclipse.esmf.test.general_with_invalid_versions/2.2.0/Part_shared.ttl", + ] + expected_lines = [ + f"[INFO] SAMM version mismatch detected in {paths[0]}. Upgrading...", + f"[INFO] SAMM version mismatch detected in {paths[1]}. Upgrading...", + ] + assert len(out_lines) == len(expected_lines) + assert set(out_lines) == set(expected_lines) + + assert aspect.name == "AspectWithReferences" + assert aspect.get_preferred_name("en") == "Aspect with references" + assert aspect.get_description("en") == "Test aspect with references from different files." + + property_1 = aspect.properties[0] + assert property_1.name == "property_1" + assert property_1.get_preferred_name("en") == "Test property" + assert property_1.get_description("en") == "Test property description." + + property_2 = property_1.properties[0] + assert property_2.name == "ExternalPartId" + assert property_2.get_preferred_name("en") == "External part id" + assert property_2.get_description("en") == "External part id description." + assert str(property_2.example_value) == "0123456789" + + property_3 = property_2.characteristic + assert property_3.name == "PartNumber" + assert property_3.see == ["https://some_link"] + assert property_3.base_characteristic.get_preferred_name("en") == "Part Number" + assert property_3.constraints[0].value == "[A-Z0-9-]{10,68}" + + property_4 = property_1.properties[1] + assert property_4.name == "TypeList" + assert property_4.get_preferred_name("en") == "Test List" + assert property_4.get_description("en") == "This is a test list." + assert property_4.see == ["http://example.com/"] + + +def test_upgrade_data(capsys): + data = """ + # + # Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved. + # + + @prefix : . + @prefix samm: . + @prefix samm-c: . + @prefix xsd: . + + :testProperty a samm:Property ; + samm:characteristic :TestEnumeration ; + samm:preferredName "Test Enumeration"@en ; + samm:description "This is a test for enumeration."@en ; + samm:exampleValue "unit:hectopascal"^^samm:curie . + + :TestEnumeration a samm-c:Enumeration ; + samm:preferredName "Test Enumeration"@en ; + samm:description "This is a test for enumeration."@en ; + samm:dataType samm:curie ; + samm-c:values ( "unit:hectopascal"^^samm:curie "unit:gram"^^samm:curie ) . + + # + # Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved. + # + + @prefix : . + @prefix samm: . + @prefix samm-c: . + @prefix xsd: . + + :AspectWithEarlierSubmodelVersionReferences a samm:Aspect ; + samm:preferredName "Aspect with references"@en ; + samm:description "Test aspect with references from different files."@en ; + samm:properties ( :testProperty ) ; + samm:operations ( ) . + """ # noqa W293 W291 trailing whitespace + + samm_graph = SAMMGraph() + samm_graph.parse(data) + + aspect = samm_graph.load_aspect_model() + + # Asserts + assert ( + capsys.readouterr().out + == "[INFO] SAMM version mismatch detected in provided data (target v2.2.0) Upgrading...\n" + ) + assert aspect.name == "AspectWithEarlierSubmodelVersionReferences" + assert aspect.get_preferred_name("en") == "Aspect with references" + assert aspect.get_description("en") == "Test aspect with references from different files." + + property_1 = aspect.properties[0] + assert property_1.name == "testProperty" + assert property_1.get_preferred_name("en") == "Test Enumeration" + assert property_1.get_description("en") == "This is a test for enumeration." + assert property_1.data_type.urn == "urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#curie" + assert str(property_1.example_value) == "unit:hectopascal" + + characteristic = property_1.characteristic + assert characteristic.data_type.urn == "urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#curie" + assert characteristic.get_preferred_name("en") == "Test Enumeration" + assert characteristic.get_description("en") == "This is a test for enumeration." + assert [str(value) for value in characteristic.values] == ["unit:hectopascal", "unit:gram"] diff --git a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_vocabulary.py b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_vocabulary.py index 8f331d7..7bf5d02 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_vocabulary.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/aspect_model_loader/test_vocabulary.py @@ -19,7 +19,7 @@ from esmf_aspect_meta_model_python.vocabulary.samme import SAMME from esmf_aspect_meta_model_python.vocabulary.unit import UNIT -SAMM_VERSION = "2.1.0" +SAMM_VERSION = "2.2.0" UNIT_URN = f"urn:samm:org.eclipse.esmf.samm:unit:{SAMM_VERSION}#referenceUnit" SAMME_URN = f"urn:samme:org.eclipse.esmf.samm:meta-model:{SAMM_VERSION}#referenceUnit" SAMMC_URN = f"urn:samm:org.eclipse.esmf.samm:characteristic:{SAMM_VERSION}#constraint" diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/SampleAspect.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.2.0/SampleAspect.ttl similarity index 86% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/SampleAspect.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.2.0/SampleAspect.ttl index e61231c..49d0c48 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/SampleAspect.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.2.0/SampleAspect.ttl @@ -2,14 +2,14 @@ # Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved. # -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . -@prefix unit: . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . +@prefix unit: . @prefix rdf: . @prefix rdfs: . @prefix xsd: . -@prefix : . +@prefix : . :SampleAspect a samm:Aspect ; samm:preferredName "Test Aspect"@en ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/test_adaptive_graph.py b/core/esmf-aspect-meta-model-python/tests/integration/test_adaptive_graph.py new file mode 100644 index 0000000..4b6710b --- /dev/null +++ b/core/esmf-aspect-meta-model-python/tests/integration/test_adaptive_graph.py @@ -0,0 +1,71 @@ +from unittest import mock + +import pytest + +from esmf_aspect_meta_model_python.adaptive_graph import AdaptiveGraph + + +class TestAdaptiveGraphIntegration: + @pytest.fixture + def graph(self): + return AdaptiveGraph(samm_version="1.0.0") + + def test_mismatch_from_file(self, graph, tmp_path, capsys): + file_path = tmp_path / "bad_version.ttl" + file_path.write_text( + """ + @prefix samm: . + samm:Aspect a samm:Aspect . + """ + ) + upgraded_ttl = """ + @prefix samm: . + samm:Aspect a samm:Aspect . + """ + + with mock.patch.object(graph._samm_cli, "prettyprint", return_value=upgraded_ttl) as mock_prettyprint: + graph.parse(source=file_path, format="ttl") + + assert len(graph) == 1 # Ensure triple exists in graph + ns_list = list(dict(graph.namespace_manager.namespaces()).values()) + assert any("1.0.0" in str(ns) for ns in ns_list) + assert f"[INFO] SAMM version mismatch detected in {file_path}. Upgrading..." in capsys.readouterr().out + mock_prettyprint.assert_called_once_with(str(file_path), capture=True) + + def test_mismatch_from_data(self, graph, capsys): + bad_ttl_data = """ + @prefix samm: . + samm:Aspect a samm:Aspect . + """ + upgraded_ttl = """ + @prefix samm: . + samm:Aspect a samm:Aspect . + """ + + with mock.patch.object(graph._samm_cli, "prettyprint", return_value=upgraded_ttl) as mock_prettyprint: + graph.parse(data=bad_ttl_data, format="ttl") + + assert len(graph) == 1 # Assert the graph contains the upgraded triple + ns_list = list(dict(graph.namespace_manager.namespaces()).values()) + assert any("1.0.0" in str(ns) for ns in ns_list) + assert ( + "[INFO] SAMM version mismatch detected in provided data (target v1.0.0) Upgrading..." + in capsys.readouterr().out + ) + mock_prettyprint.assert_called_once_with(mock.ANY, capture=True) + + def test_integration_version_match_no_upgrade(self, graph, tmp_path, capsys): + file_path = tmp_path / "good_version.ttl" + file_path.write_text( + """ + @prefix samm: . + samm:Aspect a samm:Aspect . + """ + ) + + with mock.patch.object(graph._samm_cli, "prettyprint") as mock_cli: + graph.parse(source=file_path, format="ttl") + + assert len(graph) == 1 + mock_cli.assert_not_called() + assert capsys.readouterr().out == "" diff --git a/core/esmf-aspect-meta-model-python/tests/integration/cli_functions.py b/core/esmf-aspect-meta-model-python/tests/integration/test_cli_functions.py similarity index 86% rename from core/esmf-aspect-meta-model-python/tests/integration/cli_functions.py rename to core/esmf-aspect-meta-model-python/tests/integration/test_cli_functions.py index f4283f9..48d7cd0 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/cli_functions.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/test_cli_functions.py @@ -1,3 +1,13 @@ +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH +# +# See the AUTHORS file(s) distributed with this work for additional +# information regarding authorship. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. +# +# SPDX-License-Identifier: MPL-2.0 """Integration tests for SAMM CLI functions.""" import json @@ -11,7 +21,7 @@ from esmf_aspect_meta_model_python.samm_cli.base import SammCli -RESOURCE_PATH = os.getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.general/2.1.0") +RESOURCE_PATH = Path(__file__).parent / "resources" / "org.eclipse.esmf.test.general" / "2.2.0" @pytest.fixture(scope="module") @@ -41,18 +51,29 @@ def samm_cli(): class TestSammCliIntegration: """Integration tests for SAMM CLI transformations.""" - def test_prettyprint(self, samm_cli, file_path, temp_output_dir): - """Test pretty-printing the model.""" - output_file = os.path.join(temp_output_dir, "prettyprinted.ttl") + class TestPrettyPrint: + """Test pretty-printing functionality.""" - samm_cli.prettyprint(file_path, output=output_file) + def test_file_output(self, samm_cli, file_path, temp_output_dir): + """Test pretty-printing to a file.""" + output_file = os.path.join(temp_output_dir, "prettyprinted.ttl") - assert os.path.exists(output_file) - assert os.path.getsize(output_file) > 0 - with open(output_file, "r") as f: - content = f.read() - assert "@prefix" in content - assert ":SampleAspect" in content + samm_cli.prettyprint(file_path, output=output_file) + + assert os.path.exists(output_file) + assert os.path.getsize(output_file) > 0 + with open(output_file, "r") as f: + content = f.read() + assert "@prefix" in content + assert ":SampleAspect" in content + + def test_capture_output(self, samm_cli, file_path): + """Test pretty-printing with captured output.""" + prettyprinted_content = samm_cli.prettyprint(file_path, capture=True) + + assert isinstance(prettyprinted_content, str) + assert "@prefix" in prettyprinted_content + assert ":SampleAspect" in prettyprinted_content def test_to_json(self, samm_cli, file_path, temp_output_dir): """Test generating example JSON payload.""" diff --git a/core/esmf-aspect-meta-model-python/tests/unit/loader/test_samm_graph.py b/core/esmf-aspect-meta-model-python/tests/unit/loader/test_samm_graph.py index f55a79d..a532419 100644 --- a/core/esmf-aspect-meta-model-python/tests/unit/loader/test_samm_graph.py +++ b/core/esmf-aspect-meta-model-python/tests/unit/loader/test_samm_graph.py @@ -4,6 +4,8 @@ import pytest +import esmf_aspect_meta_model_python.constants as const + from esmf_aspect_meta_model_python.loader.samm_graph import SAMMGraph @@ -12,15 +14,17 @@ class TestSAMMGraph: @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.DefaultElementCache") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.Graph") - def test_init(self, graph_mock, default_element_cache_mock): - graph_mock.side_effect = ("rdf_graph", "samm_graph") + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.AdaptiveGraph") + def test_init(self, adaptive_graph_mock, graph_mock, default_element_cache_mock): + adaptive_graph_mock.side_effect = ["rdf_graph"] + graph_mock.side_effect = ["samm_graph"] default_element_cache_mock.return_value = "cache" result = SAMMGraph() assert result.rdf_graph == "rdf_graph" assert result.samm_graph == "samm_graph" assert result._cache == "cache" - assert result.samm_version is None + assert result.samm_version == const.SAMM_VERSION assert result.aspect is None assert result.model_elements is None assert result._samm is None @@ -56,43 +60,9 @@ def test_get_rdf_graph(self, input_handler_mock): assert samm_graph.rdf_graph == "rdf_graph" input_handler_mock.assert_called_once_with(input_data, input_type) - input_handler_mock.return_value.get_reader.assert_called_once() + input_handler_mock.return_value.get_reader.assert_called_once_with() reader_mock.read.assert_called_once_with(input_data) - def test_get_samm_version_from_rdf_graph(self): - graph_mock = mock.MagicMock(name="rdf_graph") - graph_mock.namespace_manager.namespaces.return_value = [ - ("samm", "urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0#"), - ] - samm_graph = SAMMGraph() - samm_graph.rdf_graph = graph_mock - result = samm_graph._get_samm_version_from_rdf_graph() - - assert result == "2.1.0" - - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._get_samm_version_from_rdf_graph") - def test_get_samm_version(self, get_samm_version_from_rdf_graph_mock): - get_samm_version_from_rdf_graph_mock.return_value = "1.2.3" - samm_graph = SAMMGraph() - samm_graph._get_samm_version() - - assert samm_graph.samm_version == "1.2.3" - get_samm_version_from_rdf_graph_mock.assert_called_once() - - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._get_samm_version_from_rdf_graph") - def test_get_samm_version_raises_value_error(self, get_samm_version_from_rdf_graph_mock): - get_samm_version_from_rdf_graph_mock.return_value = "" - samm_graph = SAMMGraph() - samm_graph.rdf_graph = "rdf_graph" - - with pytest.raises(ValueError) as error: - samm_graph._get_samm_version() - - assert str(error.value) == ( - "SAMM version number was not found in graph. Could not process RDF graph rdf_graph." - ) - get_samm_version_from_rdf_graph_mock.assert_called_once() - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMM") def test_get_samm(self, samm_mock): samm_mock.return_value = "samm" @@ -115,15 +85,13 @@ def test_get_samm_graph(self, aspect_meta_model_resolver_mock): @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._get_samm_graph") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._get_samm") - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._get_samm_version") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._get_rdf_graph") - def test_parse(self, get_rdf_graph_mock, get_samm_version_mock, get_samm_mock, get_samm_graph_mock): + def test_parse(self, get_rdf_graph_mock, get_samm_mock, get_samm_graph_mock): samm_graph = SAMMGraph() result = samm_graph.parse("input_data", "input_type") assert result == samm_graph get_rdf_graph_mock.assert_called_once_with("input_data", "input_type") - get_samm_version_mock.assert_called_once() get_samm_mock.assert_called_once() get_samm_graph_mock.assert_called_once() @@ -216,7 +184,10 @@ def test_load_aspect_model(self): @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.ModelElementFactory") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.get_aspect_urn") - def test_load_aspect_model_create_element(self, get_aspect_urn_mock, model_element_factory_mock): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._validate_samm_namespace_version") + def test_load_aspect_model_create_element( + self, validate_samm_namespace_version_mock, get_aspect_urn_mock, model_element_factory_mock + ): reader_mock = mock.MagicMock(name="reader") cache_mock = mock.MagicMock(name="cache") samm_graph = SAMMGraph() @@ -229,6 +200,7 @@ def test_load_aspect_model_create_element(self, get_aspect_urn_mock, model_eleme get_aspect_urn_mock.return_value = "aspect_urn" model_element_factory_mock.return_value = model_element_factory_mock model_element_factory_mock.create_element.return_value = "aspect" + result = samm_graph.load_aspect_model() assert result == "aspect" @@ -236,6 +208,7 @@ def test_load_aspect_model_create_element(self, get_aspect_urn_mock, model_eleme reader_mock.prepare_aspect_model.assert_called_once_with("rdf_graph_samm_graph") model_element_factory_mock.assert_called_once_with("1.2.3", "rdf_graph_samm_graph", cache_mock) model_element_factory_mock.create_element.assert_called_once_with("aspect_urn") + validate_samm_namespace_version_mock.assert_called_once_with("rdf_graph_samm_graph") def test_load_model_elements(self): samm_graph = SAMMGraph() @@ -407,3 +380,30 @@ def test_private_determine_access_path_parent_name(self, isinstance_mock): result = samm_graph._SAMMGraph__determine_access_path(base_element_mock, [["path"]]) assert result == [["payload_element_name", "path"]] + + +@mock.patch("esmf_aspect_meta_model_python.utils.get_samm_versions_from_graph") +class TestValidateSammNamespaceVersion: + """Test suite for SAMMGraph._validate_samm_namespace_version method.""" + + def test_valid(self, get_samm_versions_from_graph_mock): + version = "1.2.3" + samm_graph = SAMMGraph() + samm_graph.samm_version = version + get_samm_versions_from_graph_mock.return_value = [version, version] + + samm_graph._validate_samm_namespace_version(graph=mock.MagicMock(name="rdf_graph")) + + def test_mismatch(self, get_samm_versions_from_graph_mock): + samm_version = "2.2.0" + earlier_version = "2.1.0" + samm_graph = SAMMGraph() + samm_graph.samm_version = samm_version + get_samm_versions_from_graph_mock.return_value = [samm_version, earlier_version] + + with pytest.raises( + ValueError, + match=f"SAMM version mismatch. Found '{earlier_version}', but expected '{samm_version}'. " + "Ensure all RDF files use a single, consistent SAMM version", + ): + samm_graph._validate_samm_namespace_version(graph=mock.MagicMock(name="rdf_graph")) diff --git a/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_base.py b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_base.py index ddc1de4..b8c994b 100644 --- a/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_base.py +++ b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_base.py @@ -1,5 +1,4 @@ """Base resolver test suit.""" - from unittest import mock import pytest @@ -35,25 +34,3 @@ def test_validate_samm_version_not_supported_version(self, samm_units_graph_mock ResolverInterface._validate_samm_version("3") assert str(error.value) == "3 is not supported SAMM version." - - def test_get_samm_version_from_graph(self): - graph_mock = mock.MagicMock(name="graph") - graph_mock.namespace_manager.namespaces.return_value = [("samm", "path:model:0.1.2#")] - resolver = ResolverTest() - resolver.graph = graph_mock - result = resolver._get_samm_version_from_graph() - - assert result == "0.1.2" - graph_mock.namespace_manager.namespaces.assert_called_once() - - @mock.patch("esmf_aspect_meta_model_python.resolver.base.ResolverInterface._validate_samm_version") - @mock.patch("esmf_aspect_meta_model_python.resolver.base.ResolverInterface._get_samm_version_from_graph") - def test_get_samm_version(self, get_samm_version_from_graph_mock, validate_samm_version_mock): - get_samm_version_from_graph_mock.return_value = "version" - resolver = ResolverTest() - result = resolver.get_samm_version() - - assert result == "version" - get_samm_version_from_graph_mock.assert_called_once() - validate_samm_version_mock.assert_called_once_with("version") - assert resolver.samm_version == "version" diff --git a/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_data_string.py b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_data_string.py index 2ebdf00..1cf7d17 100644 --- a/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_data_string.py +++ b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_data_string.py @@ -1,19 +1,26 @@ """Data string resolver test suit.""" +import pathlib from unittest import mock +import pytest + from esmf_aspect_meta_model_python.resolver.data_string import DataStringResolver class TestDataStringResolver: """Data string resolver test suit.""" - @mock.patch("esmf_aspect_meta_model_python.resolver.data_string.Graph") - def test_read(self, rdf_graph_mock): + @mock.patch("esmf_aspect_meta_model_python.resolver.data_string.AdaptiveGraph") + @pytest.mark.parametrize("data_string", ["", pathlib.Path("data_string.ttl")]) + def test_read(self, rdf_graph_mock, data_string): graph_mock = mock.MagicMock(name="graph") rdf_graph_mock.return_value = graph_mock resolver = DataStringResolver() - result = resolver.read("data_string") + resolver.samm_version = "1.0.0" + + result = resolver.read(data_string) assert result == graph_mock - graph_mock.parse.assert_called_once_with(data="data_string") + graph_mock.parse.assert_called_once_with(data=str(data_string)) + rdf_graph_mock.assert_called_once_with() diff --git a/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_local_file.py b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_local_file.py index 2ad2341..95fd38d 100644 --- a/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_local_file.py +++ b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_local_file.py @@ -1,5 +1,4 @@ """Local file resolver test suit.""" - from unittest import mock import pytest @@ -34,17 +33,20 @@ def test_validate_file_raise_error(self, exists_mock): assert str(error.value) == "Could not find a file file_path" exists_mock.assert_called_once_with("file_path") - @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.Graph") + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.AdaptiveGraph") @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver.validate_file") def test_read(self, validate_file_mock, graph_mock): rdf_graph_mock = mock.MagicMock(name="rdf_graph") graph_mock.return_value = rdf_graph_mock resolver = LocalFileResolver() + resolver.samm_version = "1.0.0" + result = resolver.read("file_path") assert result == rdf_graph_mock validate_file_mock.assert_called_once_with("file_path") - rdf_graph_mock.parse.assert_called_once_with("file_path") + graph_mock.assert_called_once_with() + rdf_graph_mock.parse.assert_called_once_with(source="file_path") def test_parse_namespace_no_data(self): resolver = LocalFileResolver() @@ -94,7 +96,7 @@ def test_get_dependency_folders(self, get_dirs_for_advanced_loading_mock): result = resolver._get_dependency_folders("file_path") assert result == "dependency_folders" - graph_mock.parse.assert_called_once_with("file_path", format="turtle") + graph_mock.parse.assert_called_once_with(source="file_path", format="turtle") get_dirs_for_advanced_loading_mock.assert_called_once_with("file_path") @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.exists") diff --git a/core/esmf-aspect-meta-model-python/tests/unit/samm_cli/test_base.py b/core/esmf-aspect-meta-model-python/tests/unit/samm_cli/test_base.py index 05c0043..3fd41f1 100644 --- a/core/esmf-aspect-meta-model-python/tests/unit/samm_cli/test_base.py +++ b/core/esmf-aspect-meta-model-python/tests/unit/samm_cli/test_base.py @@ -1,4 +1,15 @@ -"""SAMM client functions test suite.""" +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH +# +# See the AUTHORS file(s) distributed with this work for additional +# information regarding authorship. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. +# +# SPDX-License-Identifier: MPL-2.0 +"""SammCli unit tests""" +import subprocess from unittest import mock @@ -53,7 +64,7 @@ def test_get_client_path(_, path_mock, join_mock): assert result == "cli_path" path_mock.resolve.assert_called_once() - join_mock.assert_called_once_with("parent", "samm-cli", "samm.exe") + join_mock.assert_has_calls([mock.call("parent", "samm-cli"), mock.call("cli_path", "samm")]) @mock.patch(f"{BASE_PATH}.download_samm_cli") @@ -260,7 +271,7 @@ def test_repeated_params(self, subprocess_mock, samm_cli, params, expected: str) result = samm_cli._call_function("function name", "path_to_ttl_model", *args, **kwargs) - assert result is None + assert result is subprocess_mock.run.return_value.stdout subprocess_mock.run.assert_called_once_with( [ "samm", @@ -292,7 +303,7 @@ def test_diff_command_type(self, subprocess_mock, samm_cli, command_type: str): **kwargs, ) - assert result is None + assert result is subprocess_mock.run.return_value.stdout subprocess_mock.run.assert_called_once_with( [ "samm", @@ -307,89 +318,202 @@ def test_diff_command_type(self, subprocess_mock, samm_cli, command_type: str): ] ) + @mock.patch(f"{BASE_PATH}.subprocess") + class TestCapture: + def test_true(self, subprocess_mock, samm_cli): + subprocess_mock.run.return_value.stdout = stdout = "output data" + args = ["flag_1", "flag_2"] + kwargs = {"a": "value_1", "arg_2": "value_2"} + + result = samm_cli._call_function( + "function name", + "path_to_ttl_model", + *args, + capture=True, + **kwargs, + ) + + assert result is stdout + subprocess_mock.run.assert_called_once_with( + [ + "samm", + "aspect", + "path_to_ttl_model", + "function", + "name", + "-flag_1", + "-flag_2", + "-a=value_1", + "--arg-2=value_2", + ], + check=True, + capture_output=True, + text=True, + ) + + def test_false(self, subprocess_mock, samm_cli): + args = ["flag_1", "flag_2"] + kwargs = {"a": "value_1", "arg_2": "value_2"} + + result = samm_cli._call_function( + "function name", + "path_to_ttl_model", + *args, + capture=False, + **kwargs, + ) + + assert result is subprocess_mock.run.return_value.stdout + subprocess_mock.run.assert_called_once_with( + [ + "samm", + "aspect", + "path_to_ttl_model", + "function", + "name", + "-flag_1", + "-flag_2", + "-a=value_1", + "--arg-2=value_2", + ] + ) + + def test_error(self, subprocess_mock, samm_cli): + subprocess_mock.run.side_effect = subprocess.CalledProcessError( + returncode=1, + cmd=["samm", "aspect", "path_to_ttl_model", "function", "name"], + output="Validation error", + stderr="Error occurred", + ) + args = ["flag_1", "flag_2"] + kwargs = {"a": "value_1", "arg_2": "value_2"} + + with pytest.raises(subprocess.CalledProcessError) as exc_info: + samm_cli._call_function( + "function name", + "path_to_ttl_model", + *args, + capture=True, + **kwargs, + ) + + assert exc_info.value.returncode == 1 + assert exc_info.value.stdout == "Validation error" + assert exc_info.value.stderr == "Error occurred" + subprocess_mock.run.assert_called_once_with( + [ + "samm", + "aspect", + "path_to_ttl_model", + "function", + "name", + "-flag_1", + "-flag_2", + "-a=value_1", + "--arg-2=value_2", + ], + check=True, + capture_output=True, + text=True, + ) + @mock.patch(f"{CLASS_PATH}._call_function") class TestSammCliFunctions: def test_validate(self, call_function_mock, samm_cli): result = samm_cli.validate("path_to_ttl_model", "flag", arg_key="value") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( - SAMMCLICommands.VALIDATE, "path_to_ttl_model", "flag", arg_key="value" + SAMMCLICommands.VALIDATE, "path_to_ttl_model", "flag", capture=False, arg_key="value" ) def test_prettyprint(self, call_function_mock, samm_cli): result = samm_cli.prettyprint("path_to_ttl_model", "w", output="output.ttl") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( SAMMCLICommands.PRETTYPRINT, "path_to_ttl_model", "w", + capture=False, output="output.ttl", ) def test_usage(self, call_function_mock, samm_cli): result = samm_cli.usage("urn:samm:org.eclipse.example:1.0.0#MyElement", models_root="/path/to/models") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( - "usage", "urn:samm:org.eclipse.example:1.0.0#MyElement", models_root="/path/to/models" + "usage", "urn:samm:org.eclipse.example:1.0.0#MyElement", capture=False, models_root="/path/to/models" ) def test_to_openapi(self, call_function_mock, samm_cli): result = samm_cli.to_openapi("path_to_ttl_model", "flag", arg_key="value") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( - SAMMCLICommands.TO_OPENAPI, "path_to_ttl_model", "flag", arg_key="value" + SAMMCLICommands.TO_OPENAPI, "path_to_ttl_model", "flag", capture=False, arg_key="value" ) def test_to_schema(self, call_function_mock, samm_cli): result = samm_cli.to_schema("path_to_ttl_model", "flag", arg_key="value") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( - SAMMCLICommands.TO_SCHEMA, "path_to_ttl_model", "flag", arg_key="value" + SAMMCLICommands.TO_SCHEMA, "path_to_ttl_model", "flag", capture=False, arg_key="value" ) def test_to_json(self, call_function_mock, samm_cli): result = samm_cli.to_json("path_to_ttl_model", "flag", arg_key="value") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( - SAMMCLICommands.TO_JSON, "path_to_ttl_model", "flag", arg_key="value" + SAMMCLICommands.TO_JSON, "path_to_ttl_model", "flag", capture=False, arg_key="value" ) def test_to_html(self, call_function_mock, samm_cli): result = samm_cli.to_html("path_to_ttl_model", "flag", arg_key="value") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( - SAMMCLICommands.TO_HTML, "path_to_ttl_model", "flag", arg_key="value" + SAMMCLICommands.TO_HTML, "path_to_ttl_model", "flag", capture=False, arg_key="value" ) def test_to_png(self, call_function_mock, samm_cli): result = samm_cli.to_png("path_to_ttl_model", "flag", arg_key="value") - assert result is None - call_function_mock.assert_called_once_with(SAMMCLICommands.TO_PNG, "path_to_ttl_model", "flag", arg_key="value") + assert result is call_function_mock.return_value + call_function_mock.assert_called_once_with( + SAMMCLICommands.TO_PNG, + "path_to_ttl_model", + "flag", + capture=False, + arg_key="value", + ) def test_to_svg(self, call_function_mock, samm_cli): result = samm_cli.to_svg("path_to_ttl_model", "flag", arg_key="value") - assert result is None - call_function_mock.assert_called_once_with(SAMMCLICommands.TO_SVG, "path_to_ttl_model", "flag", arg_key="value") + assert result is call_function_mock.return_value + call_function_mock.assert_called_once_with( + SAMMCLICommands.TO_SVG, + "path_to_ttl_model", + "flag", + capture=False, + arg_key="value", + ) def test_to_java(self, call_function_mock, samm_cli): result = samm_cli.to_java("path_to_ttl_model", "nj", "s", package_name="org.example", output_directory="./out") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( SAMMCLICommands.TO_JAVA, "path_to_ttl_model", "nj", "s", + capture=False, package_name="org.example", output_directory="./out", ) @@ -399,12 +523,13 @@ def test_to_asyncapi(self, call_function_mock, samm_cli): "path_to_ttl_model", "sv", "sf", channel_address="topic/name", application_id="app-id" ) - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( SAMMCLICommands.TO_ASYNCAPI, "path_to_ttl_model", "sv", "sf", + capture=False, channel_address="topic/name", application_id="app-id", ) @@ -412,9 +537,9 @@ def test_to_asyncapi(self, call_function_mock, samm_cli): def test_to_jsonld(self, call_function_mock, samm_cli): result = samm_cli.to_jsonld("path_to_ttl_model", output="model.jsonld") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( - SAMMCLICommands.TO_JSONLD, "path_to_ttl_model", output="model.jsonld" + SAMMCLICommands.TO_JSONLD, "path_to_ttl_model", capture=False, output="model.jsonld" ) def test_to_sql(self, call_function_mock, samm_cli): @@ -427,10 +552,11 @@ def test_to_sql(self, call_function_mock, samm_cli): custom_column="col1 STRING", ) - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( SAMMCLICommands.TO_SQL, "path_to_ttl_model", + capture=False, output="schema.sql", dialect="databricks", mapping_strategy="denormalized", @@ -442,10 +568,11 @@ def test_to_sql(self, call_function_mock, samm_cli): # def test_to_aas(self, call_function_mock, samm_cli): # result = samm_cli.to_aas("path_to_ttl_model", output="aas.aasx", format="aasx", aspect_data="data.json") # - # assert result is None + # assert result is call_function_mock.return_value # call_function_mock.assert_called_once_with( # SAMMCLICommands.AAS_TO_ASPECT, # "path_to_ttl_model", + # capture=False, # output="aas.aasx", # format="aasx", # aspect_data="data.json", @@ -468,8 +595,8 @@ def test_edit_move(self, call_function_mock, samm_cli, element, namespace, flags """Test edit_move command with different configurations.""" result = samm_cli.edit_move("path_to_ttl_model", element, namespace, *flags) - assert result is None - call_function_mock.assert_called_once_with(expected_function_name, "path_to_ttl_model", *flags) + assert result is call_function_mock.return_value + call_function_mock.assert_called_once_with(expected_function_name, "path_to_ttl_model", *flags, capture=False) @pytest.mark.parametrize( "model_input,version_type,flags,kwargs", @@ -484,10 +611,9 @@ def test_edit_newversion(self, call_function_mock, samm_cli, model_input, versio """Test edit_newversion command with different version types.""" result = samm_cli.edit_newversion(model_input, version_type, *flags, **kwargs) - assert result is None - + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( - SAMMCLICommands.EDIT_NEWVERSION, model_input, *[version_type, *flags], **kwargs + SAMMCLICommands.EDIT_NEWVERSION, model_input, *[version_type, *flags], capture=False, **kwargs ) def test_edit_newversion_none(self, call_function_mock, samm_cli): @@ -498,12 +624,12 @@ def test_edit_newversion_none(self, call_function_mock, samm_cli): "force", ) - assert result is None - + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( SAMMCLICommands.EDIT_NEWVERSION, "path_to_ttl_model", "force", + capture=False, ) def test_aas_to_aspect(self, call_function_mock, samm_cli): @@ -511,10 +637,11 @@ def test_aas_to_aspect(self, call_function_mock, samm_cli): "AssetAdminShell.aasx", output_directory="./output", submodel_template=["1", "2"] ) - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( SAMMCLICommands.AAS_TO_ASPECT, "AssetAdminShell.aasx", + capture=False, command_type=SAMMCLICommandTypes.AAS, output_directory="./output", submodel_template=["1", "2"], @@ -523,21 +650,22 @@ def test_aas_to_aspect(self, call_function_mock, samm_cli): def test_aas_list(self, call_function_mock, samm_cli): result = samm_cli.aas_list("AssetAdminShell.aasx") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( - SAMMCLICommands.AAS_LIST, "AssetAdminShell.aasx", command_type=SAMMCLICommandTypes.AAS + SAMMCLICommands.AAS_LIST, "AssetAdminShell.aasx", capture=False, command_type=SAMMCLICommandTypes.AAS ) def test_package_import(self, call_function_mock, samm_cli): result = samm_cli.package_import("MyPackage.zip", "dry-run", "details", "force", models_root="c:\\models") - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( SAMMCLICommands.PACKAGE_IMPORT, "MyPackage.zip", "dry-run", "details", "force", + capture=False, command_type=SAMMCLICommandTypes.PACKAGE, models_root="c:\\models", ) @@ -547,10 +675,11 @@ def test_package_export(self, call_function_mock, samm_cli): "urn:samm:org.eclipse.example.myns:1.0.0", output="package.zip", models_root="/path/to/models" ) - assert result is None + assert result is call_function_mock.return_value call_function_mock.assert_called_once_with( SAMMCLICommands.PACKAGE_EXPORT, "urn:samm:org.eclipse.example.myns:1.0.0", + capture=False, command_type="package", output="package.zip", models_root="/path/to/models", diff --git a/core/esmf-aspect-meta-model-python/tests/unit/samm_cli/test_download.py b/core/esmf-aspect-meta-model-python/tests/unit/samm_cli/test_download.py index 50306eb..9f8ce26 100644 --- a/core/esmf-aspect-meta-model-python/tests/unit/samm_cli/test_download.py +++ b/core/esmf-aspect-meta-model-python/tests/unit/samm_cli/test_download.py @@ -21,6 +21,7 @@ class TestGetSammCliFileNme: def test_get_samm_cli_file_name_windows(self, system_mock): system_mock.return_value = "Windows" expected_file_name = Const.WIN_FILE_NAME.substitute(version_number=Const.JAVA_CLI_VERSION) + result = get_samm_cli_file_name() assert result == expected_file_name @@ -29,6 +30,7 @@ def test_get_samm_cli_file_name_windows(self, system_mock): def test_get_samm_cli_file_name_linux(self, system_mock): system_mock.return_value = "Linux" expected_file_name = Const.LINUX_FILE_NAME.substitute(version_number=Const.JAVA_CLI_VERSION) + result = get_samm_cli_file_name() assert result == expected_file_name @@ -36,6 +38,7 @@ def test_get_samm_cli_file_name_linux(self, system_mock): @mock.patch(f"{BASE_SCRIPT_PATH}.platform.system") def test_get_samm_cli_file_name_raise_exception(self, system_mock): system_mock.return_value = "MacOS" + with pytest.raises(NotImplementedError) as error: get_samm_cli_file_name() @@ -44,11 +47,33 @@ def test_get_samm_cli_file_name_raise_exception(self, system_mock): ) -class TestArchiveFileDownload: +class TestDownloadArchiveFile: + @mock.patch(f"{BASE_SCRIPT_PATH}.requests.get") + @mock.patch(f"{BASE_SCRIPT_PATH}.print") + @mock.patch(f"{BASE_SCRIPT_PATH}.open") + def test_raise_http_error(self, open_mock, print_mock, requests_get_mock): + f_mock = mock.MagicMock(name="file_mock") + f_mock.__enter__.return_value = f_mock + open_mock.return_value = f_mock + response_mock = mock.MagicMock(name="response_mock") + response_mock.raise_for_status.side_effect = Exception("HTTP error") + requests_get_mock.return_value = response_mock + + with pytest.raises(Exception) as error: + download_archive_file("http://example.com/archive.zip", "archive_file_path") + + assert str(error.value) == "HTTP error" + open_mock.assert_called_once_with("archive_file_path", "wb") + print_mock.assert_called_once_with("Downloading archive_file_path") + requests_get_mock.assert_called_once_with("http://example.com/archive.zip", allow_redirects=True, stream=True) + response_mock.raise_for_status.assert_called_once_with() + f_mock.__enter__.assert_called_once() + f_mock.write.assert_not_called() + @mock.patch(f"{BASE_SCRIPT_PATH}.requests.get") @mock.patch(f"{BASE_SCRIPT_PATH}.print") @mock.patch(f"{BASE_SCRIPT_PATH}.open") - def test_download_archive_file_no_content(self, open_mock, print_mock, requests_get_mock): + def test_no_content(self, open_mock, print_mock, requests_get_mock): f_mock = mock.MagicMock(name="file_mock") f_mock.__enter__.return_value = f_mock open_mock.return_value = f_mock @@ -56,6 +81,7 @@ def test_download_archive_file_no_content(self, open_mock, print_mock, requests_ response_mock.content = "response_content" response_mock.headers.get.return_value = None requests_get_mock.return_value = response_mock + result = download_archive_file("http://example.com/archive.zip", "archive_file_path") assert result is None @@ -70,7 +96,7 @@ def test_download_archive_file_no_content(self, open_mock, print_mock, requests_ @mock.patch(f"{BASE_SCRIPT_PATH}.requests.get") @mock.patch(f"{BASE_SCRIPT_PATH}.print") @mock.patch(f"{BASE_SCRIPT_PATH}.open") - def test_download_archive_file(self, open_mock, print_mock, requests_get_mock, sys_stdout_mock): + def test_ok(self, open_mock, print_mock, requests_get_mock, sys_stdout_mock): f_mock = mock.MagicMock(name="file_mock") f_mock.__enter__.return_value = f_mock open_mock.return_value = f_mock @@ -79,6 +105,7 @@ def test_download_archive_file(self, open_mock, print_mock, requests_get_mock, s response_mock.headers.get.return_value = "42" response_mock.iter_content.return_value = ["content_data"] requests_get_mock.return_value = response_mock + result = download_archive_file("http://example.com/archive.zip", "archive_file_path") assert result is None @@ -96,15 +123,17 @@ def test_download_archive_file(self, open_mock, print_mock, requests_get_mock, s class TestDownloadSammCli: @mock.patch(f"{BASE_SCRIPT_PATH}.print") @mock.patch(f"{BASE_SCRIPT_PATH}.get_samm_cli_file_name") - def test_download_samm_cli_error(self, get_samm_cli_file_name_mock, print_mock): + @mock.patch(f"{BASE_SCRIPT_PATH}.download_archive_file") + def test_not_implemented(self, download_archive_file_mock, get_samm_cli_file_name_mock, print_mock): test_error = NotImplementedError("exception_message") get_samm_cli_file_name_mock.side_effect = test_error result = download_samm_cli() assert result is None - get_samm_cli_file_name_mock.assert_called_once() + get_samm_cli_file_name_mock.assert_called_once_with() print_mock.assert_called_once_with(test_error) + download_archive_file_mock.assert_not_called() @mock.patch(f"{BASE_SCRIPT_PATH}.zipfile") @mock.patch(f"{BASE_SCRIPT_PATH}.download_archive_file") @@ -112,8 +141,10 @@ def test_download_samm_cli_error(self, get_samm_cli_file_name_mock, print_mock): @mock.patch(f"{BASE_SCRIPT_PATH}.Path") @mock.patch(f"{BASE_SCRIPT_PATH}.print") @mock.patch(f"{BASE_SCRIPT_PATH}.get_samm_cli_file_name") - def test_download_samm_cli( + @mock.patch(f"{BASE_SCRIPT_PATH}.extract_archive") + def test_ok( self, + extract_archive_mock, get_samm_cli_file_name_mock, print_mock, path_mock, @@ -121,21 +152,21 @@ def test_download_samm_cli( download_archive_file_mock, zipfile_mock, ): - get_samm_cli_file_name_mock.return_value = "samm_cli_file_name" + get_samm_cli_file_name_mock.return_value = "samm_cli_file_name.zip" path_mock.return_value = path_mock path_mock.resolve.return_value = path_mock path_mock.parents = ["parent_dir"] - os_mock.path.join.side_effect = ("archive_file", "extracted_files_path") + os_mock.path.join.side_effect = ("archive_file.zip", "extracted_files_path") archive_mock = mock.MagicMock(name="archive_mock") - archive_mock.namelist.return_value = ["file_1", "file_2"] zipfile_mock.ZipFile.return_value = archive_mock + result = download_samm_cli() assert result is None - get_samm_cli_file_name_mock.assert_called_once() + get_samm_cli_file_name_mock.assert_called_once_with() print_mock.assert_has_calls( [ - mock.call("Start downloading SAMM CLI samm_cli_file_name"), + mock.call("Start downloading SAMM CLI samm_cli_file_name.zip"), mock.call("\nSAMM CLI archive file downloaded"), mock.call("Start extracting files"), mock.call("Done extracting files"), @@ -143,21 +174,46 @@ def test_download_samm_cli( ] ) path_mock.assert_called_once_with(download_module.__file__) - path_mock.resolve.assert_called_once() + path_mock.resolve.assert_called_once_with() os_mock.path.join.assert_has_calls( - [mock.call("parent_dir", "samm_cli_file_name"), mock.call("parent_dir", "samm-cli")] + [mock.call("parent_dir", "samm_cli_file_name.zip"), mock.call("parent_dir", "samm-cli")] ) - os_mock.remove.assert_called_once() + os_mock.remove.assert_called_once_with("archive_file.zip") download_archive_file_mock.assert_called_once_with( - Const.BASE_PATH.substitute(version_number=Const.JAVA_CLI_VERSION, file_name="samm_cli_file_name"), - "archive_file", + Const.BASE_PATH.substitute(version_number=Const.JAVA_CLI_VERSION, file_name="samm_cli_file_name.zip"), + "archive_file.zip", ) - zipfile_mock.ZipFile.assert_called_once_with("archive_file") - archive_mock.namelist.assert_called_once() - archive_mock.extract.has_calls( - [ - mock.call("file_1", "extracted_files_path"), - mock.call("file_2", "extracted_files_path"), - ] - ) - archive_mock.close.assert_called_once() + extract_archive_mock.assert_called_once_with("archive_file.zip", dest_dir="extracted_files_path") + + +class TestExtractArchive: + @mock.patch(f"{BASE_SCRIPT_PATH}.zipfile.ZipFile") + def test_zip(self, zipfile_zipfile_mock): + archive_file = "archive.zip" + dest_dir = "destination_directory" + archive_mock = mock.MagicMock(name="archive_mock") + zipfile_zipfile_mock.return_value = archive_mock + + download_module.extract_archive(archive_file, dest_dir) + + zipfile_zipfile_mock.assert_called_once_with(archive_file) + archive_mock.__enter__.return_value.extractall.assert_called_once_with(dest_dir) + + @mock.patch(f"{BASE_SCRIPT_PATH}.tarfile.open") + def test_tar_gz(self, tarfile_open_mock): + archive_file = "archive.tar.gz" + dest_dir = "destination_directory" + archive_mock = mock.MagicMock(name="archive_mock") + tarfile_open_mock.return_value = archive_mock + + download_module.extract_archive(archive_file, dest_dir) + + tarfile_open_mock.assert_called_once_with(archive_file, mode="r:gz") + archive_mock.__enter__.return_value.extractall.assert_called_once_with(dest_dir) + + def test_extract_unsupported_format(self): + archive_file = "archive.rar" + dest_dir = "destination_directory" + + with pytest.raises(ValueError, match=f"Unsupported archive format: {archive_file}"): + download_module.extract_archive(archive_file, dest_dir) diff --git a/core/esmf-aspect-meta-model-python/tests/unit/test_adaptive_graph.py b/core/esmf-aspect-meta-model-python/tests/unit/test_adaptive_graph.py new file mode 100644 index 0000000..53d9f95 --- /dev/null +++ b/core/esmf-aspect-meta-model-python/tests/unit/test_adaptive_graph.py @@ -0,0 +1,205 @@ +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH +# +# See the AUTHORS file(s) distributed with this work for additional +# information regarding authorship. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. +# +# SPDX-License-Identifier: MPL-2.0 +import pathlib +import subprocess + +from unittest import mock + +import pytest + +from rdflib import Graph + +from esmf_aspect_meta_model_python.adaptive_graph import AdaptiveGraph +from esmf_aspect_meta_model_python.constants import SAMM_VERSION + + +@pytest.fixture +def graph(): + return AdaptiveGraph(samm_version="1.0.0") + + +class TestUpgradeTTLFile: + def test_calls_samm_cli_prettyprint(self, graph): + with mock.patch.object(graph._samm_cli, "prettyprint", return_value="content") as mock_prettyprint: + result = graph._upgrade_ttl_file(pathlib.Path("file.ttl")) + + assert result == "content" + mock_prettyprint.assert_called_once_with("file.ttl", capture=True) + + def test_raises_runtime_error_on_cli_failure(self, graph): + err = subprocess.CalledProcessError(returncode=1, cmd="prettyprint", output="STDOUT", stderr="STDERR") + + with mock.patch.object(graph._samm_cli, "prettyprint", side_effect=err): + with pytest.raises(RuntimeError, match="SAMM CLI failed for file.ttl:\nSTDOUT\nSTDERR"): + graph._upgrade_ttl_file(pathlib.Path("file.ttl")) + + +@mock.patch.object(AdaptiveGraph, "_upgrade_ttl_file", return_value="upgraded content") +def test_upgrade_source(mock_cli, graph, tmp_path, capsys): + file = tmp_path / "file.ttl" + file.write_text("data") + + result = graph._upgrade_source(file) + + assert result == "upgraded content" + assert isinstance(file, pathlib.Path) + mock_cli.assert_called_once_with(file) + + captured = capsys.readouterr() + assert f"SAMM version mismatch detected in {file}. Upgrading..." in captured.out + + +@pytest.mark.parametrize("input_data", ["string data", b"bytes data"]) +@mock.patch.object(AdaptiveGraph, "_upgrade_ttl_file", return_value="upgraded content") +def test_upgrade_data(mock_cli, graph, capsys, input_data): + result = graph._upgrade_data(input_data) + + assert result == "upgraded content" + temp_file_path = pathlib.Path(mock_cli.call_args[0][0]) + mock_cli.assert_called_once_with(temp_file_path) + assert not temp_file_path.exists() + + captured = capsys.readouterr() + assert "[INFO] SAMM version mismatch detected in provided data" in captured.out + + +def test_set_samm_version(graph): + graph.set_samm_version("2.0.0") + + assert graph._samm_version == "2.0.0" + + +class TestParse: + @pytest.mark.parametrize( + "source,data", + [ + (None, None), # Neither provided + (pathlib.Path("file.ttl"), "data_content"), # Both provided + ], + ) + def test_error_invalid_args(self, graph, source, data): + with pytest.raises(ValueError, match="Either 'source' or 'data' must be provided."): + graph.parse(source=source, data=data) + + def test_default_samm_version(self): + assert AdaptiveGraph()._samm_version == SAMM_VERSION + + @pytest.mark.parametrize("source_type", [str, pathlib.Path]) + @mock.patch("esmf_aspect_meta_model_python.utils.has_version_mismatch_from_input", return_value=False) + @mock.patch("rdflib.Graph.parse") + def test_version_match(self, mock_parse, mock_version_check, graph, source_type): + source = source_type("file.ttl") + + result = graph.parse(source=source) + + assert result is graph + mock_version_check.assert_called_once_with(pathlib.Path("file.ttl"), samm_version="1.0.0") + mock_parse.assert_called_once_with(source=pathlib.Path("file.ttl"), data=None) + + @mock.patch("esmf_aspect_meta_model_python.utils.has_version_mismatch_from_input", return_value=False) + @mock.patch("rdflib.Graph.parse") + def test_version_match_source_str(self, mock_parse, mock_version_check): + graph = AdaptiveGraph(samm_version="1.0.0") + source = "file.ttl" + + with mock.patch("pathlib.Path") as mock_path: + result = graph.parse(source=source) + + assert result is graph + mock_path.assert_called_once_with("file.ttl") + mock_version_check.assert_called_once_with(mock_path.return_value, samm_version="1.0.0") + mock_parse.assert_called_once_with(source=mock_path.return_value, data=None) + + @mock.patch("esmf_aspect_meta_model_python.utils.has_version_mismatch_from_input", return_value=True) + @mock.patch.object(AdaptiveGraph, "_upgrade_source", return_value="upgraded ttl data") + @mock.patch.object(AdaptiveGraph, "_upgrade_data") + @mock.patch("rdflib.Graph.parse") + def test_version_mismatch_from_file( + self, mock_parse, mock_upgrade_data, mock_upgrade_source, mock_mismatch, graph, tmp_path + ): + fake_file = tmp_path / "data.ttl" + fake_file.write_text("original ttl data") + + result = graph.parse(source=fake_file) + + assert result is graph + mock_mismatch.assert_called_once_with(fake_file, samm_version="1.0.0") + mock_upgrade_source.assert_called_once_with(fake_file) + mock_upgrade_data.assert_not_called() + mock_parse.assert_called_with(source=None, data="upgraded ttl data") + + @mock.patch("esmf_aspect_meta_model_python.utils.has_version_mismatch_from_input", return_value=True) + @mock.patch.object(AdaptiveGraph, "_upgrade_source") + @mock.patch.object(AdaptiveGraph, "_upgrade_data", return_value="upgraded ttl data") + @mock.patch("rdflib.Graph.parse") + def test_version_mismatch_from_data( + self, mock_parse, mock_upgrade_data, mock_upgrade_source, mock_mismatch, graph, tmp_path + ): + result = graph.parse(data="original ttl data") + + assert result is graph + mock_mismatch.assert_called_once_with("original ttl data", samm_version="1.0.0") + mock_upgrade_data.assert_called_once_with("original ttl data") + mock_upgrade_source.assert_not_called() + mock_parse.assert_called_with(source=None, data="upgraded ttl data") + + @mock.patch.object(AdaptiveGraph, "_upgrade_ttl_file", side_effect=RuntimeError("CLI failed")) + @mock.patch("esmf_aspect_meta_model_python.utils.has_version_mismatch_from_input", return_value=True) + def test_error_upgrade_failure(self, mock_version_check, mock_upgrade, graph): + with pytest.raises(RuntimeError, match="CLI failed"): + graph.parse(data="some data") + + mock_version_check.assert_called_once_with("some data", samm_version="1.0.0") + mock_upgrade.assert_called_once_with(mock.ANY) + + +@pytest.mark.parametrize( + ("operation", "operation_name"), + [ + ("add", "addition"), + ("sub", "subtraction"), + ("mul", "multiplication"), + ], +) +class TestOperatorOverloads: + def test_same_version(self, operation, operation_name, graph): + g2 = AdaptiveGraph(samm_version="1.0.0") + + with mock.patch(f"rdflib.Graph.__{operation}__", return_value=g2): + result = getattr(graph, f"__{operation}__")(g2) + + assert isinstance(result, AdaptiveGraph) + assert result._samm_version == "1.0.0" + + def test_add_version_conflict(self, operation, operation_name, graph): + g2 = AdaptiveGraph(samm_version="2.0.0") + + with mock.patch(f"rdflib.Graph.__{operation}__", return_value=g2): + with pytest.raises(ValueError, match=f"SAMM version mismatch during {operation_name}."): + getattr(graph, f"__{operation}__")(g2) + + def test_with_standard_graph(self, operation, operation_name, graph): + g2 = Graph() + + with mock.patch(f"rdflib.Graph.__{operation}__", return_value=graph): + result = getattr(graph, f"__{operation}__")(g2) + + assert isinstance(result, AdaptiveGraph) + assert result._samm_version == "1.0.0" + + def test_result_not_adaptive_graph(self, operation, operation_name, graph): + g2 = mock.MagicMock(spec=Graph) + + with mock.patch(f"rdflib.Graph.__{operation}__", return_value=g2): + result = getattr(graph, f"__{operation}__")(g2) + + assert result is g2 + assert not hasattr(result, "_samm_version") diff --git a/core/esmf-aspect-meta-model-python/tests/unit/test_utils.py b/core/esmf-aspect-meta-model-python/tests/unit/test_utils.py new file mode 100644 index 0000000..b214132 --- /dev/null +++ b/core/esmf-aspect-meta-model-python/tests/unit/test_utils.py @@ -0,0 +1,90 @@ +import pathlib + +from unittest import mock + +import pytest + +from esmf_aspect_meta_model_python import utils + + +class TestParseGraphFromInput: + @mock.patch("esmf_aspect_meta_model_python.utils.Graph", autospec=True) + def test_from_path(self, graph_mock): + input_source = pathlib.Path("input") + + result = utils._parse_graph_from_input(input_source) + + assert result is graph_mock.return_value + graph_mock.return_value.parse.assert_called_once_with(input_source) + + @mock.patch("esmf_aspect_meta_model_python.utils.Graph", autospec=True) + def test_from_data(self, graph_mock): + input_source = "input data" + + result = utils._parse_graph_from_input(input_source) + + assert result is graph_mock.return_value + graph_mock.return_value.parse.assert_called_once_with(data=input_source, format="turtle") + + +def test_get_samm_versions_from_graph(): + graph_mock = mock.MagicMock(name="graph") + graph_mock.namespace_manager.namespaces.return_value = [ + ("samm", "urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0#"), + ("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"), + ("samm-e", "urn:samm:org.eclipse.esmf.samm:entity:2.0.0#"), + ("other", "http://example.com/other#"), + ("samm1", "urn:samm:org.eclipse.esmf.samm:1.0.0#"), + ("samm-c", "urn:samm:org.eclipse.esmf.samm:component:1.0.0#"), + ("not-samm", "urn:not:samm:org.eclipse.esmf.samm:meta-model:3.0.0#"), + ] + + result = list(utils.get_samm_versions_from_graph(graph_mock)) + + assert result == ["1.0.0", "2.0.0", "1.0.0"] + graph_mock.namespace_manager.namespaces.assert_called_once_with() + + +class TestHasVersionMismatchInGraph: + @pytest.fixture + def graph_mock(self): + return mock.MagicMock(name="graph") + + def test_yes(self, graph_mock): + graph_mock.namespace_manager.namespaces.return_value = [ + ("samm", "urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0#"), + ("samm-c", "urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0#"), + ("samm-e", "urn:samm:org.eclipse.esmf.samm:entity:2.0.0#"), + ("samm2", "urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0#"), + ] + + result = utils.has_version_mismatch_in_graph(graph_mock, samm_version="1.0.0") + + assert result is True + graph_mock.namespace_manager.namespaces.assert_called_once_with() + + def test_no(self, graph_mock): + graph_mock.namespace_manager.namespaces.return_value = [ + ("samm", "urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0#"), + ("samm-e", "urn:samm:org.eclipse.esmf.samm:entity:1.0.0#"), + ("samm-c", "urn:samm:org.eclipse.esmf.samm:entity:1.0.0#"), + ] + + result = utils.has_version_mismatch_in_graph(graph_mock, samm_version="1.0.0") + + assert result is False + graph_mock.namespace_manager.namespaces.assert_called_once_with() + + +@pytest.mark.parametrize("has_mismatch", [True, False]) +@mock.patch("esmf_aspect_meta_model_python.utils._parse_graph_from_input", autospec=True) +@mock.patch("esmf_aspect_meta_model_python.utils.has_version_mismatch_in_graph", autospec=True) +def test_has_version_mismatch_from_input(mismatch_mock, parse_mock, has_mismatch): + input_source = "input source" + mismatch_mock.return_value = has_mismatch + + result = utils.has_version_mismatch_from_input(input_source, samm_version="1.0.0") + + assert result is has_mismatch + parse_mock.assert_called_once_with(input_source) + mismatch_mock.assert_called_once_with(parse_mock.return_value, samm_version="1.0.0") diff --git a/core/esmf-aspect-meta-model-python/tox.ini b/core/esmf-aspect-meta-model-python/tox.ini index 6aed071..31a3d82 100644 --- a/core/esmf-aspect-meta-model-python/tox.ini +++ b/core/esmf-aspect-meta-model-python/tox.ini @@ -11,7 +11,7 @@ description = Run the tests commands_pre = poetry install commands = poetry run pytest {posargs: \ - -s -vv \ + -x -s -vv \ --cov=esmf_aspect_meta_model_python/ \ --cov-fail-under=85 \ tests/ \ @@ -42,4 +42,4 @@ known_first_party = esmf_aspect_meta_model_python, tests line_length = 120 lines_between_types = 1 multi_line_output = 3 -sections = STDLIB, THIRDPARTY, FIRSTPARTY, LOCALFOLDER \ No newline at end of file +sections = STDLIB, THIRDPARTY, FIRSTPARTY, LOCALFOLDER