Skip to content

Commit

Permalink
Merge branch 'main' into directpath-compatible-getter
Browse files Browse the repository at this point in the history
  • Loading branch information
lqiu96 authored May 28, 2024
2 parents f2f9f39 + 0442df6 commit b272ba4
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.Set;
import java.util.stream.Stream;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -302,7 +301,6 @@ void complexResourceIdEqualsWildcard() {
}

@Test
@Disabled("https://github.com/googleapis/sdk-platform-java/issues/2778")
void complexResourceIdEqualsPathWildcard() {
Exception exception =
Assertions.assertThrows(
Expand All @@ -312,15 +310,6 @@ void complexResourceIdEqualsPathWildcard() {
String.format(
"parse error: wildcard path not allowed in complex ID resource '%s'", "zone_a"),
exception.getMessage());

exception =
Assertions.assertThrows(
ValidationException.class,
() -> PathTemplate.create("projects/{project=*}/zones/{zone_a}.{zone_b=**}"));
Assertions.assertEquals(
String.format(
"parse error: wildcard path not allowed in complex ID resource '%s'", "zone_b"),
exception.getMessage());
}

@Test
Expand Down Expand Up @@ -360,9 +349,18 @@ void complexResourceIdNoSeparator() {
"parse error: missing or 2+ consecutive delimiter characters in '%s'",
"{zone_a}_{zone_b}{zone_c}"),
exception.getMessage());

exception =
Assertions.assertThrows(
ValidationException.class,
() -> PathTemplate.create("projects/{project=*}/zones/{zone_a}{{zone_b}"));
Assertions.assertEquals(
String.format(
"parse error: missing or 2+ consecutive delimiter characters in '%s'",
"{zone_a}{{zone_b}"),
exception.getMessage());
}

@Disabled("https://github.com/googleapis/sdk-platform-java/issues/2776")
@ParameterizedTest
@MethodSource("invalidDelimiters")
void complexResourceIdInvalidDelimiter(String invalidDelimiter) {
Expand All @@ -381,7 +379,7 @@ void complexResourceIdInvalidDelimiter(String invalidDelimiter) {
}

static Stream<String> invalidDelimiters() {
return Stream.of("|", "!", "@", "a", "1", ",", "{", ")");
return Stream.of("|", "!", "@", "a", "1", ",", ")");
}

@Test
Expand Down
14 changes: 0 additions & 14 deletions generation_config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
gapic_generator_version: 2.40.2-SNAPSHOT # {x-version-update:gapic-generator-java:current}
googleapis_commitish: 3d50414a7ff3f0b8ffe8ad7858257396e4f18131
template_excludes:
- .github/*
- .kokoro/*
- samples/*
- CODE_OF_CONDUCT.md
- CONTRIBUTING.md
- LICENSE
- SECURITY.md
- java.header
- license-checks.xml
- README.md
- renovate.json
- .gitignore

# the libraries are ordered with respect to library name, which is
# java-{library.library_name} or java-{library.api-shortname} when
# library.library_name is not defined.
Expand Down
16 changes: 1 addition & 15 deletions library_generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ They are shared by library level parameters.
| protoc_version | No | inferred from the generator if not specified |
| grpc_version | No | inferred from the generator if not specified |
| googleapis-commitish | Yes | |
| libraries_bom_version | Yes | |
| template_excludes | Yes | |
| libraries_bom_version | No | empty string if not specified |

### Library level parameters

Expand Down Expand Up @@ -147,19 +146,6 @@ gapic_generator_version: 2.34.0
protoc_version: 25.2
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
destination_path: google-cloud-java
template_excludes:
- ".github/*"
- ".kokoro/*"
- "samples/*"
- "CODE_OF_CONDUCT.md"
- "CONTRIBUTING.md"
- "LICENSE"
- "SECURITY.md"
- "java.header"
- "license-checks.xml"
- "renovate.json"
- ".gitignore"
libraries:
- api_shortname: apigeeconnect
name_pretty: Apigee Connect
Expand Down
7 changes: 3 additions & 4 deletions library_generation/model/generation_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ def __init__(
self,
gapic_generator_version: str,
googleapis_commitish: str,
template_excludes: list[str],
libraries: list[LibraryConfig],
libraries_bom_version: Optional[str] = None,
grpc_version: Optional[str] = None,
protoc_version: Optional[str] = None,
):
self.gapic_generator_version = gapic_generator_version
self.googleapis_commitish = googleapis_commitish
self.libraries_bom_version = libraries_bom_version
self.template_excludes = template_excludes
self.libraries_bom_version = (
libraries_bom_version if libraries_bom_version else ""
)
self.libraries = libraries
self.grpc_version = grpc_version
self.protoc_version = protoc_version
Expand Down Expand Up @@ -149,7 +149,6 @@ def from_yaml(path_to_yaml: str) -> GenerationConfig:
googleapis_commitish=__required(
config, "googleapis_commitish", REPO_LEVEL_PARAMETER
),
template_excludes=__required(config, "template_excludes", REPO_LEVEL_PARAMETER),
grpc_version=__optional(config, "grpc_version", None),
protoc_version=__optional(config, "protoc_version", None),
libraries_bom_version=__optional(config, "libraries_bom_version", None),
Expand Down
3 changes: 0 additions & 3 deletions library_generation/test/generate_pr_description_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def test_generate_pr_description_with_same_googleapis_commits(self):
config=GenerationConfig(
gapic_generator_version="",
googleapis_commitish=commit_sha,
libraries_bom_version="",
template_excludes=[],
grpc_version="",
protoc_version="",
libraries=[],
Expand All @@ -84,7 +82,6 @@ def test_generate_pr_description_does_not_create_pr_description_without_qualifie
gapic_generator_version="",
googleapis_commitish=new_commit_sha,
libraries_bom_version="",
template_excludes=[],
grpc_version="",
protoc_version="",
# use empty libraries to make sure no qualified commit between
Expand Down
2 changes: 0 additions & 2 deletions library_generation/test/generate_repo_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def __get_an_empty_generation_config() -> GenerationConfig:
return GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[],
)

Expand Down
2 changes: 0 additions & 2 deletions library_generation/test/model/config_change_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ def __get_a_gen_config(
return GenerationConfig(
gapic_generator_version="",
googleapis_commitish=googleapis_commitish,
libraries_bom_version="",
template_excludes=[],
grpc_version="",
protoc_version="",
libraries=libraries,
Expand Down
42 changes: 8 additions & 34 deletions library_generation/test/model/generation_config_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@


class GenerationConfigTest(unittest.TestCase):
def test_generation_config_default_value(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries=[],
)
self.assertEqual("", config.libraries_bom_version)

def test_from_yaml_succeeds(self):
config = from_yaml(f"{test_config_dir}/generation_config.yaml")
self.assertEqual("2.34.0", config.gapic_generator_version)
Expand All @@ -53,22 +61,6 @@ def test_from_yaml_succeeds(self):
"1a45bf7393b52407188c82e63101db7dc9c72026", config.googleapis_commitish
)
self.assertEqual("26.37.0", config.libraries_bom_version)
self.assertEqual(
[
".github/*",
".kokoro/*",
"samples/*",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"LICENSE",
"SECURITY.md",
"java.header",
"license-checks.xml",
"renovate.json",
".gitignore",
],
config.template_excludes,
)
library = config.libraries[0]
self.assertEqual("cloudasset", library.api_shortname)
self.assertEqual("Cloud Asset Inventory", library.name_pretty)
Expand Down Expand Up @@ -114,8 +106,6 @@ def test_is_monorepo_with_one_library_returns_false(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[library_1],
)
self.assertFalse(config.is_monorepo())
Expand All @@ -124,8 +114,6 @@ def test_is_monorepo_with_two_libraries_returns_true(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[library_1, library_2],
)
self.assertTrue(config.is_monorepo())
Expand All @@ -134,8 +122,6 @@ def test_contains_common_protos_with_common_protos_returns_true(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[library_1, library_2, common_protos_library],
)
self.assertTrue(config.contains_common_protos())
Expand All @@ -144,8 +130,6 @@ def test_contains_common_protos_without_common_protos_returns_false(self):
config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[library_1, library_2],
)
self.assertFalse(config.contains_common_protos())
Expand All @@ -157,8 +141,6 @@ def test_validate_with_duplicate_library_name_raise_exception(self):
GenerationConfig,
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
libraries=[
LibraryConfig(
api_shortname="secretmanager",
Expand Down Expand Up @@ -194,14 +176,6 @@ def test_from_yaml_without_googleapis_commitish_raise_exception(self):
f"{test_config_dir}/config_without_googleapis.yaml",
)

def test_from_yaml_without_template_excludes_raise_exception(self):
self.assertRaisesRegex(
ValueError,
"Repo level parameter, template_excludes",
from_yaml,
f"{test_config_dir}/config_without_temp_excludes.yaml",
)

def test_from_yaml_without_libraries_raise_exception(self):
self.assertRaisesRegex(
ValueError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ gapic_generator_version: 2.38.1
protoc_version: 25.2
googleapis_commitish: a17d4caf184b050d50cacf2b0d579ce72c31ce74
libraries_bom_version: 26.37.0
template_excludes:
- ".github/*"
- ".kokoro/*"
- "samples/*"
- "CODE_OF_CONDUCT.md"
- "CONTRIBUTING.md"
- "LICENSE"
- "SECURITY.md"
- "java.header"
- "license-checks.xml"
- "renovate.json"
- ".gitignore"
libraries:
- api_shortname: apigeeconnect
name_pretty: Apigee Connect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ gapic_generator_version: 2.38.1
protoc_version: 25.2
googleapis_commitish: 4ce0ff67a3d4509be641cbe47a35844ddc1268fc
libraries_bom_version: 26.37.0
template_excludes:
- ".github/*"
- ".kokoro/*"
- "samples/*"
- "CODE_OF_CONDUCT.md"
- "CONTRIBUTING.md"
- "LICENSE"
- "SECURITY.md"
- "java.header"
- "license-checks.xml"
- "renovate.json"
- ".gitignore"
libraries:
- api_shortname: apigeeconnect
name_pretty: Apigee Connect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
gapic_generator_version: 2.37.0
protoc_version: 25.2
googleapis_commitish: 9868a57470a969ffa1d21194a5c05d7a6e4e98cc
template_excludes:
- ".gitignore"
- ".kokoro/presubmit/integration.cfg"
- ".kokoro/presubmit/graalvm-native.cfg"
- ".kokoro/presubmit/graalvm-native-17.cfg"
- ".kokoro/nightly/integration.cfg"
- ".kokoro/presubmit/samples.cfg"
- ".kokoro/nightly/samples.cfg"
- ".github/ISSUE_TEMPLATE/bug_report.md"
- ".github/PULL_REQUEST_TEMPLATE.md"
- "CONTRIBUTING.md"
- "codecov.yaml"
- ".github/release-please.yml"
- "renovate.json"
- ".kokoro/requirements.in"
- ".kokoro/requirements.txt"
libraries:
- api_shortname: bigtable
name_pretty: Cloud Bigtable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ gapic_generator_version: 2.34.0
protoc_version: 25.2
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
libraries_bom_version: 26.37.0
template_excludes:
- ".github/*"
- ".kokoro/*"
- "samples/*"
- "CODE_OF_CONDUCT.md"
- "CONTRIBUTING.md"
- "LICENSE"
- "SECURITY.md"
- "java.header"
- "license-checks.xml"
- "renovate.json"
- ".gitignore"
libraries:
- api_shortname: cloudasset
name_pretty: Cloud Asset Inventory
Expand Down
14 changes: 0 additions & 14 deletions library_generation/test/utilities_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,20 +315,6 @@ def __get_a_gen_config(
return GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[
".github/*",
".kokoro/*",
"samples/*",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"LICENSE",
"SECURITY.md",
"java.header",
"license-checks.xml",
"renovate.json",
".gitignore",
],
libraries=libraries,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,13 @@ def setUp(self) -> None:
self.baseline_config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
grpc_version="",
protoc_version="",
libraries=[self.baseline_library],
)
self.current_config = GenerationConfig(
gapic_generator_version="",
googleapis_commitish="",
libraries_bom_version="",
template_excludes=[],
grpc_version="",
protoc_version="",
libraries=[self.current_library],
Expand Down
Loading

0 comments on commit b272ba4

Please sign in to comment.