Skip to content

Commit 57d35de

Browse files
committed
Update spi classes to use gax 0.7.0
1 parent fac54b9 commit 57d35de

26 files changed

Lines changed: 302 additions & 88 deletions

File tree

google-cloud-errorreporting/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
</parent>
1616
<properties>
1717
<site.installationModule>google-cloud-errorreporting</site.installationModule>
18+
<artifact.version>${project.version}</artifact.version>
1819
</properties>
1920
<dependencies>
2021
<dependency>
@@ -87,6 +88,22 @@
8788
</profiles>
8889
<build>
8990
<plugins>
91+
<plugin>
92+
<groupId>org.codehaus.mojo</groupId>
93+
<artifactId>properties-maven-plugin</artifactId>
94+
<version>1.0-alpha-2</version>
95+
<executions>
96+
<execution>
97+
<phase>generate-resources</phase>
98+
<goals>
99+
<goal>write-project-properties</goal>
100+
</goals>
101+
<configuration>
102+
<outputFile>${project.build.outputDirectory}/project.properties</outputFile>
103+
</configuration>
104+
</execution>
105+
</executions>
106+
</plugin>
90107
<plugin>
91108
<groupId>org.codehaus.mojo</groupId>
92109
<artifactId>build-helper-maven-plugin</artifactId>

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceSettings.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.google.cloud.errorreporting.spi.v1beta1;
1717

1818
import com.google.api.gax.core.GoogleCredentialsProvider;
19+
import com.google.api.gax.core.PropertiesProvider;
1920
import com.google.api.gax.core.RetrySettings;
2021
import com.google.api.gax.grpc.ChannelProvider;
2122
import com.google.api.gax.grpc.ClientSettings;
@@ -82,6 +83,11 @@ public class ErrorGroupServiceSettings extends ClientSettings {
8283
private static final String DEFAULT_GAPIC_NAME = "gapic";
8384
private static final String DEFAULT_GAPIC_VERSION = "";
8485

86+
private static final String PROPERTIES_FILE = "/project.properties";
87+
private static final String META_VERSION_KEY = "artifact.version";
88+
89+
private static String gapicVersion;
90+
8591
private final SimpleCallSettings<GetGroupRequest, ErrorGroup> getGroupSettings;
8692
private final SimpleCallSettings<UpdateGroupRequest, ErrorGroup> updateGroupSettings;
8793

@@ -130,8 +136,13 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
130136
}
131137

132138
private static String getGapicVersion() {
133-
String packageVersion = ErrorGroupServiceSettings.class.getPackage().getImplementationVersion();
134-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
139+
if (gapicVersion == null) {
140+
gapicVersion =
141+
PropertiesProvider.loadProperty(
142+
ErrorGroupServiceSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
143+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
144+
}
145+
return gapicVersion;
135146
}
136147

137148
/** Returns a builder for this class with recommended defaults. */

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceSettings.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListGroupStatsPagedResponse;
2020

2121
import com.google.api.gax.core.GoogleCredentialsProvider;
22+
import com.google.api.gax.core.PropertiesProvider;
2223
import com.google.api.gax.core.RetrySettings;
2324
import com.google.api.gax.grpc.CallContext;
2425
import com.google.api.gax.grpc.ChannelProvider;
@@ -95,6 +96,11 @@ public class ErrorStatsServiceSettings extends ClientSettings {
9596
private static final String DEFAULT_GAPIC_NAME = "gapic";
9697
private static final String DEFAULT_GAPIC_VERSION = "";
9798

99+
private static final String PROPERTIES_FILE = "/project.properties";
100+
private static final String META_VERSION_KEY = "artifact.version";
101+
102+
private static String gapicVersion;
103+
98104
private final PagedCallSettings<
99105
ListGroupStatsRequest, ListGroupStatsResponse, ListGroupStatsPagedResponse>
100106
listGroupStatsSettings;
@@ -155,8 +161,13 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
155161
}
156162

157163
private static String getGapicVersion() {
158-
String packageVersion = ErrorStatsServiceSettings.class.getPackage().getImplementationVersion();
159-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
164+
if (gapicVersion == null) {
165+
gapicVersion =
166+
PropertiesProvider.loadProperty(
167+
ErrorStatsServiceSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
168+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
169+
}
170+
return gapicVersion;
160171
}
161172

162173
/** Returns a builder for this class with recommended defaults. */

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceSettings.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.google.cloud.errorreporting.spi.v1beta1;
1717

1818
import com.google.api.gax.core.GoogleCredentialsProvider;
19+
import com.google.api.gax.core.PropertiesProvider;
1920
import com.google.api.gax.core.RetrySettings;
2021
import com.google.api.gax.grpc.ChannelProvider;
2122
import com.google.api.gax.grpc.ClientSettings;
@@ -81,6 +82,11 @@ public class ReportErrorsServiceSettings extends ClientSettings {
8182
private static final String DEFAULT_GAPIC_NAME = "gapic";
8283
private static final String DEFAULT_GAPIC_VERSION = "";
8384

85+
private static final String PROPERTIES_FILE = "/project.properties";
86+
private static final String META_VERSION_KEY = "artifact.version";
87+
88+
private static String gapicVersion;
89+
8490
private final SimpleCallSettings<ReportErrorEventRequest, ReportErrorEventResponse>
8591
reportErrorEventSettings;
8692

@@ -125,9 +131,13 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
125131
}
126132

127133
private static String getGapicVersion() {
128-
String packageVersion =
129-
ReportErrorsServiceSettings.class.getPackage().getImplementationVersion();
130-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
134+
if (gapicVersion == null) {
135+
gapicVersion =
136+
PropertiesProvider.loadProperty(
137+
ReportErrorsServiceSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
138+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
139+
}
140+
return gapicVersion;
131141
}
132142

133143
/** Returns a builder for this class with recommended defaults. */

google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void getGroupTest() {
100100
@Test
101101
@SuppressWarnings("all")
102102
public void getGroupExceptionTest() throws Exception {
103-
StatusRuntimeException exception = new StatusRuntimeException(Status.INTERNAL);
103+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
104104
mockErrorGroupService.addException(exception);
105105

106106
try {
@@ -109,7 +109,7 @@ public void getGroupExceptionTest() throws Exception {
109109
client.getGroup(groupName);
110110
Assert.fail("No exception raised");
111111
} catch (ApiException e) {
112-
Assert.assertEquals(Status.INTERNAL.getCode(), e.getStatusCode());
112+
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
113113
}
114114
}
115115

@@ -137,7 +137,7 @@ public void updateGroupTest() {
137137
@Test
138138
@SuppressWarnings("all")
139139
public void updateGroupExceptionTest() throws Exception {
140-
StatusRuntimeException exception = new StatusRuntimeException(Status.INTERNAL);
140+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
141141
mockErrorGroupService.addException(exception);
142142

143143
try {
@@ -146,7 +146,7 @@ public void updateGroupExceptionTest() throws Exception {
146146
client.updateGroup(group);
147147
Assert.fail("No exception raised");
148148
} catch (ApiException e) {
149-
Assert.assertEquals(Status.INTERNAL.getCode(), e.getStatusCode());
149+
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
150150
}
151151
}
152152
}

google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceClientTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void listGroupStatsTest() {
119119
@Test
120120
@SuppressWarnings("all")
121121
public void listGroupStatsExceptionTest() throws Exception {
122-
StatusRuntimeException exception = new StatusRuntimeException(Status.INTERNAL);
122+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
123123
mockErrorStatsService.addException(exception);
124124

125125
try {
@@ -129,7 +129,7 @@ public void listGroupStatsExceptionTest() throws Exception {
129129
client.listGroupStats(projectName, timeRange);
130130
Assert.fail("No exception raised");
131131
} catch (ApiException e) {
132-
Assert.assertEquals(Status.INTERNAL.getCode(), e.getStatusCode());
132+
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
133133
}
134134
}
135135

@@ -166,7 +166,7 @@ public void listEventsTest() {
166166
@Test
167167
@SuppressWarnings("all")
168168
public void listEventsExceptionTest() throws Exception {
169-
StatusRuntimeException exception = new StatusRuntimeException(Status.INTERNAL);
169+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
170170
mockErrorStatsService.addException(exception);
171171

172172
try {
@@ -176,7 +176,7 @@ public void listEventsExceptionTest() throws Exception {
176176
client.listEvents(projectName, groupId);
177177
Assert.fail("No exception raised");
178178
} catch (ApiException e) {
179-
Assert.assertEquals(Status.INTERNAL.getCode(), e.getStatusCode());
179+
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
180180
}
181181
}
182182

@@ -201,7 +201,7 @@ public void deleteEventsTest() {
201201
@Test
202202
@SuppressWarnings("all")
203203
public void deleteEventsExceptionTest() throws Exception {
204-
StatusRuntimeException exception = new StatusRuntimeException(Status.INTERNAL);
204+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
205205
mockErrorStatsService.addException(exception);
206206

207207
try {
@@ -210,7 +210,7 @@ public void deleteEventsExceptionTest() throws Exception {
210210
client.deleteEvents(projectName);
211211
Assert.fail("No exception raised");
212212
} catch (ApiException e) {
213-
Assert.assertEquals(Status.INTERNAL.getCode(), e.getStatusCode());
213+
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
214214
}
215215
}
216216
}

google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceClientTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void reportErrorEventTest() {
9999
@Test
100100
@SuppressWarnings("all")
101101
public void reportErrorEventExceptionTest() throws Exception {
102-
StatusRuntimeException exception = new StatusRuntimeException(Status.INTERNAL);
102+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
103103
mockReportErrorsService.addException(exception);
104104

105105
try {
@@ -109,7 +109,7 @@ public void reportErrorEventExceptionTest() throws Exception {
109109
client.reportErrorEvent(projectName, event);
110110
Assert.fail("No exception raised");
111111
} catch (ApiException e) {
112-
Assert.assertEquals(Status.INTERNAL.getCode(), e.getStatusCode());
112+
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
113113
}
114114
}
115115
}

google-cloud-language/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
</parent>
1616
<properties>
1717
<site.installationModule>google-cloud-language</site.installationModule>
18+
<artifact.version>${project.version}</artifact.version>
1819
</properties>
1920
<dependencies>
2021
<dependency>
@@ -87,6 +88,22 @@
8788
</profiles>
8889
<build>
8990
<plugins>
91+
<plugin>
92+
<groupId>org.codehaus.mojo</groupId>
93+
<artifactId>properties-maven-plugin</artifactId>
94+
<version>1.0-alpha-2</version>
95+
<executions>
96+
<execution>
97+
<phase>generate-resources</phase>
98+
<goals>
99+
<goal>write-project-properties</goal>
100+
</goals>
101+
<configuration>
102+
<outputFile>${project.build.outputDirectory}/project.properties</outputFile>
103+
</configuration>
104+
</execution>
105+
</executions>
106+
</plugin>
90107
<plugin>
91108
<groupId>org.codehaus.mojo</groupId>
92109
<artifactId>build-helper-maven-plugin</artifactId>

google-cloud-logging/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
</parent>
1717
<properties>
1818
<site.installationModule>google-cloud-logging</site.installationModule>
19+
<artifact.version>${project.version}</artifact.version>
1920
</properties>
2021
<dependencies>
2122
<dependency>
@@ -88,6 +89,22 @@
8889
</profiles>
8990
<build>
9091
<plugins>
92+
<plugin>
93+
<groupId>org.codehaus.mojo</groupId>
94+
<artifactId>properties-maven-plugin</artifactId>
95+
<version>1.0-alpha-2</version>
96+
<executions>
97+
<execution>
98+
<phase>generate-resources</phase>
99+
<goals>
100+
<goal>write-project-properties</goal>
101+
</goals>
102+
<configuration>
103+
<outputFile>${project.build.outputDirectory}/project.properties</outputFile>
104+
</configuration>
105+
</execution>
106+
</executions>
107+
</plugin>
91108
<plugin>
92109
<groupId>org.codehaus.mojo</groupId>
93110
<artifactId>build-helper-maven-plugin</artifactId>

google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigSettings.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListSinksPagedResponse;
1919

2020
import com.google.api.gax.core.GoogleCredentialsProvider;
21+
import com.google.api.gax.core.PropertiesProvider;
2122
import com.google.api.gax.core.RetrySettings;
2223
import com.google.api.gax.grpc.CallContext;
2324
import com.google.api.gax.grpc.ChannelProvider;
@@ -99,6 +100,11 @@ public class ConfigSettings extends ClientSettings {
99100
private static final String DEFAULT_GAPIC_NAME = "gapic";
100101
private static final String DEFAULT_GAPIC_VERSION = "";
101102

103+
private static final String PROPERTIES_FILE = "/project.properties";
104+
private static final String META_VERSION_KEY = "artifact.version";
105+
106+
private static String gapicVersion;
107+
102108
private final PagedCallSettings<ListSinksRequest, ListSinksResponse, ListSinksPagedResponse>
103109
listSinksSettings;
104110
private final SimpleCallSettings<GetSinkRequest, LogSink> getSinkSettings;
@@ -167,8 +173,12 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
167173
}
168174

169175
private static String getGapicVersion() {
170-
String packageVersion = ConfigSettings.class.getPackage().getImplementationVersion();
171-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
176+
if (gapicVersion == null) {
177+
gapicVersion =
178+
PropertiesProvider.loadProperty(ConfigSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
179+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
180+
}
181+
return gapicVersion;
172182
}
173183

174184
/** Returns a builder for this class with recommended defaults. */

0 commit comments

Comments
 (0)