# This code has been automatically generated by:
# dev_scripts/test_codegen/generate_common_jsonization.py
# Do NOT edit or append.


"""Provide common functionality for JSON de-serialization."""


# pylint: disable=missing-docstring


import collections.abc
import json
import sys
from typing import Iterator, Optional

if sys.version_info >= (3, 8):
    from typing import Final
else:
    from typing_extensions import Final

import aas_core3_1.common as aas_common
import aas_core3_1.jsonization as aas_jsonization
import aas_core3_1.types as aas_types

import tests.common


class Difference:
    """Represent a single difference between two JSON-ables."""

    #: Human-readable description of the difference
    message: Final[str]

    #: Path in the expected JSON-able value which is different from
    #: the obtained JSON-able value
    path: Final[aas_jsonization.Path]

    def __init__(self, message: str) -> None:
        """Initialize with the given message and empty path."""
        self.message = message
        self.path = aas_jsonization.Path()

    def __str__(self) -> str:
        return f"#{self.path}: {self.message}"


def check_equal(
    expected: aas_jsonization.Jsonable,
    got: aas_jsonization.Jsonable,
) -> Iterator[Difference]:
    """
    Compare recursively two JSON-able values for equality.

    :param expected: expected JSON-able value
    :param got: obtained JSON-able value
    :yield: differences
    """
    if isinstance(expected, (bool, int, float, str, bytes)):
        if type(expected) != type(got):  # pylint: disable=unidiomatic-typecheck
            yield Difference(f"Expected {type(expected)}, but got {type(got)}")

        if expected != got:
            yield Difference(f"Expected {expected!r}, but got {got!r}")
    elif isinstance(expected, collections.abc.Sequence):
        if not isinstance(got, collections.abc.Sequence):
            yield Difference(f"Expected a sequence, but got {type(got)}")
        else:
            if len(expected) != len(got):
                yield Difference(
                    f"Expected a sequence of {len(expected)} item(s), "
                    f"but got {len(got)} item(s)"
                )

            for i, (expected_item, got_item) in enumerate(zip(expected, got)):
                for difference in check_equal(expected_item, got_item):
                    difference.path._prepend(aas_jsonization.IndexSegment(expected, i))
                    yield difference

    elif isinstance(expected, collections.abc.Mapping):
        if not isinstance(got, collections.abc.Mapping):
            yield Difference(f"Expected a mapping, but got {type(got)}")
        else:
            if not all(isinstance(key, str) for key in expected.keys()):
                raise ValueError(
                    f"Expected all keys in the expected JSON-able value to be strings, "
                    f"but got: {list(expected.keys())}"
                )

            if not all(isinstance(key, str) for key in got.keys()):
                yield Difference(
                    f"Expected all keys in a mapping to be strings, "
                    f"but got: {list(got.keys())}"
                )

            expected_key_set = set(expected.keys())
            got_key_set = set(got.keys())

            expected_got_diff = expected_key_set.difference(got_key_set)
            if expected_got_diff:
                yield Difference(f"Expected key(s) {sorted(expected_got_diff)} missing")

            got_expected_diff = got_key_set.difference(expected_key_set)
            if got_expected_diff:
                yield Difference(f"Unexpected key(s) {sorted(got_expected_diff)}")

            for key, expected_value in expected.items():
                got_value = got[key]

                for difference in check_equal(expected_value, got_value):
                    difference.path._prepend(
                        aas_jsonization.PropertySegment(expected, key)
                    )
                    yield difference
    else:
        aas_common.assert_never(expected)


def load_maximal_extension() -> aas_types.Extension:
    """
    Load a maximal example
    of :py:class:`aas_types.Extension`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Extension"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Extension] = None

    for something in container.descend():
        if isinstance(something, aas_types.Extension):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Extension " f"in {path}, but found none."
        )

    return instance


def load_minimal_extension() -> aas_types.Extension:
    """
    Load a minimal example
    of :py:class:`aas_types.Extension`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Extension"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Extension] = None

    for something in container.descend():
        if isinstance(something, aas_types.Extension):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Extension " f"in {path}, but found none."
        )

    return instance


def load_maximal_administrative_information() -> aas_types.AdministrativeInformation:
    """
    Load a maximal example
    of :py:class:`aas_types.AdministrativeInformation`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "AdministrativeInformation"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.AdministrativeInformation] = None

    for something in container.descend():
        if isinstance(something, aas_types.AdministrativeInformation):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of AdministrativeInformation "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_administrative_information() -> aas_types.AdministrativeInformation:
    """
    Load a minimal example
    of :py:class:`aas_types.AdministrativeInformation`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "AdministrativeInformation"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.AdministrativeInformation] = None

    for something in container.descend():
        if isinstance(something, aas_types.AdministrativeInformation):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of AdministrativeInformation "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_qualifier() -> aas_types.Qualifier:
    """
    Load a maximal example
    of :py:class:`aas_types.Qualifier`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Qualifier"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Qualifier] = None

    for something in container.descend():
        if isinstance(something, aas_types.Qualifier):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Qualifier " f"in {path}, but found none."
        )

    return instance


def load_minimal_qualifier() -> aas_types.Qualifier:
    """
    Load a minimal example
    of :py:class:`aas_types.Qualifier`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Qualifier"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Qualifier] = None

    for something in container.descend():
        if isinstance(something, aas_types.Qualifier):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Qualifier " f"in {path}, but found none."
        )

    return instance


def load_maximal_asset_administration_shell() -> aas_types.AssetAdministrationShell:
    """
    Load a maximal example
    of :py:class:`aas_types.AssetAdministrationShell`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "AssetAdministrationShell"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.AssetAdministrationShell] = None

    for something in container.descend():
        if isinstance(something, aas_types.AssetAdministrationShell):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of AssetAdministrationShell "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_asset_administration_shell() -> aas_types.AssetAdministrationShell:
    """
    Load a minimal example
    of :py:class:`aas_types.AssetAdministrationShell`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "AssetAdministrationShell"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.AssetAdministrationShell] = None

    for something in container.descend():
        if isinstance(something, aas_types.AssetAdministrationShell):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of AssetAdministrationShell "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_asset_information() -> aas_types.AssetInformation:
    """
    Load a maximal example
    of :py:class:`aas_types.AssetInformation`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "AssetInformation"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.AssetInformation] = None

    for something in container.descend():
        if isinstance(something, aas_types.AssetInformation):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of AssetInformation "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_asset_information() -> aas_types.AssetInformation:
    """
    Load a minimal example
    of :py:class:`aas_types.AssetInformation`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "AssetInformation"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.AssetInformation] = None

    for something in container.descend():
        if isinstance(something, aas_types.AssetInformation):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of AssetInformation "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_resource() -> aas_types.Resource:
    """
    Load a maximal example
    of :py:class:`aas_types.Resource`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Resource"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Resource] = None

    for something in container.descend():
        if isinstance(something, aas_types.Resource):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Resource " f"in {path}, but found none."
        )

    return instance


def load_minimal_resource() -> aas_types.Resource:
    """
    Load a minimal example
    of :py:class:`aas_types.Resource`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Resource"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Resource] = None

    for something in container.descend():
        if isinstance(something, aas_types.Resource):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Resource " f"in {path}, but found none."
        )

    return instance


def load_maximal_specific_asset_id() -> aas_types.SpecificAssetID:
    """
    Load a maximal example
    of :py:class:`aas_types.SpecificAssetID`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "SpecificAssetId"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.SpecificAssetID] = None

    for something in container.descend():
        if isinstance(something, aas_types.SpecificAssetID):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of SpecificAssetID "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_specific_asset_id() -> aas_types.SpecificAssetID:
    """
    Load a minimal example
    of :py:class:`aas_types.SpecificAssetID`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "SpecificAssetId"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.SpecificAssetID] = None

    for something in container.descend():
        if isinstance(something, aas_types.SpecificAssetID):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of SpecificAssetID "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_submodel() -> aas_types.Submodel:
    """
    Load a maximal example
    of :py:class:`aas_types.Submodel`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Submodel"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Submodel] = None

    for something in container.descend():
        if isinstance(something, aas_types.Submodel):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Submodel " f"in {path}, but found none."
        )

    return instance


def load_minimal_submodel() -> aas_types.Submodel:
    """
    Load a minimal example
    of :py:class:`aas_types.Submodel`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Submodel"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Submodel] = None

    for something in container.descend():
        if isinstance(something, aas_types.Submodel):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Submodel " f"in {path}, but found none."
        )

    return instance


def load_maximal_relationship_element() -> aas_types.RelationshipElement:
    """
    Load a maximal example
    of :py:class:`aas_types.RelationshipElement`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "RelationshipElement"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.RelationshipElement] = None

    for something in container.descend():
        if isinstance(something, aas_types.RelationshipElement):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of RelationshipElement "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_relationship_element() -> aas_types.RelationshipElement:
    """
    Load a minimal example
    of :py:class:`aas_types.RelationshipElement`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "RelationshipElement"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.RelationshipElement] = None

    for something in container.descend():
        if isinstance(something, aas_types.RelationshipElement):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of RelationshipElement "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_submodel_element_list() -> aas_types.SubmodelElementList:
    """
    Load a maximal example
    of :py:class:`aas_types.SubmodelElementList`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "SubmodelElementList"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.SubmodelElementList] = None

    for something in container.descend():
        if isinstance(something, aas_types.SubmodelElementList):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of SubmodelElementList "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_submodel_element_list() -> aas_types.SubmodelElementList:
    """
    Load a minimal example
    of :py:class:`aas_types.SubmodelElementList`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "SubmodelElementList"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.SubmodelElementList] = None

    for something in container.descend():
        if isinstance(something, aas_types.SubmodelElementList):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of SubmodelElementList "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_submodel_element_collection() -> aas_types.SubmodelElementCollection:
    """
    Load a maximal example
    of :py:class:`aas_types.SubmodelElementCollection`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "SubmodelElementCollection"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.SubmodelElementCollection] = None

    for something in container.descend():
        if isinstance(something, aas_types.SubmodelElementCollection):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of SubmodelElementCollection "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_submodel_element_collection() -> aas_types.SubmodelElementCollection:
    """
    Load a minimal example
    of :py:class:`aas_types.SubmodelElementCollection`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "SubmodelElementCollection"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.SubmodelElementCollection] = None

    for something in container.descend():
        if isinstance(something, aas_types.SubmodelElementCollection):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of SubmodelElementCollection "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_property() -> aas_types.Property:
    """
    Load a maximal example
    of :py:class:`aas_types.Property`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Property"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Property] = None

    for something in container.descend():
        if isinstance(something, aas_types.Property):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Property " f"in {path}, but found none."
        )

    return instance


def load_minimal_property() -> aas_types.Property:
    """
    Load a minimal example
    of :py:class:`aas_types.Property`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Property"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Property] = None

    for something in container.descend():
        if isinstance(something, aas_types.Property):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Property " f"in {path}, but found none."
        )

    return instance


def load_maximal_multi_language_property() -> aas_types.MultiLanguageProperty:
    """
    Load a maximal example
    of :py:class:`aas_types.MultiLanguageProperty`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "MultiLanguageProperty"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.MultiLanguageProperty] = None

    for something in container.descend():
        if isinstance(something, aas_types.MultiLanguageProperty):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of MultiLanguageProperty "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_multi_language_property() -> aas_types.MultiLanguageProperty:
    """
    Load a minimal example
    of :py:class:`aas_types.MultiLanguageProperty`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "MultiLanguageProperty"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.MultiLanguageProperty] = None

    for something in container.descend():
        if isinstance(something, aas_types.MultiLanguageProperty):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of MultiLanguageProperty "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_range() -> aas_types.Range:
    """
    Load a maximal example
    of :py:class:`aas_types.Range`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Range"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Range] = None

    for something in container.descend():
        if isinstance(something, aas_types.Range):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Range " f"in {path}, but found none."
        )

    return instance


def load_minimal_range() -> aas_types.Range:
    """
    Load a minimal example
    of :py:class:`aas_types.Range`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Range"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Range] = None

    for something in container.descend():
        if isinstance(something, aas_types.Range):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Range " f"in {path}, but found none."
        )

    return instance


def load_maximal_reference_element() -> aas_types.ReferenceElement:
    """
    Load a maximal example
    of :py:class:`aas_types.ReferenceElement`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "ReferenceElement"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.ReferenceElement] = None

    for something in container.descend():
        if isinstance(something, aas_types.ReferenceElement):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of ReferenceElement "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_reference_element() -> aas_types.ReferenceElement:
    """
    Load a minimal example
    of :py:class:`aas_types.ReferenceElement`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "ReferenceElement"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.ReferenceElement] = None

    for something in container.descend():
        if isinstance(something, aas_types.ReferenceElement):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of ReferenceElement "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_blob() -> aas_types.Blob:
    """
    Load a maximal example
    of :py:class:`aas_types.Blob`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Blob"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Blob] = None

    for something in container.descend():
        if isinstance(something, aas_types.Blob):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Blob " f"in {path}, but found none."
        )

    return instance


def load_minimal_blob() -> aas_types.Blob:
    """
    Load a minimal example
    of :py:class:`aas_types.Blob`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Blob"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Blob] = None

    for something in container.descend():
        if isinstance(something, aas_types.Blob):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Blob " f"in {path}, but found none."
        )

    return instance


def load_maximal_file() -> aas_types.File:
    """
    Load a maximal example
    of :py:class:`aas_types.File`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "File"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.File] = None

    for something in container.descend():
        if isinstance(something, aas_types.File):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of File " f"in {path}, but found none."
        )

    return instance


def load_minimal_file() -> aas_types.File:
    """
    Load a minimal example
    of :py:class:`aas_types.File`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "File"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.File] = None

    for something in container.descend():
        if isinstance(something, aas_types.File):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of File " f"in {path}, but found none."
        )

    return instance


def load_maximal_annotated_relationship_element() -> (
    aas_types.AnnotatedRelationshipElement
):
    """
    Load a maximal example
    of :py:class:`aas_types.AnnotatedRelationshipElement`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "AnnotatedRelationshipElement"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.AnnotatedRelationshipElement] = None

    for something in container.descend():
        if isinstance(something, aas_types.AnnotatedRelationshipElement):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of AnnotatedRelationshipElement "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_annotated_relationship_element() -> (
    aas_types.AnnotatedRelationshipElement
):
    """
    Load a minimal example
    of :py:class:`aas_types.AnnotatedRelationshipElement`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "AnnotatedRelationshipElement"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.AnnotatedRelationshipElement] = None

    for something in container.descend():
        if isinstance(something, aas_types.AnnotatedRelationshipElement):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of AnnotatedRelationshipElement "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_entity() -> aas_types.Entity:
    """
    Load a maximal example
    of :py:class:`aas_types.Entity`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Entity"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Entity] = None

    for something in container.descend():
        if isinstance(something, aas_types.Entity):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Entity " f"in {path}, but found none."
        )

    return instance


def load_minimal_entity() -> aas_types.Entity:
    """
    Load a minimal example
    of :py:class:`aas_types.Entity`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Entity"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Entity] = None

    for something in container.descend():
        if isinstance(something, aas_types.Entity):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Entity " f"in {path}, but found none."
        )

    return instance


def load_maximal_event_payload() -> aas_types.EventPayload:
    """
    Load a maximal example
    of :py:class:`aas_types.EventPayload`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "SelfContained"
        / "Expected"
        / "EventPayload"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    return aas_jsonization.event_payload_from_jsonable(jsonable)


def load_minimal_event_payload() -> aas_types.EventPayload:
    """
    Load a minimal example
    of :py:class:`aas_types.EventPayload`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "SelfContained"
        / "Expected"
        / "EventPayload"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    return aas_jsonization.event_payload_from_jsonable(jsonable)


def load_maximal_basic_event_element() -> aas_types.BasicEventElement:
    """
    Load a maximal example
    of :py:class:`aas_types.BasicEventElement`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "BasicEventElement"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.BasicEventElement] = None

    for something in container.descend():
        if isinstance(something, aas_types.BasicEventElement):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of BasicEventElement "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_basic_event_element() -> aas_types.BasicEventElement:
    """
    Load a minimal example
    of :py:class:`aas_types.BasicEventElement`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "BasicEventElement"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.BasicEventElement] = None

    for something in container.descend():
        if isinstance(something, aas_types.BasicEventElement):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of BasicEventElement "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_operation() -> aas_types.Operation:
    """
    Load a maximal example
    of :py:class:`aas_types.Operation`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Operation"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Operation] = None

    for something in container.descend():
        if isinstance(something, aas_types.Operation):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Operation " f"in {path}, but found none."
        )

    return instance


def load_minimal_operation() -> aas_types.Operation:
    """
    Load a minimal example
    of :py:class:`aas_types.Operation`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Operation"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Operation] = None

    for something in container.descend():
        if isinstance(something, aas_types.Operation):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Operation " f"in {path}, but found none."
        )

    return instance


def load_maximal_operation_variable() -> aas_types.OperationVariable:
    """
    Load a maximal example
    of :py:class:`aas_types.OperationVariable`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "OperationVariable"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.OperationVariable] = None

    for something in container.descend():
        if isinstance(something, aas_types.OperationVariable):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of OperationVariable "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_operation_variable() -> aas_types.OperationVariable:
    """
    Load a minimal example
    of :py:class:`aas_types.OperationVariable`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "OperationVariable"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.OperationVariable] = None

    for something in container.descend():
        if isinstance(something, aas_types.OperationVariable):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of OperationVariable "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_capability() -> aas_types.Capability:
    """
    Load a maximal example
    of :py:class:`aas_types.Capability`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Capability"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Capability] = None

    for something in container.descend():
        if isinstance(something, aas_types.Capability):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Capability " f"in {path}, but found none."
        )

    return instance


def load_minimal_capability() -> aas_types.Capability:
    """
    Load a minimal example
    of :py:class:`aas_types.Capability`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Capability"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Capability] = None

    for something in container.descend():
        if isinstance(something, aas_types.Capability):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Capability " f"in {path}, but found none."
        )

    return instance


def load_maximal_concept_description() -> aas_types.ConceptDescription:
    """
    Load a maximal example
    of :py:class:`aas_types.ConceptDescription`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "ConceptDescription"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.ConceptDescription] = None

    for something in container.descend():
        if isinstance(something, aas_types.ConceptDescription):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of ConceptDescription "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_concept_description() -> aas_types.ConceptDescription:
    """
    Load a minimal example
    of :py:class:`aas_types.ConceptDescription`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "ConceptDescription"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.ConceptDescription] = None

    for something in container.descend():
        if isinstance(something, aas_types.ConceptDescription):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of ConceptDescription "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_reference() -> aas_types.Reference:
    """
    Load a maximal example
    of :py:class:`aas_types.Reference`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Reference"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Reference] = None

    for something in container.descend():
        if isinstance(something, aas_types.Reference):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Reference " f"in {path}, but found none."
        )

    return instance


def load_minimal_reference() -> aas_types.Reference:
    """
    Load a minimal example
    of :py:class:`aas_types.Reference`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Reference"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Reference] = None

    for something in container.descend():
        if isinstance(something, aas_types.Reference):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Reference " f"in {path}, but found none."
        )

    return instance


def load_maximal_key() -> aas_types.Key:
    """
    Load a maximal example
    of :py:class:`aas_types.Key`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Key"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Key] = None

    for something in container.descend():
        if isinstance(something, aas_types.Key):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Key " f"in {path}, but found none."
        )

    return instance


def load_minimal_key() -> aas_types.Key:
    """
    Load a minimal example
    of :py:class:`aas_types.Key`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "Key"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.Key] = None

    for something in container.descend():
        if isinstance(something, aas_types.Key):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of Key " f"in {path}, but found none."
        )

    return instance


def load_maximal_lang_string_name_type() -> aas_types.LangStringNameType:
    """
    Load a maximal example
    of :py:class:`aas_types.LangStringNameType`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LangStringNameType"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LangStringNameType] = None

    for something in container.descend():
        if isinstance(something, aas_types.LangStringNameType):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LangStringNameType "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_lang_string_name_type() -> aas_types.LangStringNameType:
    """
    Load a minimal example
    of :py:class:`aas_types.LangStringNameType`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LangStringNameType"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LangStringNameType] = None

    for something in container.descend():
        if isinstance(something, aas_types.LangStringNameType):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LangStringNameType "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_lang_string_text_type() -> aas_types.LangStringTextType:
    """
    Load a maximal example
    of :py:class:`aas_types.LangStringTextType`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LangStringTextType"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LangStringTextType] = None

    for something in container.descend():
        if isinstance(something, aas_types.LangStringTextType):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LangStringTextType "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_lang_string_text_type() -> aas_types.LangStringTextType:
    """
    Load a minimal example
    of :py:class:`aas_types.LangStringTextType`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LangStringTextType"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LangStringTextType] = None

    for something in container.descend():
        if isinstance(something, aas_types.LangStringTextType):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LangStringTextType "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_environment() -> aas_types.Environment:
    """
    Load a maximal example
    of :py:class:`aas_types.Environment`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "SelfContained"
        / "Expected"
        / "Environment"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    return aas_jsonization.environment_from_jsonable(jsonable)


def load_minimal_environment() -> aas_types.Environment:
    """
    Load a minimal example
    of :py:class:`aas_types.Environment`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "SelfContained"
        / "Expected"
        / "Environment"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    return aas_jsonization.environment_from_jsonable(jsonable)


def load_maximal_embedded_data_specification() -> aas_types.EmbeddedDataSpecification:
    """
    Load a maximal example
    of :py:class:`aas_types.EmbeddedDataSpecification`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "EmbeddedDataSpecification"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.EmbeddedDataSpecification] = None

    for something in container.descend():
        if isinstance(something, aas_types.EmbeddedDataSpecification):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of EmbeddedDataSpecification "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_embedded_data_specification() -> aas_types.EmbeddedDataSpecification:
    """
    Load a minimal example
    of :py:class:`aas_types.EmbeddedDataSpecification`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "EmbeddedDataSpecification"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.EmbeddedDataSpecification] = None

    for something in container.descend():
        if isinstance(something, aas_types.EmbeddedDataSpecification):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of EmbeddedDataSpecification "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_level_type() -> aas_types.LevelType:
    """
    Load a maximal example
    of :py:class:`aas_types.LevelType`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LevelType"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LevelType] = None

    for something in container.descend():
        if isinstance(something, aas_types.LevelType):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LevelType " f"in {path}, but found none."
        )

    return instance


def load_minimal_level_type() -> aas_types.LevelType:
    """
    Load a minimal example
    of :py:class:`aas_types.LevelType`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LevelType"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LevelType] = None

    for something in container.descend():
        if isinstance(something, aas_types.LevelType):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LevelType " f"in {path}, but found none."
        )

    return instance


def load_maximal_value_reference_pair() -> aas_types.ValueReferencePair:
    """
    Load a maximal example
    of :py:class:`aas_types.ValueReferencePair`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "ValueReferencePair"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.ValueReferencePair] = None

    for something in container.descend():
        if isinstance(something, aas_types.ValueReferencePair):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of ValueReferencePair "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_value_reference_pair() -> aas_types.ValueReferencePair:
    """
    Load a minimal example
    of :py:class:`aas_types.ValueReferencePair`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "ValueReferencePair"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.ValueReferencePair] = None

    for something in container.descend():
        if isinstance(something, aas_types.ValueReferencePair):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of ValueReferencePair "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_value_list() -> aas_types.ValueList:
    """
    Load a maximal example
    of :py:class:`aas_types.ValueList`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "ValueList"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.ValueList] = None

    for something in container.descend():
        if isinstance(something, aas_types.ValueList):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of ValueList " f"in {path}, but found none."
        )

    return instance


def load_minimal_value_list() -> aas_types.ValueList:
    """
    Load a minimal example
    of :py:class:`aas_types.ValueList`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "ValueList"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.ValueList] = None

    for something in container.descend():
        if isinstance(something, aas_types.ValueList):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of ValueList " f"in {path}, but found none."
        )

    return instance


def load_maximal_lang_string_preferred_name_type_iec_61360() -> (
    aas_types.LangStringPreferredNameTypeIEC61360
):
    """
    Load a maximal example
    of :py:class:`aas_types.LangStringPreferredNameTypeIEC61360`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LangStringPreferredNameTypeIec61360"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LangStringPreferredNameTypeIEC61360] = None

    for something in container.descend():
        if isinstance(something, aas_types.LangStringPreferredNameTypeIEC61360):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LangStringPreferredNameTypeIEC61360 "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_lang_string_preferred_name_type_iec_61360() -> (
    aas_types.LangStringPreferredNameTypeIEC61360
):
    """
    Load a minimal example
    of :py:class:`aas_types.LangStringPreferredNameTypeIEC61360`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LangStringPreferredNameTypeIec61360"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LangStringPreferredNameTypeIEC61360] = None

    for something in container.descend():
        if isinstance(something, aas_types.LangStringPreferredNameTypeIEC61360):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LangStringPreferredNameTypeIEC61360 "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_lang_string_short_name_type_iec_61360() -> (
    aas_types.LangStringShortNameTypeIEC61360
):
    """
    Load a maximal example
    of :py:class:`aas_types.LangStringShortNameTypeIEC61360`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LangStringShortNameTypeIec61360"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LangStringShortNameTypeIEC61360] = None

    for something in container.descend():
        if isinstance(something, aas_types.LangStringShortNameTypeIEC61360):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LangStringShortNameTypeIEC61360 "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_lang_string_short_name_type_iec_61360() -> (
    aas_types.LangStringShortNameTypeIEC61360
):
    """
    Load a minimal example
    of :py:class:`aas_types.LangStringShortNameTypeIEC61360`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LangStringShortNameTypeIec61360"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LangStringShortNameTypeIEC61360] = None

    for something in container.descend():
        if isinstance(something, aas_types.LangStringShortNameTypeIEC61360):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LangStringShortNameTypeIEC61360 "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_lang_string_definition_type_iec_61360() -> (
    aas_types.LangStringDefinitionTypeIEC61360
):
    """
    Load a maximal example
    of :py:class:`aas_types.LangStringDefinitionTypeIEC61360`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LangStringDefinitionTypeIec61360"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LangStringDefinitionTypeIEC61360] = None

    for something in container.descend():
        if isinstance(something, aas_types.LangStringDefinitionTypeIEC61360):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LangStringDefinitionTypeIEC61360 "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_lang_string_definition_type_iec_61360() -> (
    aas_types.LangStringDefinitionTypeIEC61360
):
    """
    Load a minimal example
    of :py:class:`aas_types.LangStringDefinitionTypeIEC61360`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "LangStringDefinitionTypeIec61360"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.LangStringDefinitionTypeIEC61360] = None

    for something in container.descend():
        if isinstance(something, aas_types.LangStringDefinitionTypeIEC61360):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of LangStringDefinitionTypeIEC61360 "
            f"in {path}, but found none."
        )

    return instance


def load_maximal_data_specification_iec_61360() -> aas_types.DataSpecificationIEC61360:
    """
    Load a maximal example
    of :py:class:`aas_types.DataSpecificationIEC61360`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "DataSpecificationIec61360"
        / "maximal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.DataSpecificationIEC61360] = None

    for something in container.descend():
        if isinstance(something, aas_types.DataSpecificationIEC61360):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of DataSpecificationIEC61360 "
            f"in {path}, but found none."
        )

    return instance


def load_minimal_data_specification_iec_61360() -> aas_types.DataSpecificationIEC61360:
    """
    Load a minimal example
    of :py:class:`aas_types.DataSpecificationIEC61360`
    from :py:attr:`tests.common.TEST_DATA_DIR`.
    """
    path = (
        tests.common.TEST_DATA_DIR
        / "Json"
        / "ContainedInEnvironment"
        / "Expected"
        / "DataSpecificationIec61360"
        / "minimal.json"
    )

    with path.open("rt") as fid:
        try:
            jsonable = json.load(fid)
        except json.decoder.JSONDecodeError as exception:
            raise AssertionError(
                f"Unexpected non-JSON content in {path}"
            ) from exception

    container = aas_jsonization.environment_from_jsonable(jsonable)

    instance: Optional[aas_types.DataSpecificationIEC61360] = None

    for something in container.descend():
        if isinstance(something, aas_types.DataSpecificationIEC61360):
            # We pick the least deep instance, so that we can also test for
            # nested instances *etc.*
            instance = something
            break

    if instance is None:
        raise AssertionError(
            f"Expected to find an instance of DataSpecificationIEC61360 "
            f"in {path}, but found none."
        )

    return instance


# This code has been automatically generated by:
# dev_scripts/test_codegen/generate_common_jsonization.py
# Do NOT edit or append.
