# Path: releasetool/commands/tag/java.py
# def _parse_release_tag(output: str) -> str:
#     match = re.search("creating release (v.*)", output)
#     if match:
#         return match[1]
#     return None
# 
# def kokoro_job_name(upstream_repo: str, package_name: str) -> Union[str, None]:
#     """Return the Kokoro job name.
# 
#     Args:
#         upstream_repo (str): The GitHub repo in the form of `<owner>/<repo>`
#         package_name (str): The name of package to release
# 
#     Returns:
#         The name of the Kokoro job to trigger or None if there is no job to trigger
#     """
#     repo_short_name = upstream_repo.split("/")[-1]
#     return f"cloud-devrel/client-libraries/java/{repo_short_name}/release/stage"
# 
# def package_name(pull: dict) -> Union[str, None]:
#     return None


from releasetool.commands.tag.java import (
    _parse_release_tag,
    kokoro_job_name,
    package_name,
)
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


RELEASE_PLEASE_OUTPUT = """
✔ creating release v1.20.0
✔ Created release: https://github.com/googleapis/java-bigtable/releases/tag/v1.20.0.
✔ adding comment to https://github.com/googleapis/java-bigtable/issue/610
✔ adding label autorelease: tagged to https://github.com/googleapis/java-bigtable/pull/610
✔ removing label autorelease: pending from 610
"""


def test_releasetool_release_tag():
    expected = "v1.20.0"

# Path: releasetool/commands/tag/java.py
# def _parse_release_tag(output: str) -> str:
#     match = re.search("creating release (v.*)", output)
#     if match:
#         return match[1]
#     return None
# 
# def kokoro_job_name(upstream_repo: str, package_name: str) -> Union[str, None]:
#     """Return the Kokoro job name.
# 
#     Args:
#         upstream_repo (str): The GitHub repo in the form of `<owner>/<repo>`
#         package_name (str): The name of package to release
# 
#     Returns:
#         The name of the Kokoro job to trigger or None if there is no job to trigger
#     """
#     repo_short_name = upstream_repo.split("/")[-1]
#     return f"cloud-devrel/client-libraries/java/{repo_short_name}/release/stage"
# 
# def package_name(pull: dict) -> Union[str, None]:
#     return None


# Path: tests/commands/tag/test_tag_java.py
from releasetool.commands.tag.java import (
    _parse_release_tag,
    kokoro_job_name,
    package_name,
)

# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


RELEASE_PLEASE_OUTPUT = """
✔ creating release v1.20.0
✔ Created release: https://github.com/googleapis/java-bigtable/releases/tag/v1.20.0.
✔ adding comment to https://github.com/googleapis/java-bigtable/issue/610
✔ adding label autorelease: tagged to https://github.com/googleapis/java-bigtable/pull/610
✔ removing label autorelease: pending from 610
"""


def test_releasetool_release_tag():
    expected = "v1.20.0"

    assert _parse_release_tag(RELEASE_PLEASE_OUTPUT) == expected