diff --git a/core/esmf-aspect-meta-model-python/README.md b/core/esmf-aspect-meta-model-python/README.md index 2e79d0a..fe13562 100644 --- a/core/esmf-aspect-meta-model-python/README.md +++ b/core/esmf-aspect-meta-model-python/README.md @@ -9,6 +9,7 @@ https://projects.eclipse.org/projects/dt.esmf). * [Download SAMM files](#download-samm-files) * [Download SAMM release](#download-samm-release) * [Download SAMM branch](#download-samm-branch) + * [Input data handler usage](#input-data-handler-usage) * [Aspect Meta Model Loader usage](#aspect-meta-model-loader-usage) * [Samm Units](#samm-units) * [SAMM CLI wrapper class](#samm-cli-wrapper-class) @@ -84,14 +85,47 @@ poetry run download-samm-branch ``` Link to all branches: [SAMM Releases](https://github.com/eclipse-esmf/esmf-semantic-aspect-meta-model/branches) +## Input data handler usage + +The InputHandler is a general-purpose class designed for loading input data into an RDF graph. +It easily accommodates different input sources such as local files (.ttl) or direct data strings containing +RDF formatted data. + +```python +from esmf_aspect_meta_model_python.resolver.handler import InputHandler + +# Instantiating the Handler +# The InputHandler requires a path or data string upon instantiation, which defines the source of RDF data +# local file +model_path = "path/to/local/file/AspectName.ttl" +handler = InputHandler(model_path) +graph, aspect_urn = handler.get_rdf_graph() + +# returns a tuple containing the RDF graph and the aspect URN derived from the provided data source +``` + +```python +from esmf_aspect_meta_model_python.resolver.handler import InputHandler + +# Alternatively, if you have RDF data in a string format, you can directly pass it as follows: +rdf_data_string = "your RDF data string here" +handler = InputHandler(rdf_data_string) +graph, aspect_urn = handler.get_rdf_graph() +``` + ## Aspect Meta Model Loader usage An Aspect of the Meta Model can be loaded as follows: ```python from esmf_aspect_meta_model_python import AspectLoader +from esmf_aspect_meta_model_python.resolver.handler import InputHandler + +model_path = "absolute/path/to/turtle.ttl" +handler = InputHandler(model_path) +graph, aspect_urn = handler.get_rdf_graph() loader = AspectLoader() -model_elements = loader.load_aspect_model("absolute/path/to/turtle.ttl") +model_elements = loader.load_aspect_model(graph, aspect_urn) aspect = model_elements[0] # or you can provide an Aspect URN diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/__init__.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/__init__.py index 0456b9b..e26b96a 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/__init__.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/__init__.py @@ -87,3 +87,4 @@ ) from .loader.aspect_loader import AspectLoader from .loader.samm_graph import SAMMGraph +from .resolver.handler import InputHandler diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/loader/aspect_loader.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/loader/aspect_loader.py index a6ecfad..afb5db9 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/loader/aspect_loader.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/loader/aspect_loader.py @@ -9,10 +9,11 @@ # # SPDX-License-Identifier: MPL-2.0 -from pathlib import Path -from typing import Union +from typing import List -from esmf_aspect_meta_model_python.loader.default_element_cache import DefaultElementCache +from rdflib import Graph, URIRef + +from esmf_aspect_meta_model_python.base.aspect import Aspect from esmf_aspect_meta_model_python.loader.samm_graph import SAMMGraph @@ -24,55 +25,37 @@ class AspectLoader: The default cache strategy ignores inline defined elements. """ - def __init__(self) -> None: - self._cache = DefaultElementCache() - self._graph = SAMMGraph() - - def get_graph(self) -> SAMMGraph: - """Get SAMM graph. + def __init__(self): + self.graph = None - :return: parsed SAMM Aspect model Graph. + def load_aspect_model(self, rdf_graph: Graph, aspect_urn: URIRef | str = "") -> List[Aspect]: """ - return self._graph - - def get_samm_version(self) -> str: - """Get SAMM version of the graph.""" - return self._graph.get_samm_version() + Creates a python object(s) to represent the Aspect model graph. - @staticmethod - def convert_file_path(file_path: Union[str, Path]) -> str: - """Convert file_path to the string. - - :param file_path: path to model file - """ - if isinstance(file_path, Path): - file_path = str(file_path) + This function takes an RDF graph and a URN for an Aspect node and converts it into + a set of structured and connected Python objects that represents the Aspect model graph. The output is a + list of Python objects derived from the RDF graph centered around the specified Aspect node. - tmp_path = Path(file_path) - if not tmp_path.exists(): - raise FileNotFoundError(f"Could not found the file {tmp_path}") + Args: + rdf_graph (RDFGraph): The RDF graph from which to create the model. + aspect_urn (str): The URN identifier for the main Aspect node in the RDF graph. - return file_path + Returns: + list: A list of Python objects that represent the Aspect elements of the Aspect model graph. - def _reset_graph(self): - """Reset graph and cache data.""" - if self._graph: - self._graph = SAMMGraph() + Examples: + # Assuming 'graph' is a predefined RDFGraph object and 'aspect_urn' is defined: + aspect_model = create_aspect_model_graph(graph, "urn:example:aspectNode") + print(aspect_model) # This prints the list of Python objects. - if self._cache: - self._cache = DefaultElementCache() - - def load_aspect_model(self, file_path: Union[Path, str]): - """Load aspect model to RDF GRAPH. - - Create an aspect object with all the including properties and operations with the turtle file - - :param file_path: path to the turtle file. Can be either a string or a Path object - :return: instance of the aspect + Notes: + It's crucial that the aspect_urn corresponds to a valid Aspect node within the RDF graph; + otherwise, the function may not perform as expected. """ - file_path = self.convert_file_path(file_path) - self._reset_graph() - _ = self._graph.parse(file_path) - loaded_aspect_model = self._graph.to_python() + self.graph = SAMMGraph(graph=rdf_graph) + loaded_aspect_model = self.graph.to_python(aspect_urn) + + # Add check that loaded_aspect_model is not empty + # Add check that aspect_urn is ref to an Aspect node return loaded_aspect_model 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 d97e334..8b91c29 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 @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH # # See the AUTHORS file(s) distributed with this work for additional # information regarding authorship. @@ -9,17 +9,17 @@ # # SPDX-License-Identifier: MPL-2.0 -from pathlib import Path from typing import List, Optional, Union from rdflib import RDF, Graph, URIRef from rdflib.graph import Node +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 from esmf_aspect_meta_model_python.loader.default_element_cache import DefaultElementCache from esmf_aspect_meta_model_python.loader.model_element_factory import ModelElementFactory -from esmf_aspect_meta_model_python.resolver.base import AspectModelResolver, BaseResolver +from esmf_aspect_meta_model_python.resolver.meta_model import AspectMetaModelResolver from esmf_aspect_meta_model_python.vocabulary.SAMM import SAMM @@ -31,16 +31,13 @@ class SAMMGraph: def __init__( self, graph: Graph | None = None, - resolver: BaseResolver | None = None, - cache: DefaultElementCache | None = None, + cache: Union[DefaultElementCache, None] = None, ): - super().__init__() - self._graph = graph if graph else Graph() - self._resolver = resolver if resolver else AspectModelResolver() self._cache = cache if cache else DefaultElementCache() self._samm_version = "" - self._file_path: str = "" + + self.populate_with_meta_data() def __repr__(self) -> str: return repr(self._graph) @@ -52,7 +49,7 @@ def get_rdf_graph(self) -> Graph: """Get RDF graph.""" return self._graph - def get_samm_version(self) -> str: + def _get_samm_version_from_graph(self): """Get SAMM version from the graph.""" version = "" @@ -63,64 +60,38 @@ def get_samm_version(self) -> str: return version - @staticmethod - def convert_file_path(file_path: Union[Path, str]) -> str: - """Convert file_path to the string. - - :param file_path: path to model file - """ - if isinstance(file_path, Path): - file_path = str(file_path) - - return file_path - - def parse(self, file_path: Union[Path, str]) -> Graph: - """Parse a file to the SAMM graph. - - :param file_path: Path to the *ttl file. - """ - self._file_path = self.convert_file_path(file_path) - self._graph.parse(self._file_path) - self._samm_version = self.get_samm_version() - self._resolver.resolve(self._graph, self._file_path, self._samm_version) - - return self._graph + def get_samm_version(self): + """Get SAMM version from the graph.""" + version = self._get_samm_version_from_graph() - def _get_model_file_path(self, model_file_path: str = "") -> str: - """Get a model file path. + if not version: + raise ValueError("SAMM version not found in the Graph.") + else: + self._samm_version = version - :param model_file_path: str with path to the model - :return: validated path rto the model fiel - """ - model_file_path = model_file_path if model_file_path else self._file_path - if not model_file_path: - raise ValueError("Path to the model is empty") + def populate_with_meta_data(self): + """Populate RDF graph with SAMM data.""" + if not self._samm_version: + self.get_samm_version() - return model_file_path + meta_model_reader = AspectMetaModelResolver() + meta_model_reader.parse(self._graph, self._samm_version) - def get_nodes_from_graph(self, model_file_path: str = "") -> List[Node]: - """Get a list of URIRef to nodes from the base model file.""" + def get_aspect_nodes_from_graph(self) -> List[Node]: + """Get a list of Aspect nodes from the graph.""" nodes = [] - model_file_path = self._get_model_file_path(model_file_path) - base_graph = Graph().parse(model_file_path, format="turtle") + samm = SAMM(self._samm_version) # Search for Aspect elements - samm = SAMM(self._samm_version) - for subject in base_graph.subjects(predicate=RDF.type, object=samm.get_urn(SAMM.aspect)): # type: ignore + for subject in self._graph.subjects(predicate=RDF.type, object=samm.get_urn(SAMM.aspect)): # type: ignore nodes.append(subject) - if not nodes: - for subject, object in base_graph.subject_objects(predicate=RDF.type, unique=True): - prefix_data = str(object).replace("<", "").split(":") - if ":".join(prefix_data[:3]) == self.samm_prefix: - nodes.append(subject) - return nodes def get_base_nodes(self, aspect_urn: URIRef | str = "") -> List[Node]: """Get a list of base graph elements. - :param aspect_urn: URN of the Aspect node. + :param model_pointer: pointer to the model :return: List of base graph elements. """ base_elements: list[Node] = [] @@ -128,13 +99,16 @@ def get_base_nodes(self, aspect_urn: URIRef | str = "") -> List[Node]: if aspect_urn: base_elements += [aspect_urn if isinstance(aspect_urn, URIRef) else URIRef(aspect_urn)] else: - base_elements += self.get_nodes_from_graph() + base_elements += self.get_aspect_nodes_from_graph() return base_elements - def to_python(self, aspect_urn: URIRef | str = "") -> List[URIRef | None]: + def to_python(self, aspect_urn: URIRef | str = "") -> List[Aspect]: """Convert SAMM graph to Python objects.""" base_nodes = self.get_base_nodes(aspect_urn) + if not base_nodes: + raise ValueError(f"Could not found Aspect node by the URN {aspect_urn}.") + model_element_factory = ModelElementFactory(self._samm_version, self._graph, self._cache) aspect_elements = model_element_factory.create_all_graph_elements(base_nodes) 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 655e410..b33eda6 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 @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH # # See the AUTHORS file(s) distributed with this work for additional # information regarding authorship. @@ -13,73 +13,109 @@ from rdflib import Graph -from esmf_aspect_meta_model_python.resolver.meta_model import AspectMetaModelResolver, BaseMetaModelResolver -from esmf_aspect_meta_model_python.resolver.namespace import AspectNamespaceResolver, BaseNamespaceResolver +from esmf_aspect_meta_model_python.samm_meta_model import SammUnitsGraph -class BaseResolver(ABC): - """Base Aspect resolver.""" +class ResolverInterface(ABC): + """ + Abstract class defining the interface for resolver classes. + + This class provides the template method `read` which all subclasses must implement to specify + how they read data and return it. + + Methods: + read(): Method to be overridden by subclasses to provide specific reading logic. + get_aspect_urn(): Method to be overridden by subclasses to provide specific to provide specific logic to find + the appropriate aspect urn. + get_samm_version(): Method to find a SAMM version. + """ + + def __init__(self): + self.graph = Graph() + self.aspect_urn = "" + self.samm_version = "" @abstractmethod - def resolve(self, aspect_graph: Graph, aspect_file_path: str, meta_model_version: str): - """Resolve Aspect meta-model and namespace prefixes. + def read(self, input_data: str) -> Graph: + """ + Abstract method to read data. + + Subclasses must implement this method to handle the specific details of reading data + from their respective sources and return the data in the required format. + + Args: + input_data (str): The input data to be read. - :param aspect_graph: Aspect model graph - :param meta_model_version: Meta model version - :param aspect_file_path:path to the aspect model file + Returns: + Data read from the source, the type of the data can be decided based on the specific subclass. """ @abstractmethod - def resolve_meta_model(self, aspect_graph: Graph, meta_model_version: str): - """Resolve SAMM meta-model with tha specific version + def get_aspect_urn(self) -> str: + """ + Abstract method to get an aspect urn. + + Subclasses must implement this method to handle the specific details of getting a URN of aspect. - :param aspect_graph: Aspect graph - :param meta_model_version: Meta model version + Returns: + String with URN of the aspect. """ - @abstractmethod - def resolve_namespaces(self, aspect_graph: Graph, aspect_file_path: str): - """Resolve namespace dependencies of the aspect graph. + @staticmethod + def _validate_samm_version(samm_version: str): + """ + Validates the provided SAMM version string against a supported version. + + This method checks if the `samm_version` provided and matches of the SAMM version supported by the system. - :param aspect_graph: Aspect graph - :param aspect_file_path: path to the aspect model file + Args: + samm_version (str): The version string of SAMM to be validated. Expected to be in the format like '1.2.3'. + + Raises: + ValueError: If `samm_version` is empty or not supplied. """ + if not samm_version: + raise ValueError("SAMM version not found in the Graph.") + elif samm_version != SammUnitsGraph.SAMM_VERSION: + raise ValueError(f"{samm_version} is not supported SAMM version.") + def _get_samm_version_from_graph(self): + """ + Extracts the SAMM version from the RDF graph. -class AspectModelResolver(BaseResolver): - """Aspect model resolver class. + This method searches through the RDF graph namespaces to find a prefix that indicate the SAMM version. - Provide a functions for resolving SAMM meta-model and Aspect model namespaces. - """ + Returns: + str: The SAMM version as a string extracted from the graph. Returns an empty string if no version + can be conclusively identified. + """ + version = "" - def __init__( - self, - meta_model_resolver: BaseMetaModelResolver | None = None, - namespace_resolver: BaseNamespaceResolver | None = None, - ): - self._meta_model_resolver = meta_model_resolver if meta_model_resolver else AspectMetaModelResolver() - self._namespace_resolver = namespace_resolver if namespace_resolver else AspectNamespaceResolver() + for prefix, namespace in self.graph.namespace_manager.namespaces(): + if prefix == "samm": + urn_parts = namespace.split(":") + version = urn_parts[-1].replace("#", "") - def resolve(self, aspect_graph: Graph, aspect_file_path: str, meta_model_version: str): - """Resolve Aspect meta-model and namespace prefixes. + return version - :param aspect_graph: Aspect model graph - :param meta_model_version: Meta model version - :param aspect_file_path:path to the aspect model file + def get_samm_version(self) -> str: """ - self.resolve_meta_model(aspect_graph, meta_model_version) - self.resolve_namespaces(aspect_graph, aspect_file_path) + 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. - def resolve_meta_model(self, aspect_graph: Graph, meta_model_version: str): - """Resolve SAMM meta-model with tha specific version - :param aspect_graph: Aspect graph - :param meta_model_version: Meta model version""" - self._meta_model_resolver.parse(aspect_graph, meta_model_version) + 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. - def resolve_namespaces(self, aspect_graph: Graph, aspect_file_path: str): - """Resolve namespace dependencies of the aspect graph. + 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 - :param aspect_graph: Aspect graph - :param aspect_file_path: path to the aspect model file""" - self._namespace_resolver.parse(aspect_graph, aspect_file_path) + return version 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 new file mode 100644 index 0000000..4d33b8c --- /dev/null +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/data_string.py @@ -0,0 +1,53 @@ +# 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 rdflib import RDF, Graph + +from esmf_aspect_meta_model_python.resolver.base import ResolverInterface +from esmf_aspect_meta_model_python.vocabulary.SAMM import SAMM + + +class DataStringResolver(ResolverInterface): + """String aspect model presenter resolver.""" + + def read(self, data_string: str): + """ + Parses the provided data string into an RDF graph. + + This method takes a string that contains RDF graph description in a serialization format (such as Turtle, XML, + or JSON-LD) and converts it into an RDF graph object. + + Args: + data_string (str): A string containing RDF data. This should be in a valid RDF serialization format. + + Returns: + RDFGraph: An object representing the RDF graph constructed from the input data. + """ + self.graph = Graph() + self.graph.parse(data=data_string) + + return self.graph + + def get_aspect_urn(self): + """ + Retrieves the URN pointing to the main aspect node of the RDF graph. + + This method searches the RDF graph for the node with predicate RDF.type and object a SAMM Aspect, + The URN (Uniform Resource Name) of this node is then returned. This method assumes + that the graph contains exactly one main aspect node. + + Returns: + str: The URN of the SAMM aspect node in the RDF graph. + """ + samm = SAMM(self.get_samm_version()) + self.aspect_urn = self.graph.value(predicate=RDF.type, object=samm.get_urn(SAMM.aspect), any=False) + + return self.aspect_urn diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/handler.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/handler.py new file mode 100644 index 0000000..d80fd8a --- /dev/null +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/handler.py @@ -0,0 +1,121 @@ +# 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 os + +from typing import Optional, Tuple + +from rdflib import Graph + +from esmf_aspect_meta_model_python.resolver.data_string import DataStringResolver +from esmf_aspect_meta_model_python.resolver.local_file import LocalFileResolver + + +class InputHandler: + """ + Handles the input for RDF graph processing based on the specified type or detected type of the input data. + + The InputHandler class now takes an additional parameter indicating the data type (file path or string data). + If the data type is not provided, the class attempts to determine the type based on the content and format + of the input. + + Attributes: + input_data (str): The initial input data which can be a path or a direct graph description. + input_type (Optional[str]): Type of input data provided, could be 'file' for file path and + 'string' for direct data. + + Methods: + get_reader(): Returns the appropriate reader for the input type. + get_rdf_graph(): Parses the input data and returns the corresponding RDF graph based on the detected or + provided input type. + guess_input_type(): Guesses the input type based on the detected input type. + contains_newline(): Checks if the input data is a string with several lines. + """ + + DATA_STRING = "data_string" + FILE_PATH_TYPE = "file_path" + + def __init__(self, input_data: str, input_type: Optional[str] = None): + """ + Initializes the InputHandler with provided input data and optional input type. + + Args: + input_data (str): A string which is either the path to the RDF file or the string of RDF data. + input_type (Optional[str]): Optional string indicating type of input ('file' or 'string'). + If None, the type is guessed. + """ + self.input_data = input_data + self.input_type = input_type if input_type else self.guess_input_type(input_data) + + def get_reader(self): + """ + Factory method that returns a reader instance based on the input type. + + Depending on the 'input_type', this method returns an instance of a corresponding reader class. + This method simplifies object creation and allows for extendability of reader types. + + Returns: + Reader: An instance of a reader that conforms to the Reader interface. + + Raises: + ValueError: If the 'input_type' does not correspond to a known reader type. + """ + reader = None + + if self.input_type == self.FILE_PATH_TYPE: + reader = LocalFileResolver() + elif self.input_type == self.DATA_STRING: + reader = DataStringResolver() + + if not reader: + raise ValueError("Unknown input type") + + return reader + + def get_rdf_graph(self) -> Tuple[Graph, str]: + """ + Determines the type of input and retrieves the RDF graph from it. + + Returns: + An RDF graph object based on the parsed input data. + """ + reader = self.get_reader() + graph = reader.read(self.input_data) + aspect_urn = reader.get_aspect_urn() + + return graph, aspect_urn + + def guess_input_type(self, input_str: str) -> str: + """ + Guesses the type of input based on its content and configuration. + + Args: + input_str (str): The input string to type-check. + + Returns: + str: Guessed input type ('file' or 'string'). + """ + if not self.contains_newline(input_str) and os.path.isfile(input_str): + return self.FILE_PATH_TYPE + return self.DATA_STRING + + @staticmethod + def contains_newline(input_str: str) -> bool: + """ + Checks if the provided string contains a newline character. + + Args: + input_str (str): The string to be inspected for newline characters. + + Returns: + bool: True if the string contains at least one newline character, False otherwise. + """ + return "\n" in input_str diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/namespace.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/local_file.py similarity index 64% rename from core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/namespace.py rename to core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/local_file.py index 051d66f..1b69506 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/namespace.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/local_file.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH # # See the AUTHORS file(s) distributed with this work for additional # information regarding authorship. @@ -9,34 +9,22 @@ # # SPDX-License-Identifier: MPL-2.0 -from abc import ABC, abstractmethod from os.path import exists, join from pathlib import Path from typing import Dict, List, Optional, Tuple -from rdflib import Graph +from rdflib import RDF, Graph +from esmf_aspect_meta_model_python.resolver.base import ResolverInterface +from esmf_aspect_meta_model_python.vocabulary.SAMM import SAMM -class BaseNamespaceResolver(ABC): - """Interface for namespace resolver class.""" - @abstractmethod - def parse(self, aspect_graph: Graph, aspect_file_path: str): - """Parse Aspect namespaces. - - :param aspect_graph: RDF Graph - :param aspect_file_path: path to the Aspect model file - """ - - -class AspectNamespaceResolver(BaseNamespaceResolver): - """Aspect model namespace dependency resolver. - - Recursively go through the Aspect namespaces and resolve (parse) additional models. - """ +class LocalFileResolver(ResolverInterface): + """Local storage aspect model file resolver.""" def __init__(self): - self.aspect_graph = None + super().__init__() + self.file_path = None @staticmethod @@ -81,7 +69,8 @@ def _get_dirs_for_advanced_loading(self, file_path: str) -> List[str]: paths_for_advanced_loading = [] base_path = Path(file_path).parents[2] - for prefix, namespace in self.aspect_graph.namespace_manager.namespaces(): + namespaces = self.graph.namespace_manager.namespaces() + for prefix, namespace in namespaces: namespace_specific_str, version = self._parse_namespace(namespace) if namespace_specific_str and version: paths_for_advanced_loading.append(join(base_path, namespace_specific_str, version)) @@ -95,7 +84,7 @@ def _get_dependency_folders(self, file_path: str) -> List[str]: :return: list of dependency folders """ if file_path != self.file_path: - self.aspect_graph.parse(file_path, format="turtle") + self.graph.parse(file_path, format="turtle") dependency_folders = self._get_dirs_for_advanced_loading(file_path) @@ -142,20 +131,67 @@ def _get_dependency_files( for file_path in files: if file_path not in file_dependencies: - self._get_dependency_files(file_dependencies, folder_dependencies, file_path) + try: + self._get_dependency_files(file_dependencies, folder_dependencies, file_path) + except Exception as error: + print(f"Could not parse file {file_path}\nError: {error}") + raise return file_dependencies - def parse(self, aspect_graph, aspect_file_path: str): + def parse_namespaces(self, aspect_file_path: str): """Parse namespaces from the Aspect model. :param aspect_graph: RDF Graph :param aspect_file_path: path to the Aspect model file """ - self.aspect_graph = aspect_graph - self.file_path = aspect_file_path - file_dependencies: Dict[str, List[str]] = {} folder_dependencies: Dict[str, List[str]] = {} self._get_dependency_files(file_dependencies, folder_dependencies, aspect_file_path) + + def read(self, file_path: str) -> Graph: + """ + Read an RDF graph stored in the local file. + + This method takes a string with a path to the file with RDF graph description in a serialization format + (such as Turtle, XML, or JSON-LD) and converts it into an RDF graph object. + + Args: + file_path (str): A string with path to the file with RDF graph description. + + Returns: + RDFGraph: An object representing the RDF graph constructed from the input data. + """ + self.file_path = file_path + self.graph.parse(file_path) + self._find_aspect_urn() + self.parse_namespaces(self.file_path) + + return self.graph + + def _find_aspect_urn(self): + """ + Find a main aspect node in the RDF graph. + + Searches the node with RDF.type predicate and SAMM Aspect obkect type. + """ + samm = SAMM(self.get_samm_version()) + file_name = Path(self.file_path).stem + for aspect in self.graph.subjects(predicate=RDF.type, object=samm.get_urn(SAMM.aspect)): + if str(aspect).split("#")[-1] == file_name: + self.aspect_urn = aspect + break + + def get_aspect_urn(self): + """ + Retrieves the URN pointing to the main aspect node of the RDF graph. + + This method searches the RDF graph for the node with predicate RDF.type and object a SAMM Aspect, + The URN (Uniform Resource Name) of this node is then returned. This method assumes + that the graph contains exactly one main aspect node. + + Returns: + str: The URN of the SAMM aspect node in the RDF graph. + """ + return self.aspect_urn diff --git a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/meta_model.py b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/meta_model.py index a5d12c5..a1f67e5 100644 --- a/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/meta_model.py +++ b/core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/resolver/meta_model.py @@ -9,7 +9,6 @@ # # SPDX-License-Identifier: MPL-2.0 -from abc import ABC, abstractmethod from glob import glob from os.path import exists, join from pathlib import Path @@ -18,19 +17,7 @@ from rdflib import Graph -class BaseMetaModelResolver(ABC): - """Interface for meta-model resolver class.""" - - @abstractmethod - def parse(self, aspect_graph: Graph, meta_model_version: str): - """Parse SAMM meta-model files. - - :param aspect_graph: RDF Graph - :param meta_model_version: version of the meta-model to extract the right SAMM turtle files - """ - - -class AspectMetaModelResolver(BaseMetaModelResolver): +class AspectMetaModelResolver: """SAMM meta-model resolver class.""" samm_folder_path = join("esmf_aspect_meta_model_python", "samm_aspect_meta_model", "samm") @@ -61,7 +48,7 @@ def validate_file(file_path: str): "Try to install SAMM Meta Model using 'download-samm-release' or 'download-samm-branch' command", ) - def parse(self, aspect_graph: Graph, meta_model_version: str): + def parse(self, rdf_graph: Graph, meta_model_version: str): """Resolve SAMM meta-model data. Merges the information of the global SAMM from turtle files into the aspect graph. @@ -71,9 +58,9 @@ def parse(self, aspect_graph: Graph, meta_model_version: str): - entity - unit - :param aspect_graph: RDF Graph + :param rdf_graph: RDF graph :param meta_model_version: version of the meta-model to extract the right SAMM turtle files """ for file_path in self._get_samm_files_path(meta_model_version): self.validate_file(file_path) - aspect_graph.parse(file_path, format="turtle") + rdf_graph.parse(file_path, format="turtle") diff --git a/core/esmf-aspect-meta-model-python/pyproject.toml b/core/esmf-aspect-meta-model-python/pyproject.toml index e56bdf8..b8aff18 100644 --- a/core/esmf-aspect-meta-model-python/pyproject.toml +++ b/core/esmf-aspect-meta-model-python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "esmf-aspect-model-loader" -version = "2.1.5" +version = "2.1.6" description = "Load Aspect Models based on the Semantic Aspect Meta Model" authors = [ "Eclipse Semantic Modeling Framework", diff --git a/core/esmf-aspect-meta-model-python/samm_elements/__init__.py b/core/esmf-aspect-meta-model-python/samm_elements/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/esmf-aspect-meta-model-python/tests/integration/java_models/test_loading_aspects.py b/core/esmf-aspect-meta-model-python/tests/integration/java_models/test_loading_aspects.py index 3c55da0..e065f4e 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/java_models/test_loading_aspects.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/java_models/test_loading_aspects.py @@ -8,6 +8,7 @@ from pathlib import Path from esmf_aspect_meta_model_python.loader.aspect_loader import AspectLoader +from esmf_aspect_meta_model_python.resolver.handler import InputHandler from scripts.constants import TestModelConstants from scripts.download_test_models import download_test_models @@ -65,8 +66,10 @@ def load_test_models(): } try: + handler = InputHandler(str(test_file)) + rdf_graph, aspect_urn = handler.get_rdf_graph() loader = AspectLoader() - model_elements = loader.load_aspect_model(test_file) + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) if not model_elements: raise Exception("No elements loaded") except Exception as error: diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithBlankNode.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithBlankNode.ttl similarity index 94% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithBlankNode.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithBlankNode.ttl index 773df90..6170a6d 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithBlankNode.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithBlankNode.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithCode.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCode.ttl similarity index 94% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithCode.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCode.ttl index d71167c..33a254f 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithCode.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCode.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithCollection.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollection.ttl similarity index 95% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithCollection.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollection.ttl index 26a39d1..3f9d283 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithCollection.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollection.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithCollectionWithElementCharacteristic.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollectionWithElementCharacteristic.ttl similarity index 95% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithCollectionWithElementCharacteristic.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollectionWithElementCharacteristic.ttl index 06f843d..0c264e7 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithCollectionWithElementCharacteristic.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithCollectionWithElementCharacteristic.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithDuration.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithDuration.ttl similarity index 94% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithDuration.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithDuration.ttl index ee718c7..440f716 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithDuration.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithDuration.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithList.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithList.ttl similarity index 95% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithList.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithList.ttl index 5c9abd2..4aa8f95 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithList.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithList.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithMeasurement.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithMeasurement.ttl similarity index 94% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithMeasurement.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithMeasurement.ttl index 4f30341..d91bbff 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithMeasurement.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithMeasurement.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithQuantifiableAndUnit.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithQuantifiableAndUnit.ttl similarity index 94% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithQuantifiableAndUnit.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithQuantifiableAndUnit.ttl index 2f771e8..006c736 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithQuantifiableAndUnit.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithQuantifiableAndUnit.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithSet.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSet.ttl similarity index 95% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithSet.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSet.ttl index 8fa2a86..28ec741 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithSet.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSet.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithSimpleEnum.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSimpleEnum.ttl similarity index 84% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithSimpleEnum.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSimpleEnum.ttl index 582725c..f95014b 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithSimpleEnum.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.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/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithSortedSet.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSortedSet.ttl similarity index 95% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithSortedSet.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSortedSet.ttl index 20f6b4b..c10c4a9 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithSortedSet.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithSortedSet.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithState.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithState.ttl similarity index 84% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithState.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithState.ttl index 9e7d969..54635f4 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithState.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.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/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithStructuredValue.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithStructuredValue.ttl similarity index 95% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithStructuredValue.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithStructuredValue.ttl index 2609973..f665b19 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0/AspectWithStructuredValue.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0/AspectWithStructuredValue.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithConstrainedCollection.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithConstrainedCollection.ttl similarity index 94% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithConstrainedCollection.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithConstrainedCollection.ttl index 9bbcc1a..4423134 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithConstrainedCollection.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithConstrainedCollection.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithEncodingConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithEncodingConstraint.ttl similarity index 96% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithEncodingConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithEncodingConstraint.ttl index a2edbdc..2b6064c 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithEncodingConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithEncodingConstraint.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithFixedPoint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithFixedPoint.ttl similarity index 95% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithFixedPoint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithFixedPoint.ttl index 36981db..3251d9a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithFixedPoint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithFixedPoint.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithLanguageConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLanguageConstraint.ttl similarity index 96% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithLanguageConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLanguageConstraint.ttl index 2261342..51f1011 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithLanguageConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLanguageConstraint.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithLengthConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLengthConstraint.ttl similarity index 96% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithLengthConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLengthConstraint.ttl index 8f0fafc..ada882b 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithLengthConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLengthConstraint.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithLocaleConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLocaleConstraint.ttl similarity index 87% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithLocaleConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithLocaleConstraint.ttl index 21fff7b..a1c11e3 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithLocaleConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.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/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithMultipleConstraints.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithMultipleConstraints.ttl similarity index 90% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithMultipleConstraints.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithMultipleConstraints.ttl index 0a9912d..5654a91 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithMultipleConstraints.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.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/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithMultipleOneValueConstraints.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithMultipleOneValueConstraints.ttl similarity index 90% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithMultipleOneValueConstraints.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithMultipleOneValueConstraints.ttl index cb2f009..78f9eba 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithMultipleOneValueConstraints.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.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/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithRangeConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraint.ttl similarity index 88% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithRangeConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraint.ttl index d6079b7..8e8697b 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithRangeConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.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/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl similarity index 96% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl index 887f7bc..56ebaf0 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRangeConstraintInclBoundDefinitionProperties.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithRegularExpressionConstraint.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRegularExpressionConstraint.ttl similarity index 96% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithRegularExpressionConstraint.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRegularExpressionConstraint.ttl index 028d0a4..a7387e0 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0/AspectWithRegularExpressionConstraint.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0/AspectWithRegularExpressionConstraint.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractEntity.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractEntity.ttl similarity index 93% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractEntity.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractEntity.ttl index c7d3752..58856f5 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractEntity.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractEntityMultipleAttributes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractEntityMultipleAttributes.ttl similarity index 92% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractEntityMultipleAttributes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractEntityMultipleAttributes.ttl index fb0034a..74d9ea7 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractEntityMultipleAttributes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractPropertyBlankNode.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyBlankNode.ttl similarity index 90% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractPropertyBlankNode.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyBlankNode.ttl index 8c2b7d3..8dd7110 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractPropertyBlankNode.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl similarity index 89% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl index edb38c1..acee99b 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractPropertyMultipleAbstractEntities.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractPropertyMultipleAttributes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyMultipleAttributes.ttl similarity index 91% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractPropertyMultipleAttributes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithAbstractPropertyMultipleAttributes.ttl index bd46923..f685e5a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithAbstractPropertyMultipleAttributes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithEntity.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntity.ttl similarity index 91% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithEntity.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntity.ttl index 920e267..91e3eb9 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithEntity.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithEntityEnum.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntityEnum.ttl similarity index 91% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithEntityEnum.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntityEnum.ttl index a107039..6ed8b29 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithEntityEnum.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithEntityExtendingFileResource.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntityExtendingFileResource.ttl similarity index 83% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithEntityExtendingFileResource.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithEntityExtendingFileResource.ttl index 8407e30..f50b8f5 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithEntityExtendingFileResource.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithFileResourceEntity.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithFileResourceEntity.ttl similarity index 79% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithFileResourceEntity.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithFileResourceEntity.ttl index e0666e3..47c1372 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithFileResourceEntity.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl similarity index 94% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl index 25f1a71..5eada1c 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithMultipleEntitiesSameExtend.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultipleEntitiesSameExtend.ttl similarity index 90% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithMultipleEntitiesSameExtend.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultipleEntitiesSameExtend.ttl index 4fa9d88..1c55104 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithMultipleEntitiesSameExtend.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithMultiplePropertiesSameExtend.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultiplePropertiesSameExtend.ttl similarity index 92% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithMultiplePropertiesSameExtend.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithMultiplePropertiesSameExtend.ttl index 1c553cb..39d7993 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithMultiplePropertiesSameExtend.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithPoint3d.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithPoint3d.ttl similarity index 85% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithPoint3d.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithPoint3d.ttl index d3d547f..2bd5145 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithPoint3d.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithTimeSeries.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeries.ttl similarity index 96% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithTimeSeries.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeries.ttl index 4f1de5d..644913e 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithTimeSeries.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeries.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix samm-e: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithTimeSeriesWithComplexType.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeriesWithComplexType.ttl similarity index 88% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithTimeSeriesWithComplexType.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithTimeSeriesWithComplexType.ttl index 9bb6897..ccc72e0 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithTimeSeriesWithComplexType.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithUnusedExtendingEntity.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithUnusedExtendingEntity.ttl similarity index 91% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithUnusedExtendingEntity.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0/AspectWithUnusedExtendingEntity.ttl index 491fd85..811c752 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0/AspectWithUnusedExtendingEntity.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.entity/2.1.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/resources/org.eclipse.esmf.test.event/2.0.0/aspect_with_event.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_event.ttl similarity index 78% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.0.0/aspect_with_event.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_event.ttl index 34153f9..009858d 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.0.0/aspect_with_event.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.1.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/resources/org.eclipse.esmf.test.event/2.0.0/aspect_with_event_with_parameters.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_event_with_parameters.ttl similarity index 80% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.0.0/aspect_with_event_with_parameters.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_event_with_parameters.ttl index 6d947d1..c972606 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.0.0/aspect_with_event_with_parameters.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.1.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/resources/org.eclipse.esmf.test.event/2.0.0/aspect_with_multiple_event.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_multiple_event.ttl similarity index 85% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.0.0/aspect_with_multiple_event.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.1.0/aspect_with_multiple_event.ttl index b757d3b..2e38212 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.0.0/aspect_with_multiple_event.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.event/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/Aspect.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/Aspect.ttl similarity index 78% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/Aspect.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/Aspect.ttl index eb682eb..8f8dc30 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/Aspect.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl similarity index 83% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl index 33d3cdb..c9fe26a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithDuplicatePropertyWithPayloadName.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithDuplicatePropertyWithPayloadName.ttl similarity index 81% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithDuplicatePropertyWithPayloadName.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithDuplicatePropertyWithPayloadName.ttl index d09f3af..1ab1c68 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithDuplicatePropertyWithPayloadName.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithEither.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithEither.ttl similarity index 94% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithEither.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithEither.ttl index 1c10c53..234ccdc 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithEither.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithEither.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithExtendingPropertyWithPayloadName.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithExtendingPropertyWithPayloadName.ttl similarity index 83% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithExtendingPropertyWithPayloadName.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithExtendingPropertyWithPayloadName.ttl index 2f1fdb8..28aef6a 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithExtendingPropertyWithPayloadName.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithMultipleAttributes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithMultipleAttributes.ttl similarity index 81% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithMultipleAttributes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithMultipleAttributes.ttl index 9495c49..eef8a5b 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithMultipleAttributes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithOperation.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperation.ttl similarity index 95% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithOperation.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperation.ttl index c68b293..b6307ed 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithOperation.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperation.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithOperationNoOutput.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperationNoOutput.ttl similarity index 76% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithOperationNoOutput.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperationNoOutput.ttl index 7ab39c5..eba02f1 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithOperationNoOutput.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOperationNoOutput.ttl @@ -9,22 +9,22 @@ # # 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 (); - samm:operations (:testOperation :testOperationTwo); + samm:operations (:testOperationThree :testOperationFour); samm:events (). -:testOperation a samm:Operation; +:testOperationThree a samm:Operation; samm:preferredName "Test Operation"@en; samm:description "Test Operation description"@en; samm:see , ; samm:input (:input). -:testOperationTwo a samm:Operation; +:testOperationFour a samm:Operation; samm:preferredName "Test Operation2"@en; samm:description "Test Operation2 description"@en; samm:see , ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithOptionalPropertyWithPayloadName.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOptionalPropertyWithPayloadName.ttl similarity index 95% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithOptionalPropertyWithPayloadName.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOptionalPropertyWithPayloadName.ttl index d290a4d..8b5472b 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithOptionalPropertyWithPayloadName.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithOptionalPropertyWithPayloadName.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithProperties.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithProperties.ttl similarity index 84% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithProperties.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithProperties.ttl index 071f95b..2d1dc93 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithProperties.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithProperty.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithProperty.ttl similarity index 84% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithProperty.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithProperty.ttl index ee7716e..5eaddfe 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithProperty.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithPropertyMultipleReferences.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyMultipleReferences.ttl similarity index 83% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithPropertyMultipleReferences.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyMultipleReferences.ttl index 31d9562..c375212 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithPropertyMultipleReferences.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithPropertyWithAllBaseAttributes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithAllBaseAttributes.ttl similarity index 94% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithPropertyWithAllBaseAttributes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithAllBaseAttributes.ttl index 39e3274..1c526a2 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithPropertyWithAllBaseAttributes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithAllBaseAttributes.ttl @@ -9,7 +9,7 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix : . +@prefix : . @prefix samm: . @prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithPropertyWithPayloadName.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithPayloadName.ttl similarity index 80% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithPropertyWithPayloadName.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/AspectWithPropertyWithPayloadName.ttl index b4da956..ebf7d89 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/AspectWithPropertyWithPayloadName.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/Movement.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/Movement.ttl similarity index 82% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/Movement.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/Movement.ttl index 4b39e86..4eadc1d 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/Movement.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/ProductType_shared.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/ProductType_shared.ttl similarity index 85% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/ProductType_shared.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/ProductType_shared.ttl index 18a63b9..64a8da3 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/ProductType_shared.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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/resources/org.eclipse.esmf.test.general/2.0.0/ProductTypes.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/ProductTypes.ttl similarity index 82% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/ProductTypes.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.0/ProductTypes.ttl index 647e941..1c8b170 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.0.0/ProductTypes.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general/2.1.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,5 @@ 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/resources/org.eclipse.esmf.test.general_with_references/2.0.0/AspectWithReferences.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.1.0/AspectWithReferences.ttl similarity index 82% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.0.0/AspectWithReferences.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.1.0/AspectWithReferences.ttl index d9a138d..f4598ea 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.0.0/AspectWithReferences.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.1.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/resources/org.eclipse.esmf.test.general_with_references/2.0.0/Part_shared.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.1.0/Part_shared.ttl similarity index 90% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.0.0/Part_shared.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.1.0/Part_shared.ttl index 5060d60..2806c60 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.0.0/Part_shared.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.1.0/Part_shared.ttl @@ -2,9 +2,9 @@ # Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved. # -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . :ExternalPartId a samm:Property ; diff --git a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.types/2.0.0/type_shared.ttl b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.types/2.1.0/type_shared.ttl similarity index 75% rename from core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.types/2.0.0/type_shared.ttl rename to core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.types/2.1.0/type_shared.ttl index 9899b11..4738600 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.types/2.0.0/type_shared.ttl +++ b/core/esmf-aspect-meta-model-python/tests/integration/resources/org.eclipse.esmf.test.types/2.1.0/type_shared.ttl @@ -2,9 +2,9 @@ # Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved. # -@prefix : . -@prefix samm: . -@prefix samm-c: . +@prefix : . +@prefix samm: . +@prefix samm-c: . @prefix xsd: . diff --git a/core/esmf-aspect-meta-model-python/tests/integration/test_aspect_functionality.py b/core/esmf-aspect-meta-model-python/tests/integration/test_aspect_functionality.py index 8e33b3b..ef2f5ed 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/test_aspect_functionality.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/test_aspect_functionality.py @@ -12,17 +12,21 @@ from os import getcwd from pathlib import Path -from esmf_aspect_meta_model_python import AspectLoader, BaseImpl +from esmf_aspect_meta_model_python import BaseImpl +from esmf_aspect_meta_model_python.loader.aspect_loader import AspectLoader +from esmf_aspect_meta_model_python.resolver.handler import InputHandler -RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.general/2.0.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.general/2.1.0") def test_get_access_path(): file_path = RESOURCE_PATH / "Movement.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] - graph = aspect_loader.get_graph() + graph = loader.graph path = graph.determine_element_access_path(aspect.properties[2].data_type.properties[2]) # type: ignore assert path[0][0] == "position" @@ -41,10 +45,12 @@ def test_get_access_path(): def test_get_access_path_input_property(): file_path = RESOURCE_PATH / "AspectWithOperationNoOutput.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] - graph = aspect_loader.get_graph() + graph = loader.graph path = graph.determine_element_access_path(aspect.operations[0].input_properties[0]) assert path[0][0] == "input" @@ -56,16 +62,18 @@ def test_get_access_path_input_property(): def test_find_properties_by_name() -> None: file_path = RESOURCE_PATH / "AspectWithProperties.ttl" - aspect_loader = AspectLoader() - aspect_loader.load_aspect_model(file_path) - graph = aspect_loader.get_graph() + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + _ = loader.load_aspect_model(rdf_graph, aspect_urn) + graph = loader.graph result = graph.find_by_name("testPropertyOne") assert result is not 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.0.0#testPropertyOne" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -75,7 +83,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.0.0#testPropertyTwo" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -86,16 +94,18 @@ def test_find_properties_by_name() -> None: def test_find_property_chaticaristic_by_name() -> None: file_path = RESOURCE_PATH / "AspectWithPropertyWithAllBaseAttributes.ttl" - aspect_loader = AspectLoader() - aspect_loader.load_aspect_model(file_path) - graph = aspect_loader.get_graph() + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + _ = loader.load_aspect_model(rdf_graph, aspect_urn) + graph = loader.graph result = graph.find_by_name("BooleanTestCharacteristic") assert result is not 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.0.0#BooleanTestCharacteristic" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#BooleanTestCharacteristic" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -103,24 +113,26 @@ def test_find_property_chaticaristic_by_name() -> None: def test_find_properties_by_urn() -> None: file_path = RESOURCE_PATH / "AspectWithProperties.ttl" - aspect_loader = AspectLoader() - aspect_loader.load_aspect_model(file_path) - graph = aspect_loader.get_graph() - element = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.0.0#testPropertyOne") + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + _ = loader.load_aspect_model(rdf_graph, aspect_urn) + graph = loader.graph + element = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.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.0.0#testPropertyOne" + assert element.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne" assert len(element.preferred_names) == 0 assert len(element.see) == 0 assert len(element.descriptions) == 0 - element = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.0.0#testPropertyTwo") + element = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.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.0.0#testPropertyTwo" + assert element.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo" assert len(element.preferred_names) == 0 assert len(element.see) == 0 assert len(element.descriptions) == 0 @@ -131,15 +143,17 @@ def test_find_properties_by_urn() -> None: def test_find_property_chaticaristic_by_urn() -> None: file_path = RESOURCE_PATH / "AspectWithPropertyWithAllBaseAttributes.ttl" - aspect_loader = AspectLoader() - aspect_loader.load_aspect_model(file_path) - graph = aspect_loader.get_graph() - element = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.0.0#BooleanTestCharacteristic") + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + _ = loader.load_aspect_model(rdf_graph, aspect_urn) + graph = loader.graph + element = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.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.0.0#BooleanTestCharacteristic" + assert element.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.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/test_characteristics.py b/core/esmf-aspect-meta-model-python/tests/integration/test_characteristics.py index bad8471..3ce0240 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/test_characteristics.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/test_characteristics.py @@ -15,23 +15,26 @@ import rdflib from esmf_aspect_meta_model_python import ( - AspectLoader, Collection, Duration, Enumeration, Measurement, Quantifiable, State, - StructuredValue + StructuredValue, ) +from esmf_aspect_meta_model_python.loader.aspect_loader import AspectLoader +from esmf_aspect_meta_model_python.resolver.handler import InputHandler -RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.characteristics/2.0.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.characteristics/2.1.0") def test_loading_aspect_with_collection(): file_path = RESOURCE_PATH / "AspectWithCollection.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert aspect.name == "AspectWithCollection" @@ -45,7 +48,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.0.0#testProperty" + assert aspect_property.urn == "urn:samm:org.eclipse.esmf.test.characteristics:2.1.0#testProperty" assert aspect_property.example_value == rdflib.Literal("Example Value") characteristic = aspect_property.characteristic @@ -62,26 +65,34 @@ def test_loading_aspect_with_collection(): def test_loading_aspect_with_set(): file_path = RESOURCE_PATH / "AspectWithSet.ttl" - aspect_loader = AspectLoader() - aspect = aspect_loader.load_aspect_model(file_path) # noqa: F841 + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + aspect = loader.load_aspect_model(rdf_graph, aspect_urn) # noqa: F841 def test_loading_aspect_with_sorted_set(): file_path = RESOURCE_PATH / "AspectWithSortedSet.ttl" - aspect_loader = AspectLoader() - aspect = aspect_loader.load_aspect_model(file_path) # noqa: F841 + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + aspect = loader.load_aspect_model(rdf_graph, aspect_urn) # noqa: F841 def test_loading_aspect_with_list(): file_path = RESOURCE_PATH / "AspectWithList.ttl" - aspect_loader = AspectLoader() - aspect = aspect_loader.load_aspect_model(file_path) # noqa: F841 + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + aspect = loader.load_aspect_model(rdf_graph, aspect_urn) # noqa: F841 def test_loading_aspect_with_collection_with_element_characteristic(): file_path = RESOURCE_PATH / "AspectWithCollectionWithElementCharacteristic.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -95,14 +106,16 @@ def test_loading_aspect_with_collection_with_element_characteristic(): assert element_characteristic.urn == "urn:samm:org.eclipse.esmf.samm:characteristic:2.1.0#Text" assert element_characteristic.parent_elements[0].urn == ( - "urn:samm:org.eclipse.esmf.test.characteristics:2.0.0#TestCollection" + "urn:samm:org.eclipse.esmf.test.characteristics:2.1.0#TestCollection" ) def test_loading_aspect_with_simple_enum(): file_path = RESOURCE_PATH / "AspectWithSimpleEnum.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -120,8 +133,10 @@ def test_loading_aspect_with_simple_enum(): def test_loading_aspect_with_simple_state(): print(RESOURCE_PATH) file_path = RESOURCE_PATH / "AspectWithState.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -140,8 +155,10 @@ def test_loading_aspect_with_simple_state(): def test_loading_aspect_with_quantifiable(): file_path = RESOURCE_PATH / "AspectWithQuantifiableAndUnit.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -159,13 +176,15 @@ 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.0.0#TestQuantifiable" + assert unit.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.characteristics:2.1.0#TestQuantifiable" def test_loading_aspect_with_duration(): file_path = RESOURCE_PATH / "AspectWithDuration.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -178,8 +197,10 @@ def test_loading_aspect_with_duration(): def test_loading_aspect_with_measurement(): file_path = RESOURCE_PATH / "AspectWithMeasurement.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -192,8 +213,10 @@ def test_loading_aspect_with_measurement(): def test_loading_aspect_with_structured_value(): file_path = RESOURCE_PATH / "AspectWithStructuredValue.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -219,8 +242,10 @@ def test_loading_aspect_with_structured_value(): def test_loading_aspect_with_code(): file_path = RESOURCE_PATH / "AspectWithCode.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -231,8 +256,10 @@ def test_loading_aspect_with_code(): def test_loading_aspect_with_blank_node() -> None: file_path = RESOURCE_PATH / "AspectWithBlankNode.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] diff --git a/core/esmf-aspect-meta-model-python/tests/integration/test_constraints.py b/core/esmf-aspect-meta-model-python/tests/integration/test_constraints.py index 2413edc..6456aa4 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/test_constraints.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/test_constraints.py @@ -26,14 +26,17 @@ RegularExpressionConstraint, Trait, ) +from esmf_aspect_meta_model_python.resolver.handler import InputHandler -RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.constraints/2.0.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.constraints/2.1.0") def test_loading_aspect_with_constrained_collection(): file_path = RESOURCE_PATH / "AspectWithConstrainedCollection.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -56,8 +59,10 @@ def test_loading_aspect_with_constrained_collection(): def test_loading_aspect_with_range_constraint(): file_path = RESOURCE_PATH / "AspectWithRangeConstraint.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -81,8 +86,10 @@ def test_loading_aspect_with_range_constraint(): def test_loading_aspect_with_multiple_constraints(): file_path = RESOURCE_PATH / "AspectWithMultipleConstraints.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -109,8 +116,10 @@ def test_loading_aspect_with_multiple_constraints(): def test_loading_aspect_with_multiple_one_value_constraints(): file_path = RESOURCE_PATH / "AspectWithMultipleOneValueConstraints.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -144,8 +153,10 @@ def test_loading_aspect_with_multiple_one_value_constraints(): def test_loading_aspect_with_range_constraint_incl_bound_definition(): file_path = RESOURCE_PATH / "AspectWithRangeConstraintInclBoundDefinitionProperties.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -170,8 +181,10 @@ def test_loading_aspect_with_range_constraint_incl_bound_definition(): def test_loading_aspect_with_language_constraint(): file_path = RESOURCE_PATH / "AspectWithLanguageConstraint.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -187,8 +200,10 @@ def test_loading_aspect_with_language_constraint(): def test_loading_aspect_with_locale_constraint(): file_path = RESOURCE_PATH / "AspectWithLocaleConstraint.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -204,8 +219,10 @@ def test_loading_aspect_with_locale_constraint(): def test_loading_aspect_with_fixed_point_constraint(): file_path = RESOURCE_PATH / "AspectWithFixedPoint.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -224,8 +241,10 @@ def test_loading_aspect_with_fixed_point_constraint(): def test_loading_aspect_with_encoding_constraint(): file_path = RESOURCE_PATH / "AspectWithEncodingConstraint.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -240,8 +259,10 @@ def test_loading_aspect_with_encoding_constraint(): def test_loading_aspect_with_regular_expression_constraint(): file_path = RESOURCE_PATH / "AspectWithRegularExpressionConstraint.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -255,8 +276,10 @@ def test_loading_aspect_with_regular_expression_constraint(): def test_loading_aspect_with_length_constraint(): file_path = RESOURCE_PATH / "AspectWithLengthConstraint.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] diff --git a/core/esmf-aspect-meta-model-python/tests/integration/test_entities.py b/core/esmf-aspect-meta-model-python/tests/integration/test_entities.py index 24ae970..42c7b62 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/test_entities.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/test_entities.py @@ -12,15 +12,19 @@ from os import getcwd from pathlib import Path -from esmf_aspect_meta_model_python import AbstractEntity, AspectLoader, ComplexType, Enumeration, Quantifiable +from esmf_aspect_meta_model_python import AbstractEntity, ComplexType, Enumeration, Quantifiable +from esmf_aspect_meta_model_python.loader.aspect_loader import AspectLoader +from esmf_aspect_meta_model_python.resolver.handler import InputHandler -RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.entity/2.0.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.entity/2.1.0") def test_loading_aspect_with_entity_enum(): file_path = RESOURCE_PATH / "AspectWithEntityEnum.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] properties = aspect.properties @@ -57,8 +61,10 @@ def test_loading_aspect_with_entity_enum(): def test_loading_aspect_with_entity(): file_path = RESOURCE_PATH / "AspectWithEntity.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] property = aspect.properties[0] @@ -80,8 +86,10 @@ def test_loading_aspect_with_entity(): def test_aspect_with_abstract_entity(): file_path = RESOURCE_PATH / "AspectWithAbstractEntity.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] aspect_properties = aspect.properties @@ -101,7 +109,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.0.0#Text" + assert entity_property_characteristic.urn == "urn:samm:org.eclipse.esmf.samm:characteristic:2.1.0#Text" abstract_entity = entity.extends assert abstract_entity is not None @@ -110,8 +118,10 @@ def test_aspect_with_abstract_entity(): def test_aspect_with_multiple_entities_same_extend(): file_path = RESOURCE_PATH / "AspectWithMultipleEntitiesSameExtend.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] properties = aspect.properties @@ -141,8 +151,10 @@ def test_aspect_with_unused_extending_entity() -> None: but extends an abstract entity that is connected to an aspect. """ file_path = RESOURCE_PATH / "AspectWithUnusedExtendingEntity.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] properties = aspect.properties @@ -173,8 +185,10 @@ def test_aspect_with_unused_extending_entity() -> None: def test_aspect_with_abstract_coordinate_properties_list() -> None: file_path = RESOURCE_PATH / "AspectWithPoint3d.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] properties = aspect.properties @@ -193,14 +207,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.0.0#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].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.0.0#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].characteristic is not None assert float_3d_coordinate_properties[1].characteristic.name == "FloatValue" @@ -210,8 +224,10 @@ def test_attribute_inheritance_entity() -> None: for extending entities. """ file_path = RESOURCE_PATH / "AspectWithAbstractEntityMultipleAttributes.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] properties = aspect.properties @@ -248,8 +264,10 @@ def test_multiple_attribute_inheritance_entity() -> None: for multiple extending entities. """ file_path = RESOURCE_PATH / "AspectWithMultipleAbstractEntitiesMultipleAttributes.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] properties = aspect.properties @@ -287,8 +305,10 @@ def test_multiple_attribute_inheritance_entity() -> None: def test_attribute_inheritance_property() -> None: file_path = RESOURCE_PATH / "AspectWithAbstractPropertyMultipleAttributes.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] properties = aspect.properties @@ -316,8 +336,10 @@ def test_attribute_inheritance_property() -> None: def test_multiple_properties_same_extend() -> None: file_path = RESOURCE_PATH / "AspectWithMultiplePropertiesSameExtend.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert len(aspect.properties) == 2 @@ -351,8 +373,10 @@ def test_multiple_properties_same_extend() -> None: def test_abstract_property_blank_node() -> None: file_path = RESOURCE_PATH / "AspectWithAbstractPropertyBlankNode.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert len(aspect.properties) == 1 @@ -385,8 +409,10 @@ def test_abstract_property_blank_node() -> None: def test_abstract_property_multiple_abstract_entities() -> None: file_path = RESOURCE_PATH / "AspectWithAbstractPropertyMultipleAbstractEntities.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert len(aspect.properties) == 1 @@ -426,8 +452,10 @@ def test_abstract_property_multiple_abstract_entities() -> None: def test_aspect_with_time_series(): file_path = RESOURCE_PATH / "AspectWithTimeSeries.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] property1 = aspect.properties[0] @@ -440,7 +468,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.0.0#TestTimeSeriesEntity" + assert time_series_entity.urn == "urn:samm:org.eclipse.esmf.test.entity:2.1.0#TestTimeSeriesEntity" assert len(time_series_entity.properties) == 1 assert len(time_series_entity.all_properties) == 3 @@ -473,8 +501,10 @@ def test_aspect_with_time_series(): def test_aspect_with_time_series_with_complex_type() -> None: file_path = RESOURCE_PATH / "AspectWithTimeSeriesWithComplexType.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] property1 = aspect.properties[0] @@ -487,7 +517,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.0.0#TestTimeSeriesEntity" + assert data_type.urn == "urn:samm:org.eclipse.esmf.test.entity:2.1.0#TestTimeSeriesEntity" assert len(data_type.properties) == 1 assert len(data_type.all_properties) == 3 @@ -511,8 +541,10 @@ def test_aspect_with_time_series_with_complex_type() -> None: def test_aspect_with_file_resource_entity() -> None: file_path = RESOURCE_PATH / "AspectWithFileResourceEntity.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] characteristic = aspect.properties[0].characteristic @@ -520,7 +552,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.0.0#FileResource" + assert fileResource.urn == "urn:samm:org.eclipse.esmf.samm:entity:2.1.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" @@ -545,8 +577,10 @@ def test_aspect_with_file_resource_entity() -> None: def test_aspect_with_entity_extending_file_resource() -> None: file_path = RESOURCE_PATH / "AspectWithEntityExtendingFileResource.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] characteristic = aspect.properties[0].characteristic @@ -554,12 +588,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.0.0#AdvancedFileResource" + assert advancedFileResource.urn == "urn:samm:org.eclipse.esmf.test.entity:2.1.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.0.0#FileResource" + assert fileResource.urn == "urn:samm:org.eclipse.esmf.samm:entity:2.1.0#FileResource" assert fileResource.name == "FileResource" diff --git a/core/esmf-aspect-meta-model-python/tests/integration/test_event.py b/core/esmf-aspect-meta-model-python/tests/integration/test_event.py index 6735c7c..a0e26a5 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/test_event.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/test_event.py @@ -12,15 +12,19 @@ from os import getcwd from pathlib import Path -from esmf_aspect_meta_model_python import AspectLoader, Event +from esmf_aspect_meta_model_python import Event +from esmf_aspect_meta_model_python.loader.aspect_loader import AspectLoader +from esmf_aspect_meta_model_python.resolver.handler import InputHandler -RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.event/2.0.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.event/2.1.0") def test_loading_aspect_with_event() -> None: file_path = RESOURCE_PATH / "aspect_with_event.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert aspect.events is not None @@ -32,8 +36,10 @@ def test_loading_aspect_with_event() -> None: def test_loading_aspect_with_event_with_parameters() -> None: file_path = RESOURCE_PATH / "aspect_with_event_with_parameters.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert aspect.events is not None @@ -48,8 +54,10 @@ def test_loading_aspect_with_event_with_parameters() -> None: def test_loading_aspect_with_multiple_event() -> None: file_path = RESOURCE_PATH / "aspect_with_multiple_event.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert aspect.events is not None diff --git a/core/esmf-aspect-meta-model-python/tests/integration/test_general.py b/core/esmf-aspect-meta-model-python/tests/integration/test_general.py index 35a052a..921cb94 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/test_general.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/test_general.py @@ -12,15 +12,19 @@ from os import getcwd from pathlib import Path -from esmf_aspect_meta_model_python import AspectLoader, BaseImpl, ComplexType, Either +from esmf_aspect_meta_model_python import BaseImpl, ComplexType, Either +from esmf_aspect_meta_model_python.loader.aspect_loader import AspectLoader +from esmf_aspect_meta_model_python.resolver.handler import InputHandler -RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.general/2.0.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.general/2.1.0") def test_aspect_with_multiple_attributes(): file_path = RESOURCE_PATH / "AspectWithMultipleAttributes.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert aspect.get_preferred_name("en") == "Test Aspect" @@ -35,18 +39,20 @@ def test_aspect_with_multiple_attributes(): def test_aspect(): file_path = RESOURCE_PATH / "AspectWithProperties.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] - assert aspect.meta_model_version == "2.0.0" + assert aspect.meta_model_version == "2.1.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.0.0#TestAspect" + assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#TestAspect" assert len(aspect.properties) == 2 assert aspect.is_collection_aspect is False @@ -63,8 +69,8 @@ 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.0.0#testPropertyOne" - assert characteristic.parent_elements[1].urn == "urn:samm:org.eclipse.esmf.test.general:2.0.0#testPropertyTwo" + assert characteristic.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne" + assert characteristic.parent_elements[1].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo" data_type = characteristic.data_type assert data_type.is_scalar is True @@ -74,13 +80,15 @@ def test_aspect(): def test_aspect_with_operation(): file_path = RESOURCE_PATH / "AspectWithOperation.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert aspect.meta_model_version == "2.1.0" assert aspect.name == "AspectWithOperation" - assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.0.0#AspectWithOperation" + assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#AspectWithOperation" properties = aspect.properties assert len(properties) == 0 @@ -135,13 +143,15 @@ def test_aspect_with_operation(): def test_aspect_with_operation_no_output(): file_path = RESOURCE_PATH / "AspectWithOperationNoOutput.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] - assert aspect.meta_model_version == "2.0.0" + assert aspect.meta_model_version == "2.1.0" assert aspect.name == "AspectWithOperationNoOutput" - assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.0.0#AspectWithOperationNoOutput" + assert aspect.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#AspectWithOperationNoOutput" properties = aspect.properties assert len(properties) == 0 @@ -150,7 +160,7 @@ def test_aspect_with_operation_no_output(): assert len(operations) == 2 operation1 = operations[0] - assert operation1.name == "testOperation" + assert operation1.name == "testOperationThree" preferred_names = operation1.preferred_names assert len(preferred_names) == 1 assert operation1.get_preferred_name("en") == "Test Operation" @@ -169,7 +179,7 @@ def test_aspect_with_operation_no_output(): assert operation1_output_properties is None operation2 = operations[1] - assert operation2.name == "testOperationTwo" + assert operation2.name == "testOperationFour" preferred_names = operation2.preferred_names assert len(preferred_names) == 1 assert operation2.get_preferred_name("en") == "Test Operation2" @@ -190,8 +200,10 @@ def test_aspect_with_operation_no_output(): def test_aspect_with_property_multiple_references() -> None: file_path = RESOURCE_PATH / "AspectWithPropertyMultipleReferences.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] property1 = aspect.properties[0] property2 = aspect.properties[1] @@ -210,8 +222,10 @@ def test_aspect_with_property_multiple_references() -> None: def test_aspect_with_property_with_payload_name() -> None: file_path = RESOURCE_PATH / "AspectWithPropertyWithPayloadName.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] property1 = aspect.properties[0] @@ -222,8 +236,10 @@ def test_aspect_with_property_with_payload_name() -> None: def test_aspect_with_optional_property_with_payload_name() -> None: file_path = RESOURCE_PATH / "AspectWithOptionalPropertyWithPayloadName.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] property1 = aspect.properties[0] @@ -234,8 +250,10 @@ def test_aspect_with_optional_property_with_payload_name() -> None: def test_aspect_with_duplicate_property_with_payload_name() -> None: file_path = RESOURCE_PATH / "AspectWithDuplicatePropertyWithPayloadName.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] property1 = aspect.properties[0] @@ -248,8 +266,10 @@ def test_aspect_with_duplicate_property_with_payload_name() -> None: def test_aspect_with_duplicate_property_with_different_payload_names() -> None: file_path = RESOURCE_PATH / "AspectWithDuplicatePropertyWithDifferentPayloadNames.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] property1 = aspect.properties[0] @@ -262,8 +282,10 @@ def test_aspect_with_duplicate_property_with_different_payload_names() -> None: def test_aspect_with_extending_property_with_payload_name() -> None: file_path = RESOURCE_PATH / "AspectWithExtendingPropertyWithPayloadName.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert aspect.properties[0].characteristic is not None @@ -280,16 +302,18 @@ def test_aspect_with_extending_property_with_payload_name() -> None: def test_find_properties_by_name() -> None: file_path = RESOURCE_PATH / "AspectWithProperties.ttl" - aspect_loader = AspectLoader() - aspect_loader.load_aspect_model(file_path) - graph = aspect_loader.get_graph() + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + _ = loader.load_aspect_model(rdf_graph, aspect_urn) + graph = loader.graph result = graph.find_by_name("testPropertyOne") assert result is not 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.0.0#testPropertyOne" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -299,7 +323,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.0.0#testPropertyTwo" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -310,16 +334,18 @@ def test_find_properties_by_name() -> None: def test_find_property_characteristic_by_name() -> None: file_path = RESOURCE_PATH / "AspectWithPropertyWithAllBaseAttributes.ttl" - aspect_loader = AspectLoader() - aspect_loader.load_aspect_model(file_path) - graph = aspect_loader.get_graph() + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + _ = loader.load_aspect_model(rdf_graph, aspect_urn) + graph = loader.graph result = graph.find_by_name("BooleanTestCharacteristic") assert result is not 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.0.0#BooleanTestCharacteristic" + assert result[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#BooleanTestCharacteristic" assert len(result[0].preferred_names) == 0 assert len(result[0].see) == 0 assert len(result[0].descriptions) == 0 @@ -327,24 +353,26 @@ def test_find_property_characteristic_by_name() -> None: def test_find_properties_by_urn() -> None: file_path = RESOURCE_PATH / "AspectWithProperties.ttl" - aspect_loader = AspectLoader() - aspect_loader.load_aspect_model(file_path) - graph = aspect_loader.get_graph() + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + _ = loader.load_aspect_model(rdf_graph, aspect_urn) + graph = loader.graph - result = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.0.0#testPropertyOne") + result = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.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.0.0#testPropertyOne" + assert result.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyOne" assert len(result.preferred_names) == 0 assert len(result.see) == 0 assert len(result.descriptions) == 0 - result = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.0.0#testPropertyTwo") + result = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.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.0.0#testPropertyTwo" + assert result.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#testPropertyTwo" assert len(result.preferred_names) == 0 assert len(result.see) == 0 assert len(result.descriptions) == 0 @@ -355,15 +383,17 @@ def test_find_properties_by_urn() -> None: def test_find_property_characteristic_by_urn() -> None: file_path = RESOURCE_PATH / "AspectWithPropertyWithAllBaseAttributes.ttl" - aspect_loader = AspectLoader() - aspect_loader.load_aspect_model(file_path) - graph = aspect_loader.get_graph() - result = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.0.0#BooleanTestCharacteristic") + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + _ = loader.load_aspect_model(rdf_graph, aspect_urn) + graph = loader.graph + result = graph.find_by_urn("urn:samm:org.eclipse.esmf.test.general:2.1.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.0.0#BooleanTestCharacteristic" + assert result.urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#BooleanTestCharacteristic" assert len(result.preferred_names) == 0 assert len(result.see) == 0 assert len(result.descriptions) == 0 @@ -374,8 +404,10 @@ def test_find_property_characteristic_by_urn() -> None: def test_loading_aspect_with_either(): file_path = RESOURCE_PATH / "AspectWithEither.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] first_property = aspect.properties[0] @@ -385,8 +417,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.0.0#TestEither" + assert left.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#TestEither" right = either_characteristic.right assert right.name == "Boolean" - assert right.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.0.0#TestEither" + assert right.parent_elements[0].urn == "urn:samm:org.eclipse.esmf.test.general:2.1.0#TestEither" diff --git a/core/esmf-aspect-meta-model-python/tests/integration/test_resolve_elements_referencies.py b/core/esmf-aspect-meta-model-python/tests/integration/test_resolve_elements_referencies.py index 99b5121..4520f5c 100644 --- a/core/esmf-aspect-meta-model-python/tests/integration/test_resolve_elements_referencies.py +++ b/core/esmf-aspect-meta-model-python/tests/integration/test_resolve_elements_referencies.py @@ -12,15 +12,18 @@ from os import getcwd from pathlib import Path -from esmf_aspect_meta_model_python import AspectLoader +from esmf_aspect_meta_model_python.loader.aspect_loader import AspectLoader +from esmf_aspect_meta_model_python.resolver.handler import InputHandler -RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.0.0") +RESOURCE_PATH = getcwd() / Path("tests/integration/resources/org.eclipse.esmf.test.general_with_references/2.1.0") def test_resolve_elements_references(): file_path = RESOURCE_PATH / "AspectWithReferences.ttl" - aspect_loader = AspectLoader() - model_elements = aspect_loader.load_aspect_model(file_path) + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() + loader = AspectLoader() + model_elements = loader.load_aspect_model(rdf_graph, aspect_urn) aspect = model_elements[0] assert aspect.name == "test_aspect" diff --git a/core/esmf-aspect-meta-model-python/tests/unit/loader/test_aspect_loader.py b/core/esmf-aspect-meta-model-python/tests/unit/loader/test_aspect_loader.py index c7091d7..f2bf74e 100644 --- a/core/esmf-aspect-meta-model-python/tests/unit/loader/test_aspect_loader.py +++ b/core/esmf-aspect-meta-model-python/tests/unit/loader/test_aspect_loader.py @@ -6,89 +6,14 @@ class TestAspectLoader: - """Aspect model Loader test suite.""" - - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.SAMMGraph") - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.DefaultElementCache") - def test_init(self, default_element_cache_mock, samm_graph_mock): - default_element_cache_mock.return_value = "cache" - samm_graph_mock.return_value = "graph" - result = AspectLoader() - - assert result._cache == "cache" - assert result._graph == "graph" - - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.SAMMGraph") - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.DefaultElementCache") - def test_init_with_defaults(self, default_element_cache_mock, samm_graph_mock): - default_element_cache_mock.return_value = "cache" - samm_graph_mock.return_value = "graph" - result = AspectLoader() - - assert result._cache == "cache" - assert result._graph == "graph" - default_element_cache_mock.assert_called_once() - samm_graph_mock.assert_called_once_with() - - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.SAMMGraph") - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.DefaultElementCache") - def test_get_graph(self, default_element_cache_mock, samm_graph_mock): - default_element_cache_mock.return_value = "cache" - samm_graph_mock.return_value = "graph" - loader = AspectLoader() - result = loader.get_graph() - - assert result == "graph" - - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.SAMMGraph") - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.DefaultElementCache") - def test_get_samm_version(self, default_element_cache_mock, samm_graph_mock): - default_element_cache_mock.return_value = "cache" - graph_mock = mock.MagicMock(name="graph") - graph_mock.get_samm_version.return_value = "samm_version" - samm_graph_mock.return_value = graph_mock - loader = AspectLoader() - result = loader.get_samm_version() - - assert result == "samm_version" - graph_mock.get_samm_version.assert_called_once() - - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.Path") - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.isinstance") - def test_prepare_file_path(self, isinstance_mock, path_mock): - isinstance_mock.return_value = True - file_path_mock = mock.MagicMock(name="file_path") - file_path_mock.exists.return_value = True - path_mock.return_value = file_path_mock - result = AspectLoader.convert_file_path("file_path") - - assert result == "file_path" - isinstance_mock.assert_called_once_with("file_path", path_mock) - path_mock.assert_called_once_with("file_path") - file_path_mock.exists.assert_called_once() - - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.AspectLoader._reset_graph") - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.AspectLoader.convert_file_path") @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.SAMMGraph") - @mock.patch("esmf_aspect_meta_model_python.loader.aspect_loader.DefaultElementCache") - def test_load_aspect_model( - self, - default_element_cache_mock, - samm_graph_mock, - convert_file_path_mock, - reset_graph_mock, - ): - default_element_cache_mock.return_value = "cache" + def test_load_aspect_model(self, samm_graph_mock): graph_mock = mock.MagicMock(name="graph") - graph_mock.parse.return_value = "graph" - graph_mock.to_python.return_value = "loaded_aspect_model" + graph_mock.to_python.return_value = "python_aspect_nodes" samm_graph_mock.return_value = graph_mock - convert_file_path_mock.return_value = "converted_file_path" loader = AspectLoader() - result = loader.load_aspect_model("file_path") + result = loader.load_aspect_model("graph", "aspect_urn") - assert result == "loaded_aspect_model" - convert_file_path_mock.assert_called_once_with("file_path") - reset_graph_mock.assert_called_once() - graph_mock.parse.assert_called_once_with("converted_file_path") - graph_mock.to_python.assert_called_once() + assert result == "python_aspect_nodes" + samm_graph_mock.assert_called_once_with(graph="graph") + graph_mock.to_python.assert_called_once_with("aspect_urn") 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 41d1e37..8b3ed2a 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 @@ -1,32 +1,35 @@ """SAMM Graph test suite.""" -from pathlib import Path from unittest import mock import pytest +from rdflib import RDF + from esmf_aspect_meta_model_python.loader.samm_graph import SAMMGraph class TestSAMMGraph: """SAMM Graph test suite.""" - def test_init(self): - result = SAMMGraph("graph", "resolver", "cache") + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_init(self, populate_with_meta_data_mock): + result = SAMMGraph("graph", "cache") assert result._graph == "graph" - assert result._resolver == "resolver" assert result._cache == "cache" assert result._samm_version == "" - assert result._file_path == "" + populate_with_meta_data_mock.assert_called_once() - def test_get_rdf_graph(self): - samm_graph = SAMMGraph("graph", "resolver", "cache") + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_get_rdf_graph(self, _): + samm_graph = SAMMGraph("graph", "cache") result = samm_graph.get_rdf_graph() assert result == "graph" - def test_get_samm_version(self): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_get_samm_version_from_graph(self, _): graph_mock = mock.MagicMock(name="graph") namespace_manager_mock = mock.MagicMock(name="namespace_manager") namespace_manager_mock.namespaces.return_value = [ @@ -35,113 +38,87 @@ def test_get_samm_version(self): ("samm", "namespace:path:to:model:3.2.1#"), ] graph_mock.namespace_manager = namespace_manager_mock - samm_graph = SAMMGraph(graph_mock, "resolver", "cache") - result = samm_graph.get_samm_version() + samm_graph = SAMMGraph(graph_mock, "cache") + result = samm_graph._get_samm_version_from_graph() assert result == "3.2.1" - namespace_manager_mock.namespaces.assert_called_once() - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.isinstance") - def test_prepare_file_path(self, isinstance_mock): - isinstance_mock.return_value = True - file_path = Path("file_path") - result = SAMMGraph.convert_file_path(file_path) + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._get_samm_version_from_graph") + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_get_samm_version_raise_error(self, _, get_samm_version_from_graph_mock): + get_samm_version_from_graph_mock.return_value = "" + samm_graph = SAMMGraph("graph", "cache") + with pytest.raises(ValueError) as error: + samm_graph.get_samm_version() - assert result == "file_path" - isinstance_mock.assert_called_once_with(file_path, Path) + assert str(error.value) == "SAMM version not found in the Graph." + get_samm_version_from_graph_mock.assert_called_once() + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._get_samm_version_from_graph") + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_get_samm_version(self, _, get_samm_version_from_graph_mock): + get_samm_version_from_graph_mock.return_value = "1.2.3" + samm_graph = SAMMGraph("graph", "cache") + result = samm_graph.get_samm_version() + + assert result is None + assert samm_graph._samm_version == "1.2.3" + get_samm_version_from_graph_mock.assert_called_once() + + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.AspectMetaModelResolver") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.get_samm_version") - def test_parse(self, get_samm_version_mock): - graph_mock = mock.MagicMock(name="graph") - get_samm_version_mock.return_value = "samm_version" - resolver_mock = mock.MagicMock(name="resolver") - samm_graph = SAMMGraph(graph_mock, resolver_mock, "cache") - result = samm_graph.parse("file_path") - - assert result == graph_mock - assert samm_graph._file_path == "file_path" - graph_mock.parse.assert_called_once_with("file_path") - assert samm_graph._samm_version == "samm_version" - resolver_mock.resolve.assert_called_once_with(graph_mock, "file_path", "samm_version") - - def test_get_model_file_path(self): - samm_graph = SAMMGraph("graph", "resolver", "cache") - samm_graph._file_path = "file_path" - result = samm_graph._get_model_file_path() - - assert result == "file_path" - - def test_get_model_file_path_raise_exception(self): - samm_graph = SAMMGraph("graph", "resolver", "cache") - with pytest.raises(ValueError) as error: - samm_graph._get_model_file_path() + def test_populate_with_meta_data(self, get_samm_version_mock, aspect_meta_model_resolver_mock): + meta_model_reader_mock = mock.MagicMock(name="meta_model_reader") + aspect_meta_model_resolver_mock.return_value = meta_model_reader_mock + _ = SAMMGraph("graph", "cache") - assert str(error.value) == "Path to the model is empty" + get_samm_version_mock.assert_called_once() + aspect_meta_model_resolver_mock.assert_called_once() + meta_model_reader_mock.parse.assert_called_once_with("graph", "") - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.RDF.type") - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMM") - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.Graph") - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._get_model_file_path") - def test_get_nodes_from_graph_with_aspect(self, get_model_file_path_mock, rdf_graph_mock, samm_mock, rdf_type_mock): - get_model_file_path_mock.return_value = "model_file_path" - base_graph_mock = mock.MagicMock(name="base_graph") - base_graph_mock.subjects.return_value = ["aspect_node"] - rdf_graph_mock.return_value = rdf_graph_mock - rdf_graph_mock.parse.return_value = base_graph_mock - samm_mock.return_value = samm_mock - samm_mock.aspect = "aspect_node_name" - samm_mock.get_urn.return_value = "aspect_urn" - samm_graph = SAMMGraph("graph", "resolver", "cache") - samm_graph._samm_version = "samm_version" - result = samm_graph.get_nodes_from_graph() + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_prepare_graph(self, populate_with_meta_data_mock): + _ = SAMMGraph(cache="cache") - assert result == ["aspect_node"] - get_model_file_path_mock.assert_called_once_with("") - rdf_graph_mock.assert_called_once() - rdf_graph_mock.parse.assert_called_once_with("model_file_path", format="turtle") - samm_mock.assert_called_once_with("samm_version") - samm_mock.get_urn.assert_called_once_with("aspect_node_name") - base_graph_mock.subjects.assert_called_once_with(predicate=rdf_type_mock, object="aspect_urn") + populate_with_meta_data_mock.assert_called_once() - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.RDF.type") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMM") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.Graph") - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._get_model_file_path") - def test_get_nodes_from_graph_no_aspect(self, get_model_file_path_mock, rdf_graph_mock, samm_mock, rdf_type_mock): - get_model_file_path_mock.return_value = "model_file_path" - base_graph_mock = mock.MagicMock(name="base_graph") - base_graph_mock.subjects.return_value = [] - base_graph_mock.subject_objects.return_value = [ - ("base_node_name", ""), - ] + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_get_aspect_nodes_from_graph(self, _, rdf_graph_mock, samm_mock): rdf_graph_mock.return_value = rdf_graph_mock - rdf_graph_mock.parse.return_value = base_graph_mock + rdf_graph_mock.subjects.return_value = ["subject_1", "subject_2"] samm_mock.return_value = samm_mock - samm_mock.aspect = "aspect_node_name" + samm_mock.aspect = "aspect" samm_mock.get_urn.return_value = "aspect_urn" - samm_graph = SAMMGraph("graph", "resolver", "cache") - samm_graph._samm_version = "samm_version" - result = samm_graph.get_nodes_from_graph() + samm_graph = SAMMGraph(cache="cache") + samm_graph._samm_version = "1.2.3" + result = samm_graph.get_aspect_nodes_from_graph() - assert result == ["base_node_name"] - base_graph_mock.subject_objects.assert_called_once_with(predicate=rdf_type_mock, unique=True) + assert result == ["subject_1", "subject_2"] + samm_mock.assert_called_once_with("1.2.3") + samm_mock.get_urn.assert_called_once_with("aspect") + rdf_graph_mock.assert_called_once() + rdf_graph_mock.subjects.assert_called_once_with(predicate=RDF.type, object="aspect_urn") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.URIRef") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.isinstance") - def test_get_base_nodes_with_aspect_urn(self, isinstance_mock, uri_ref_mock): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_get_base_nodes_with_aspect_urn(self, _, isinstance_mock, uri_ref_mock): isinstance_mock.return_value = False uri_ref_mock.return_value = "aspect_uri_ref" - samm_graph = SAMMGraph("graph", "resolver", "cache") + samm_graph = SAMMGraph("graph", "cache") result = samm_graph.get_base_nodes("aspect_urn") assert result == ["aspect_uri_ref"] isinstance_mock.assert_called_once_with("aspect_urn", uri_ref_mock) uri_ref_mock.assert_called_once_with("aspect_urn") - @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.get_nodes_from_graph") - def test_get_base_nodes_no_aspect_urn(self, get_nodes_from_graph_mock): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.get_aspect_nodes_from_graph") + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_get_base_nodes_no_aspect_urn(self, _, get_nodes_from_graph_mock): get_nodes_from_graph_mock.return_value = ["base_node"] - samm_graph = SAMMGraph("graph", "resolver", "cache") + samm_graph = SAMMGraph("graph", "cache") result = samm_graph.get_base_nodes() assert result == ["base_node"] @@ -149,11 +126,12 @@ def test_get_base_nodes_no_aspect_urn(self, get_nodes_from_graph_mock): @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.ModelElementFactory") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.get_base_nodes") - def test_to_python(self, get_base_nodes_mock, model_element_factory_mock): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_to_python(self, _, get_base_nodes_mock, model_element_factory_mock): get_base_nodes_mock.return_value = "base_nodes" model_element_factory_mock.return_value = model_element_factory_mock model_element_factory_mock.create_all_graph_elements.return_value = ["aspect_elements"] - samm_graph = SAMMGraph("graph", "resolver", "cache") + samm_graph = SAMMGraph("graph", "cache") samm_graph._samm_version = "samm_version" result = samm_graph.to_python("aspect_urn") @@ -163,22 +141,24 @@ def test_to_python(self, get_base_nodes_mock, model_element_factory_mock): model_element_factory_mock.create_all_graph_elements.assert_called_once_with("base_nodes") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.DefaultElementCache") - def test_find_by_name(self, default_element_cache_mock): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_find_by_name(self, _, default_element_cache_mock): cache_mock = mock.MagicMock(name="cache") cache_mock.get_by_name.return_value = "graph_node" default_element_cache_mock.return_value = cache_mock - samm_graph = SAMMGraph("graph", "resolver") + samm_graph = SAMMGraph("graph") result = samm_graph.find_by_name("element_name") assert result == "graph_node" cache_mock.get_by_name.assert_called_once_with("element_name") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.DefaultElementCache") - def test_find_by_urn(self, default_element_cache_mock): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_find_by_urn(self, _, default_element_cache_mock): cache_mock = mock.MagicMock(name="cache") cache_mock.get_by_urn.return_value = "graph_node" default_element_cache_mock.return_value = cache_mock - samm_graph = SAMMGraph("graph", "resolver") + samm_graph = SAMMGraph("graph") result = samm_graph.find_by_urn("urn") assert result == "graph_node" @@ -186,14 +166,11 @@ def test_find_by_urn(self, default_element_cache_mock): @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.determine_element_access_path") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.find_by_name") - def test_determine_access_path( - self, - find_by_name_mock, - determine_element_access_path_mock, - ): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_determine_access_path(self, _, find_by_name_mock, determine_element_access_path_mock): find_by_name_mock.side_effect = (["base_element"], []) determine_element_access_path_mock.return_value = ["access_path"] - samm_graph = SAMMGraph("graph", "resolver", "cache") + samm_graph = SAMMGraph("graph", "cache") result = samm_graph.determine_access_path("base_element_name") assert result == ["access_path"] @@ -203,8 +180,10 @@ def test_determine_access_path( @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._SAMMGraph__determine_access_path") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.Property") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.isinstance") + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") def test_determine_element_access_path_with_payload_name( self, + _, isinstance_mock, property_mock, determine_access_path_mock, @@ -213,7 +192,7 @@ def test_determine_element_access_path_with_payload_name( base_element_mock = mock.MagicMock(name="base_element") base_element_mock.payload_name = "payload_name" determine_access_path_mock.return_value = "element_access_path" - samm_graph = SAMMGraph("graph", "resolver", "cache") + samm_graph = SAMMGraph("graph", "cache") result = samm_graph.determine_element_access_path(base_element_mock) assert result == "element_access_path" @@ -223,8 +202,10 @@ def test_determine_element_access_path_with_payload_name( @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph._SAMMGraph__determine_access_path") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.Property") @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.isinstance") + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") def test_determine_element_access_path_base_element_name( self, + _, isinstance_mock, property_mock, determine_access_path_mock, @@ -234,50 +215,55 @@ def test_determine_element_access_path_base_element_name( base_element_mock.name = "base_element_name" base_element_mock.payload_name = None determine_access_path_mock.return_value = "element_access_path" - samm_graph = SAMMGraph("graph", "resolver", "cache") + samm_graph = SAMMGraph("graph", "cache") result = samm_graph.determine_element_access_path(base_element_mock) assert result == "element_access_path" isinstance_mock.assert_called_once_with(base_element_mock, property_mock) determine_access_path_mock.assert_called_once_with(base_element_mock, [["base_element_name"]]) - def test_determine_access_path_base_element_is_none(self): - samm_graph = SAMMGraph("graph", "resolver", "cache") + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_determine_access_path_base_element_is_none(self, _): + samm_graph = SAMMGraph("graph", "cache") result = samm_graph._SAMMGraph__determine_access_path(None, "path") assert result == "path" - def test_determine_access_path_parent_element_is_none(self): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_determine_access_path_parent_element_is_none(self, _): base_element_mock = mock.MagicMock(name="base_element") base_element_mock.parent_elements = None - samm_graph = SAMMGraph("graph", "resolver", "cache") + samm_graph = SAMMGraph("graph", "cache") result = samm_graph._SAMMGraph__determine_access_path(base_element_mock, "path") assert result == "path" - def test_determine_access_path_parent_element_is_empty_list(self): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_determine_access_path_parent_element_is_empty_list(self, _): base_element_mock = mock.MagicMock(name="base_element") base_element_mock.parent_elements = [] - samm_graph = SAMMGraph("graph", "resolver", "cache") + samm_graph = SAMMGraph("graph", "cache") result = samm_graph._SAMMGraph__determine_access_path(base_element_mock, "path") assert result == "path" @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.isinstance") - def test_private_determine_access_path_parent_payload_name(self, isinstance_mock): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_private_determine_access_path_parent_payload_name(self, _, isinstance_mock): parent_element_mock = mock.MagicMock(name="parent_element") parent_element_mock.parent_elements = [] parent_element_mock.payload_name = "payload_name" base_element_mock = mock.MagicMock(name="base_element") base_element_mock.parent_elements = [parent_element_mock] isinstance_mock.return_value = True - samm_graph = SAMMGraph("graph", "resolver", "cache") + samm_graph = SAMMGraph("graph", "cache") result = samm_graph._SAMMGraph__determine_access_path(base_element_mock, [["path"]]) assert result == [["payload_name", "path"]] @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.isinstance") - def test_private_determine_access_path_parent_name(self, isinstance_mock): + @mock.patch("esmf_aspect_meta_model_python.loader.samm_graph.SAMMGraph.populate_with_meta_data") + def test_private_determine_access_path_parent_name(self, _, isinstance_mock): parent_element_mock = mock.MagicMock(name="parent_element") parent_element_mock.parent_elements = [] parent_element_mock.payload_name = None @@ -285,7 +271,7 @@ def test_private_determine_access_path_parent_name(self, isinstance_mock): base_element_mock = mock.MagicMock(name="base_element") base_element_mock.parent_elements = [parent_element_mock] isinstance_mock.return_value = True - samm_graph = SAMMGraph("graph", "resolver", "cache") + samm_graph = SAMMGraph("graph", "cache") result = samm_graph._SAMMGraph__determine_access_path(base_element_mock, [["path"]]) assert result == [["payload_element_name", "path"]] 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 72279be..1298061 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,55 +1,58 @@ -"""Aspect Model Resolver test suit.""" +"""Base resolver test suit.""" +from rdflib import Graph from unittest import mock -from esmf_aspect_meta_model_python.resolver.base import AspectModelResolver +import pytest +from esmf_aspect_meta_model_python.resolver.base import ResolverInterface -class TestAspectModelResolver: - """Aspect Model Resolver test suit.""" - def test__init__(self): - result = AspectModelResolver("meta_model_resolver", "namespace_resolver") +class ResolverTest(ResolverInterface): + """Resolver interface test class.""" - assert result._meta_model_resolver == "meta_model_resolver" - assert result._namespace_resolver == "namespace_resolver" + def read(self, input_data): + return Graph() - @mock.patch("esmf_aspect_meta_model_python.resolver.base.AspectNamespaceResolver") - @mock.patch("esmf_aspect_meta_model_python.resolver.base.AspectMetaModelResolver") - def test_init_with_defaults(self, aspect_meta_model_resolver_mock, aspect_namespace_resolver_mock): - aspect_meta_model_resolver_mock.return_value = "meta_model_resolver" - aspect_namespace_resolver_mock.return_value = "namespace_resolver" - result = AspectModelResolver() + def get_aspect_urn(self): + return "aspect_urn" - assert result._meta_model_resolver == "meta_model_resolver" - assert result._namespace_resolver == "namespace_resolver" - @mock.patch("esmf_aspect_meta_model_python.resolver.base.AspectModelResolver.resolve_namespaces") - @mock.patch("esmf_aspect_meta_model_python.resolver.base.AspectModelResolver.resolve_meta_model") - def test_resolve(self, resolve_meta_model_mock, resolve_namespaces_mock): - aspect_resolver = AspectModelResolver("meta_model_resolver", "namespace_resolver") - result = aspect_resolver.resolve("graph", "file_path", "samm_version") +class TestResolverInterface: + """Resolver interface test suit.""" - assert result is None - resolve_meta_model_mock.assert_called_once_with("graph", "samm_version") - resolve_namespaces_mock.assert_called_once_with("graph", "file_path") + def test_validate_samm_version_no_version(self): + with pytest.raises(ValueError) as error: + ResolverInterface._validate_samm_version("") - @mock.patch("esmf_aspect_meta_model_python.resolver.base.AspectMetaModelResolver") - def test_resolve_meta_model(self, aspect_meta_model_resolver_mock): - meta_model_resolver_mock = mock.MagicMock(name="meta_model_resolver") - aspect_meta_model_resolver_mock.return_value = meta_model_resolver_mock - aspect_resolver = AspectModelResolver(namespace_resolver="namespace_resolver") - result = aspect_resolver.resolve_meta_model("graph", "samm_version") + assert str(error.value) == "SAMM version not found in the Graph." - assert result is None - meta_model_resolver_mock.parse.assert_called_once_with("graph", "samm_version") + @mock.patch("esmf_aspect_meta_model_python.resolver.base.SammUnitsGraph") + def test_validate_samm_version_not_supported_version(self, samm_units_graph_mock): + samm_units_graph_mock.SAMM_VERSION = "2" + with pytest.raises(ValueError) as error: + ResolverInterface._validate_samm_version("1") - @mock.patch("esmf_aspect_meta_model_python.resolver.base.AspectNamespaceResolver") - def test_resolve_namespaces(self, aspect_namespace_resolver_mock): - namespace_resolver_mock = mock.MagicMock(name="namespace_resolver") - aspect_namespace_resolver_mock.return_value = namespace_resolver_mock - aspect_resolver = AspectModelResolver(meta_model_resolver="meta_model_resolver") - result = aspect_resolver.resolve_namespaces("graph", "aspect_file_path") + assert str(error.value) == "1 is not supported SAMM version." - assert result is None - namespace_resolver_mock.parse.assert_called_once_with("graph", "aspect_file_path") + 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 new file mode 100644 index 0000000..a8229ae --- /dev/null +++ b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_data_string.py @@ -0,0 +1,40 @@ +"""Data string resolver test suit.""" + +from unittest import mock + +from rdflib import RDF + +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): + graph_mock = mock.MagicMock(name="graph") + rdf_graph_mock.return_value = graph_mock + resolver = DataStringResolver() + result = resolver.read("data_string") + + assert result == graph_mock + graph_mock.parse.assert_called_once_with(data="data_string") + + @mock.patch("esmf_aspect_meta_model_python.resolver.data_string.SAMM") + @mock.patch("esmf_aspect_meta_model_python.resolver.data_string.DataStringResolver.get_samm_version") + def test_get_aspect_urn(self, get_samm_version_mock, samm_class_mock): + samm_mock = mock.MagicMock(name="samm") + samm_mock.get_urn.return_value = "aspect_urn" + samm_class_mock.return_value = samm_mock + samm_class_mock.aspect = "aspect" + get_samm_version_mock.return_value = "1.2.3" + graph_mock = mock.MagicMock(mname="graph") + graph_mock.value.return_value = "aspect_urn" + resolver = DataStringResolver() + resolver.graph = graph_mock + result = resolver.get_aspect_urn() + + assert result == "aspect_urn" + get_samm_version_mock.assert_called_once() + samm_mock.get_urn.assert_called_once_with("aspect") + graph_mock.value.assert_called_once_with(predicate=RDF.type, object="aspect_urn", any=False) diff --git a/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_handler.py b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_handler.py new file mode 100644 index 0000000..44359b1 --- /dev/null +++ b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_handler.py @@ -0,0 +1,101 @@ +"""Input handler test suit.""" + +from unittest import mock + +import pytest + +from esmf_aspect_meta_model_python.resolver.handler import InputHandler + + +class TestInputHandler: + """Input handler test suit.""" + + def test_init(self): + result = InputHandler("input_data", "input_type") + + assert result.input_data == "input_data" + assert result.input_type == "input_type" + + @mock.patch("esmf_aspect_meta_model_python.resolver.handler.LocalFileResolver") + def test_get_reader_local_file(self, local_file_resolver_mock): + local_file_resolver_mock.return_value = "local_file_reader" + handler = InputHandler("file_path", InputHandler.FILE_PATH_TYPE) + result = handler.get_reader() + + assert result == "local_file_reader" + local_file_resolver_mock.assert_called_once() + + @mock.patch("esmf_aspect_meta_model_python.resolver.handler.DataStringResolver") + def test_get_reader_data_string(self, data_string_resolver): + data_string_resolver.return_value = "data_string_reader" + handler = InputHandler("data", InputHandler.DATA_STRING) + result = handler.get_reader() + + assert result == "data_string_reader" + data_string_resolver.assert_called_once() + + def test_get_reader_raise_error(self): + handler = InputHandler("input_data", "input_type") + with pytest.raises(ValueError) as error: + handler.get_reader() + + assert str(error.value) == "Unknown input type" + + @mock.patch("esmf_aspect_meta_model_python.resolver.handler.InputHandler.get_reader") + def test_get_rdf_graph(self, get_reader_mock): + reader_mock = mock.MagicMock(name="reader") + reader_mock.read.return_value = "graph" + reader_mock.get_aspect_urn.return_value = "aspect_urn" + get_reader_mock.return_value = reader_mock + handler = InputHandler("input_data", "input_type") + result = handler.get_rdf_graph() + + assert len(result) == 2 + graph, aspect_urn = result + assert graph == "graph" + assert aspect_urn == "aspect_urn" + + @mock.patch("esmf_aspect_meta_model_python.resolver.handler.os.path.isfile") + @mock.patch("esmf_aspect_meta_model_python.resolver.handler.InputHandler.contains_newline") + def test_guess_input_type_file_path(self, contains_newline_mock, isfile_mock): + contains_newline_mock.return_value = False + isfile_mock.return_value = True + handler = InputHandler("input_data", "input_type") + result = handler.guess_input_type("input_str") + + assert result == InputHandler.FILE_PATH_TYPE + contains_newline_mock.assert_called_once_with("input_str") + isfile_mock.assert_called_once_with("input_str") + + @mock.patch("esmf_aspect_meta_model_python.resolver.handler.InputHandler.contains_newline") + def test_guess_input_type_data_string_with_newline(self, contains_newline_mock): + contains_newline_mock.return_value = True + handler = InputHandler("input_data", "input_type") + result = handler.guess_input_type("input_str") + + assert result == InputHandler.DATA_STRING + contains_newline_mock.assert_called_once_with("input_str") + + @mock.patch("esmf_aspect_meta_model_python.resolver.handler.os.path.isfile") + @mock.patch("esmf_aspect_meta_model_python.resolver.handler.InputHandler.contains_newline") + def test_guess_input_type_data_string_not_file(self, contains_newline_mock, isfile_mock): + contains_newline_mock.return_value = False + isfile_mock.return_value = False + handler = InputHandler("input_data", "input_type") + result = handler.guess_input_type("input_str") + + assert result == InputHandler.DATA_STRING + contains_newline_mock.assert_called_once_with("input_str") + isfile_mock.assert_called_once_with("input_str") + + def test_contains_newline_true(self): + handler = InputHandler("input_data", "input_type") + result = handler.contains_newline("input_str\n") + + assert result is True + + def test_contains_newline_false(self): + handler = InputHandler("input_data", "input_type") + result = handler.contains_newline("input_str") + + assert result is False 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 new file mode 100644 index 0000000..7c53167 --- /dev/null +++ b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_local_file.py @@ -0,0 +1,201 @@ +"""Local file resolver test suit.""" + +from unittest import mock + +import pytest + +from rdflib import RDF + +from esmf_aspect_meta_model_python.resolver.local_file import LocalFileResolver + + +class TestLocalFileResolver: + """Local file resolver test suit.""" + + def test_init(self): + result = LocalFileResolver() + + assert result.file_path is None + + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.exists") + def test_validate_file(self, exists_mock): + exists_mock.return_value = True + resolver = LocalFileResolver() + result = resolver.validate_file("file_path") + + assert result is None + exists_mock.assert_called_once_with("file_path") + + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.exists") + def test_validate_file_raise_error(self, exists_mock): + exists_mock.return_value = False + resolver = LocalFileResolver() + with pytest.raises(FileNotFoundError) as error: + resolver.validate_file("file_path") + + assert str(error.value) == "Could not find a file file_path" + exists_mock.assert_called_once_with("file_path") + + def test_parse_namespace_no_data(self): + resolver = LocalFileResolver() + result = resolver._parse_namespace("urn:samm:org.eclipse.esmf.samm:2.1.0#") + + assert len(result) == 2 + namespace_specific_str, version = result + assert namespace_specific_str is None + assert version is None + + def test_parse_namespace(self): + resolver = LocalFileResolver() + result = resolver._parse_namespace("urn:samm:com.boschsemanticstack.digitalcv.instance:0.2.0#") + + assert len(result) == 2 + namespace_specific_str, version = result + assert namespace_specific_str == "com.boschsemanticstack.digitalcv.instance" + assert version == "0.2.0" + + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.join") + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver._parse_namespace") + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.Path") + def test_get_dirs_for_advanced_loading(self, path_mock, parse_namespace_mock, join_mock): + path_mock.return_value = path_mock + path_mock.parents = ["parent_path", "path", "base_path"] + graph_mock = mock.MagicMock(name="graph") + graph_mock.namespace_manager.namespaces.return_value = [("prefix", "namespace")] + parse_namespace_mock.return_value = "namespace", "version" + join_mock.return_value = "join_path" + resolver = LocalFileResolver() + resolver.graph = graph_mock + result = resolver._get_dirs_for_advanced_loading("file_path") + + assert result == ["join_path"] + path_mock.assert_called_once_with("file_path") + graph_mock.namespace_manager.namespaces.assert_called_once() + parse_namespace_mock.assert_called_once_with("namespace") + join_mock.assert_called_once_with("base_path", "namespace", "version") + + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver._get_dirs_for_advanced_loading") + def test_get_dependency_folders(self, get_dirs_for_advanced_loading_mock): + graph_mock = mock.MagicMock(name="graph") + get_dirs_for_advanced_loading_mock.return_value = "dependency_folders" + resolver = LocalFileResolver() + resolver.file_path = "base_file_path" + resolver.graph = graph_mock + result = resolver._get_dependency_folders("file_path") + + assert result == "dependency_folders" + graph_mock.parse.assert_called_once_with("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") + def test_get_additional_files_from_dir_raise_error(self, exists_mock): + exists_mock.return_value = False + resolver = LocalFileResolver() + with pytest.raises(NotADirectoryError) as error: + resolver._get_additional_files_from_dir("file_path") + + assert str(error.value) == "Directory not found: file_path" + exists_mock.assert_called_once_with("file_path") + + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.Path") + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.exists") + def test_get_additional_files_from_dir(self, exists_mock, path_mock): + exists_mock.return_value = True + path_mock.return_value = path_mock + path_mock.glob.return_value = ["additional_file_path"] + resolver = LocalFileResolver() + result = resolver._get_additional_files_from_dir("file_path") + + assert result == ["additional_file_path"] + exists_mock.assert_called_once_with("file_path") + path_mock.assert_called_once_with("file_path") + path_mock.glob.assert_called_once_with("*.ttl") + + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.print") + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver._get_additional_files_from_dir") + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver._get_dependency_folders") + def test_get_dependency_files_raise_error( + self, + get_dependency_folders_mock, + get_additional_files_from_dir_mock, + print_mock, + ): + get_dependency_folders_mock.side_effect = (["dependency_folder"], Exception("error")) + get_additional_files_from_dir_mock.return_value = ["additional_file_path"] + resolver = LocalFileResolver() + file_dependencies = {} + folder_dependencies = {} + with pytest.raises(Exception) as error: + resolver._get_dependency_files(file_dependencies, folder_dependencies, "file_path") + + assert str(error.value) == "error" + get_dependency_folders_mock.assert_has_calls([mock.call("file_path"), mock.call("additional_file_path")]) + get_additional_files_from_dir_mock.assert_called_once_with("dependency_folder") + print_mock.assert_called_once_with("Could not parse file additional_file_path\nError: error") + + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver._get_additional_files_from_dir") + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver._get_dependency_folders") + def test_get_dependency_files(self, get_dependency_folders_mock, get_additional_files_from_dir_mock): + get_dependency_folders_mock.return_value = ["dependency_folder"] + get_additional_files_from_dir_mock.return_value = ["additional_file_path"] + resolver = LocalFileResolver() + file_dependencies = {} + folder_dependencies = {} + result = resolver._get_dependency_files(file_dependencies, folder_dependencies, "file_path") + + assert result == {"file_path": ["dependency_folder"], "additional_file_path": ["dependency_folder"]} + get_dependency_folders_mock.assert_has_calls([mock.call("file_path"), mock.call("additional_file_path")]) + get_additional_files_from_dir_mock.assert_called_once_with("dependency_folder") + + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver._get_dependency_files") + def test_parse_namespaces(self, get_dependency_files_mock): + resolver = LocalFileResolver() + result = resolver.parse_namespaces("aspect_file_path") + + assert result is None + get_dependency_files_mock.assert_called_once_with({}, {}, "aspect_file_path") + + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver.parse_namespaces") + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver._find_aspect_urn") + def test_read(self, find_aspect_urn_mock, parse_namespaces_mock): + graph_mock = mock.MagicMock(name="graph") + resolver = LocalFileResolver() + resolver.graph = graph_mock + result = resolver.read("file_path") + + assert result == graph_mock + assert resolver.file_path == "file_path" + graph_mock.parse.assert_called_once_with("file_path") + find_aspect_urn_mock.assert_called_once() + parse_namespaces_mock.assert_called_once_with("file_path") + + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.Path") + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.SAMM") + @mock.patch("esmf_aspect_meta_model_python.resolver.local_file.LocalFileResolver.get_samm_version") + def test_find_aspect_urn(self, get_samm_version_mock, samm_class_mock, path_mock): + samm_mock = mock.MagicMock(name="samm") + samm_mock.get_urn.return_value = "aspect_urn" + samm_class_mock.return_value = samm_mock + samm_class_mock.aspect = "aspect" + get_samm_version_mock.return_value = "1.2.3" + graph_mock = mock.MagicMock(mname="graph") + graph_mock.subjects.return_value = ["path#aspect_name", "path#another_aspect_urn"] + path_mock.return_value = path_mock + path_mock.stem = "aspect" + resolver = LocalFileResolver() + resolver.file_path = "path/to/file/aspect_name.ttl" + resolver.graph = graph_mock + result = resolver._find_aspect_urn() + + assert result is None + get_samm_version_mock.assert_called_once() + samm_mock.get_urn.assert_called_once_with("aspect") + graph_mock.subjects.assert_called_once_with(predicate=RDF.type, object="aspect_urn") + path_mock.assert_called_once_with("path/to/file/aspect_name.ttl") + + def test_get_aspect_urn(self): + resolver = LocalFileResolver() + resolver.aspect_urn = "aspect_urn" + result = resolver.get_aspect_urn() + + assert result == "aspect_urn" diff --git a/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_namespace.py b/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_namespace.py deleted file mode 100644 index 0aa2f87..0000000 --- a/core/esmf-aspect-meta-model-python/tests/unit/resolver/test_namespace.py +++ /dev/null @@ -1,131 +0,0 @@ -"""Aspect namespace resolver test suite.""" - -from unittest import mock - -import pytest - -from esmf_aspect_meta_model_python.resolver.namespace import AspectNamespaceResolver - - -class TestAspectNamespaceResolver: - """Aspect namespace resolver test suite.""" - - def test_init(self): - result = AspectNamespaceResolver() - - assert result.aspect_graph is None - - @mock.patch("esmf_aspect_meta_model_python.resolver.namespace.exists") - def test_validate_file(self, exists_mock): - exists_mock.return_value = False - with pytest.raises(FileNotFoundError) as error: - AspectNamespaceResolver.validate_file("file_path") - - assert str(error.value) == "Could not find a file file_path" - - def test_parse_namespace(self): - result = AspectNamespaceResolver._parse_namespace("urn:samm:some.address:0.1.2#") - - assert result == ("some.address", "0.1.2") - - def test_parse_namespace_not_valid_samm(self): - result = AspectNamespaceResolver._parse_namespace("urn:samm:org.eclipse.esmf.samm:not.valid.reference#") - - assert result == (None, None) - - @mock.patch("esmf_aspect_meta_model_python.resolver.namespace.join") - @mock.patch("esmf_aspect_meta_model_python.resolver.namespace.AspectNamespaceResolver._parse_namespace") - @mock.patch("esmf_aspect_meta_model_python.resolver.namespace.Path") - def test_get_dirs_for_advanced_loading( - self, - path_mock, - parse_namespace_mock, - join_mock, - ): - path_mock.return_value = path_mock - path_mock.parents = ["path", "some_path", "base_path"] - aspect_graph_mock = mock.MagicMock(name="aspect_graph") - aspect_graph_mock.namespace_manager.namespaces.return_value = [ - ("prefix", "namespace"), - ] - parse_namespace_mock.return_value = ("namespace_specific_str", "version") - join_mock.return_value = "paths_for_advanced_loading" - resolver = AspectNamespaceResolver() - resolver.aspect_graph = aspect_graph_mock - result = resolver._get_dirs_for_advanced_loading("file_path") - - assert result == ["paths_for_advanced_loading"] - path_mock.assert_called_once_with("file_path") - aspect_graph_mock.namespace_manager.namespaces.assert_called_once() - parse_namespace_mock.assert_called_once_with("namespace") - join_mock.assert_called_once_with("base_path", "namespace_specific_str", "version") - - @mock.patch( - "esmf_aspect_meta_model_python.resolver.namespace.AspectNamespaceResolver._get_dirs_for_advanced_loading" - ) - def test_get_dependency_folders(self, get_dirs_for_advanced_loading_mock): - get_dirs_for_advanced_loading_mock.return_value = "dependency_folders" - resolver = AspectNamespaceResolver() - graph_mock = mock.MagicMock(name="graph") - resolver.aspect_graph = graph_mock - result = resolver._get_dependency_folders("file_path") - - assert result == "dependency_folders" - graph_mock.parse.assert_called_once_with("file_path", format="turtle") - get_dirs_for_advanced_loading_mock.assert_called_once_with("file_path") - - @mock.patch("esmf_aspect_meta_model_python.resolver.namespace.Path") - @mock.patch("esmf_aspect_meta_model_python.resolver.namespace.exists") - def test_get_additional_files_from_dir(self, exists_mock, path_mock): - exists_mock.return_value = True - path_mock.return_value = path_mock - path_mock.glob.return_value = ["additional_file_path"] - resolver = AspectNamespaceResolver() - result = resolver._get_additional_files_from_dir("file_path") - - assert result == ["additional_file_path"] - exists_mock.assert_called_once_with("file_path") - path_mock.assert_called_once_with("file_path") - path_mock.glob.assert_called_once_with("*.ttl") - - @mock.patch("esmf_aspect_meta_model_python.resolver.namespace.exists") - def test_get_additional_files_from_dir_raise_exception(self, exists_mock): - exists_mock.return_value = False - resolver = AspectNamespaceResolver() - with pytest.raises(NotADirectoryError) as error: - resolver._get_additional_files_from_dir("file_path") - - assert str(error.value) == "Directory not found: file_path" - - @mock.patch( - "esmf_aspect_meta_model_python.resolver.namespace.AspectNamespaceResolver._get_additional_files_from_dir" - ) - @mock.patch("esmf_aspect_meta_model_python.resolver.namespace.AspectNamespaceResolver._get_dependency_folders") - def test_get_dependency_files(self, get_dependency_folders_mock, get_additional_files_from_dir_mock): - get_dependency_folders_mock.side_effect = (["folder_1", "folder_2"], ["folder_1", "folder_3"]) - get_additional_files_from_dir_mock.side_effect = (["file_1"], ["file_1", "file_2"], ["file_2"]) - file_dependencies = {} - folder_dependencies = {} - resolver = AspectNamespaceResolver() - result = resolver._get_dependency_files(file_dependencies, folder_dependencies, "file_1") - - assert "file_1" in result - assert sorted(result["file_1"]) == ["folder_1", "folder_2"] - assert "file_2" in result - assert sorted(result["file_2"]) == ["folder_1", "folder_3"] - get_dependency_folders_mock.assert_has_calls( - [ - mock.call("file_1"), - mock.call("file_2"), - ] - ) - get_additional_files_from_dir_mock.assert_has_calls( - [ - mock.call("folder_1"), - mock.call("folder_2"), - mock.call("folder_3"), - ] - ) - - def test_parse(self): - pass diff --git a/core/esmf-aspect-meta-model-python/tests_invalid/test_constraints.py b/core/esmf-aspect-meta-model-python/tests_invalid/test_constraints.py index 28b0348..163076c 100644 --- a/core/esmf-aspect-meta-model-python/tests_invalid/test_constraints.py +++ b/core/esmf-aspect-meta-model-python/tests_invalid/test_constraints.py @@ -13,20 +13,25 @@ import pytest -from esmf_aspect_meta_model_python.loader.aspect_loader import AspectLoader +from esmf_aspect_meta_model_python import AspectLoader +from esmf_aspect_meta_model_python.resolver.handler import InputHandler RESOURCE_PATH = Path("tests_invalid/resources") def test_trait_missing_base_characteristic(): + file_path = RESOURCE_PATH / "trait_missing_base_characteristic.ttl" + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() with pytest.raises(ValueError): - file_path = RESOURCE_PATH / "trait_missing_base_characteristic.ttl" loader = AspectLoader() - loader.load_aspect_model(file_path) + _ = loader.load_aspect_model(rdf_graph, aspect_urn) def test_trait_missing_constraint(): + file_path = RESOURCE_PATH / "trait_missing_constraint.ttl" + handler = InputHandler(str(file_path), input_type=InputHandler.FILE_PATH_TYPE) + rdf_graph, aspect_urn = handler.get_rdf_graph() with pytest.raises(ValueError): - file_path = RESOURCE_PATH / "trait_missing_constraint.ttl" loader = AspectLoader() - loader.load_aspect_model(file_path) + _ = loader.load_aspect_model(rdf_graph, aspect_urn)