Skip to content

Commit a3a4b71

Browse files
committed
chore: add baseline storage golden files
1 parent 36594fa commit a3a4b71

16 files changed

Lines changed: 2655 additions & 0 deletions

test/integration/BUILD.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ INTEGRATION_TEST_LIBRARIES = [
3030
"pubsub", # Special=case handling for "_deleted-topic_" resource name patterns.
3131
"logging", # Java package remapping in gapic.yaml.
3232
"redis", # Has a gapic.yaml.
33+
"storage", # Exercises storage-specific edge cases.
3334
"library", # No gRPC service config.
3435
"compute", # REGAPIC test.
3536
]
@@ -43,6 +44,7 @@ API_GAPIC_TARGETS = {
4344
"pubsub": ":pubsub_java_gapic",
4445
"logging": "@com_google_googleapis//google/logging/v2:logging_java_gapic",
4546
"redis": "@com_google_googleapis//google/cloud/redis/v1beta1:redis_java_gapic",
47+
"storage": "@com_google_googleapis//google/storage/v2:storage_java_gapic",
4648
"library": "@com_google_googleapis//google/example/library/v1:library_java_gapic",
4749
"compute": "@com_google_googleapis_discovery//google/cloud/compute/v1:compute_small_java_gapic",
4850
}
@@ -100,6 +102,25 @@ java_gapic_assembly_gradle_pkg(
100102
],
101103
)
102104

105+
# Storage API.
106+
java_gapic_test(
107+
name = "storage_java_gapic_test_suite",
108+
test_classes = [
109+
"com.google.storage.v2.StorageClientTest",
110+
],
111+
runtime_deps = ["@com_google_googleapis//google/storage/v2:storage_java_gapic_test"],
112+
)
113+
114+
java_gapic_assembly_gradle_pkg(
115+
name = "google-cloud-storage-v2-java",
116+
deps = [
117+
"@com_google_googleapis//google/storage/v2:storage_java_gapic",
118+
"@com_google_googleapis//google/storage/v2:storage_java_grpc",
119+
"@com_google_googleapis//google/storage/v2:storage_java_proto",
120+
"@com_google_googleapis//google/storage/v2:storage_proto",
121+
],
122+
)
123+
103124
# Logging API
104125
java_gapic_test(
105126
name = "logging_java_gapic_test_suite",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
filegroup(
4+
name = "goldens_files",
5+
srcs = glob(
6+
["**/*"],
7+
exclude = [
8+
"BUILD.bazel",
9+
".*.sw*",
10+
],
11+
),
12+
)
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.storage.v2;
18+
19+
import com.google.api.pathtemplate.PathTemplate;
20+
import com.google.api.resourcenames.ResourceName;
21+
import com.google.common.base.Preconditions;
22+
import com.google.common.collect.ImmutableMap;
23+
import java.util.ArrayList;
24+
import java.util.List;
25+
import java.util.Map;
26+
import java.util.Objects;
27+
import javax.annotation.Generated;
28+
29+
// AUTO-GENERATED DOCUMENTATION AND CLASS.
30+
@Generated("by gapic-generator-java")
31+
public class BucketName implements ResourceName {
32+
private static final PathTemplate PROJECT_BUCKET =
33+
PathTemplate.createWithoutUrlEncoding("projects/{project}/buckets/{bucket}");
34+
private volatile Map<String, String> fieldValuesMap;
35+
private final String project;
36+
private final String bucket;
37+
38+
@Deprecated
39+
protected BucketName() {
40+
project = null;
41+
bucket = null;
42+
}
43+
44+
private BucketName(Builder builder) {
45+
project = Preconditions.checkNotNull(builder.getProject());
46+
bucket = Preconditions.checkNotNull(builder.getBucket());
47+
}
48+
49+
public String getProject() {
50+
return project;
51+
}
52+
53+
public String getBucket() {
54+
return bucket;
55+
}
56+
57+
public static Builder newBuilder() {
58+
return new Builder();
59+
}
60+
61+
public Builder toBuilder() {
62+
return new Builder(this);
63+
}
64+
65+
public static BucketName of(String project, String bucket) {
66+
return newBuilder().setProject(project).setBucket(bucket).build();
67+
}
68+
69+
public static String format(String project, String bucket) {
70+
return newBuilder().setProject(project).setBucket(bucket).build().toString();
71+
}
72+
73+
public static BucketName parse(String formattedString) {
74+
if (formattedString.isEmpty()) {
75+
return null;
76+
}
77+
Map<String, String> matchMap =
78+
PROJECT_BUCKET.validatedMatch(
79+
formattedString, "BucketName.parse: formattedString not in valid format");
80+
return of(matchMap.get("project"), matchMap.get("bucket"));
81+
}
82+
83+
public static List<BucketName> parseList(List<String> formattedStrings) {
84+
List<BucketName> list = new ArrayList<>(formattedStrings.size());
85+
for (String formattedString : formattedStrings) {
86+
list.add(parse(formattedString));
87+
}
88+
return list;
89+
}
90+
91+
public static List<String> toStringList(List<BucketName> values) {
92+
List<String> list = new ArrayList<>(values.size());
93+
for (BucketName value : values) {
94+
if (value == null) {
95+
list.add("");
96+
} else {
97+
list.add(value.toString());
98+
}
99+
}
100+
return list;
101+
}
102+
103+
public static boolean isParsableFrom(String formattedString) {
104+
return PROJECT_BUCKET.matches(formattedString);
105+
}
106+
107+
@Override
108+
public Map<String, String> getFieldValuesMap() {
109+
if (fieldValuesMap == null) {
110+
synchronized (this) {
111+
if (fieldValuesMap == null) {
112+
ImmutableMap.Builder<String, String> fieldMapBuilder = ImmutableMap.builder();
113+
if (project != null) {
114+
fieldMapBuilder.put("project", project);
115+
}
116+
if (bucket != null) {
117+
fieldMapBuilder.put("bucket", bucket);
118+
}
119+
fieldValuesMap = fieldMapBuilder.build();
120+
}
121+
}
122+
}
123+
return fieldValuesMap;
124+
}
125+
126+
public String getFieldValue(String fieldName) {
127+
return getFieldValuesMap().get(fieldName);
128+
}
129+
130+
@Override
131+
public String toString() {
132+
return PROJECT_BUCKET.instantiate("project", project, "bucket", bucket);
133+
}
134+
135+
@Override
136+
public boolean equals(Object o) {
137+
if (o == this) {
138+
return true;
139+
}
140+
if (o != null || getClass() == o.getClass()) {
141+
BucketName that = ((BucketName) o);
142+
return Objects.equals(this.project, that.project) && Objects.equals(this.bucket, that.bucket);
143+
}
144+
return false;
145+
}
146+
147+
@Override
148+
public int hashCode() {
149+
int h = 1;
150+
h *= 1000003;
151+
h ^= Objects.hashCode(project);
152+
h *= 1000003;
153+
h ^= Objects.hashCode(bucket);
154+
return h;
155+
}
156+
157+
/** Builder for projects/{project}/buckets/{bucket}. */
158+
public static class Builder {
159+
private String project;
160+
private String bucket;
161+
162+
protected Builder() {}
163+
164+
public String getProject() {
165+
return project;
166+
}
167+
168+
public String getBucket() {
169+
return bucket;
170+
}
171+
172+
public Builder setProject(String project) {
173+
this.project = project;
174+
return this;
175+
}
176+
177+
public Builder setBucket(String bucket) {
178+
this.bucket = bucket;
179+
return this;
180+
}
181+
182+
private Builder(BucketName bucketName) {
183+
this.project = bucketName.project;
184+
this.bucket = bucketName.bucket;
185+
}
186+
187+
public BucketName build() {
188+
return new BucketName(this);
189+
}
190+
}
191+
}

0 commit comments

Comments
 (0)