Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate to owlbot #1458

Merged
merged 4 commits into from Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/.OwlBot.lock.yaml
@@ -0,0 +1,3 @@
docker:
digest: sha256:db1616f2f70823d8381d859835229e04371d14f59ac78063c5af73c55c3fffbb
image: gcr.io/repo-automation-bots/owlbot-java:latest
14 changes: 3 additions & 11 deletions synth.py → .github/.OwlBot.yaml
@@ -1,4 +1,4 @@
# Copyright 2019 Google LLC
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,14 +11,6 @@
# 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.
"""This script is used to synthesize generated parts of this library."""

import synthtool.languages.java as java

java.common_templates(excludes=[
"README.md",
"java.header",
"checkstyle.xml",
"license-checks.xml",
".github/workflows/samples.yaml",
])
docker:
image: "gcr.io/repo-automation-bots/owlbot-java:latest"
Expand Up @@ -15,7 +15,6 @@

import com.google.api.client.json.JsonFactory;
import com.google.api.client.test.json.AbstractJsonFactoryTest;

import java.util.ArrayList;

/**
Expand All @@ -24,16 +23,31 @@
* @author Yaniv Inbar
*/
public class AndroidJsonFactoryTest extends AbstractJsonFactoryTest {

private static final String GSON_LINE_SEPARATOR = "\n";

private static final String JSON_ENTRY_PRETTY =
"{" + GSON_LINE_SEPARATOR + " \"title\": \"foo\"" + GSON_LINE_SEPARATOR + "}";
private static final String JSON_FEED_PRETTY = "{" + GSON_LINE_SEPARATOR + " \"entries\": ["
+ GSON_LINE_SEPARATOR + " {" + GSON_LINE_SEPARATOR + " \"title\": \"foo\""
+ GSON_LINE_SEPARATOR + " }," + GSON_LINE_SEPARATOR + " {"
+ GSON_LINE_SEPARATOR + " \"title\": \"bar\"" + GSON_LINE_SEPARATOR + " }"
+ GSON_LINE_SEPARATOR + " ]" + GSON_LINE_SEPARATOR + "}";
private static final String JSON_FEED_PRETTY =
"{"
+ GSON_LINE_SEPARATOR
+ " \"entries\": ["
+ GSON_LINE_SEPARATOR
+ " {"
+ GSON_LINE_SEPARATOR
+ " \"title\": \"foo\""
+ GSON_LINE_SEPARATOR
+ " },"
+ GSON_LINE_SEPARATOR
+ " {"
+ GSON_LINE_SEPARATOR
+ " \"title\": \"bar\""
+ GSON_LINE_SEPARATOR
+ " }"
+ GSON_LINE_SEPARATOR
+ " ]"
+ GSON_LINE_SEPARATOR
+ "}";

public AndroidJsonFactoryTest(String name) {
super(name);
Expand Down Expand Up @@ -61,5 +75,4 @@ public final void testToPrettyString_Feed() throws Exception {
feed.entries.add(entryBar);
assertEquals(JSON_FEED_PRETTY, newFactory().toPrettyString(feed));
}

}
Expand Up @@ -26,6 +26,5 @@ public FakeTest(String name) {
super(name);
}

public final void test() throws Exception {
}
public final void test() throws Exception {}
}
Expand Up @@ -17,6 +17,4 @@
*
* @author Yaniv Inbar
*/

package com.google.api.client.extensions.android.json;

Expand Up @@ -20,8 +20,7 @@
@Beta
public class BetaClass {

public void method() {
}
public void method() {}

@Beta
public void betaMethod() {
Expand All @@ -36,8 +35,7 @@ public BetaClass() {

int field;

@Beta
int betaField;
@Beta int betaField;

@Override
public String toString() {
Expand Down
Expand Up @@ -19,12 +19,10 @@
/** A class which contains {@link Beta} fields. */
public class ClassWithBetaField {

@Beta
public int betaField;
@Beta public int betaField;
public int field;

@Beta
public static final int betaStaticField = 10;
@Beta public static final int betaStaticField = 10;
public static final int staticField = 20;

public ClassWithBetaField() {
Expand Down
Expand Up @@ -19,8 +19,7 @@
/** A class which contains {@link Beta} methods. */
public class ClassWithBetaMethod {

@Beta
int betaField = 10;
@Beta int betaField = 10;

@Beta
public void betaMethod() {
Expand Down
32 changes: 32 additions & 0 deletions owlbot.py
@@ -0,0 +1,32 @@
# Copyright 2021 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.

import synthtool as s
from synthtool.languages import java


for library in s.get_staging_dirs():
# put any special-case replacements here
s.move(library)

s.remove_staging_dirs()
java.common_templates(
excludes=[
"README.md",
"java.header",
"checkstyle.xml",
"license-checks.xml",
".github/workflows/samples.yaml",
]
)
49 changes: 16 additions & 33 deletions samples/snippets/src/main/java/com/example/json/YouTubeSample.java
Expand Up @@ -18,7 +18,6 @@

import com.google.api.client.http.HttpResponse;
import com.google.api.client.util.Key;

import java.io.IOException;
import java.util.List;
import java.util.Map;
Expand All @@ -28,8 +27,7 @@ public static class ListResponse {
@Key("items")
private List<SearchResult> searchResults;

@Key
private PageInfo pageInfo;
@Key private PageInfo pageInfo;

public List<SearchResult> getSearchResults() {
return searchResults;
Expand All @@ -41,11 +39,9 @@ public PageInfo getPageInfo() {
}

public static class PageInfo {
@Key
private long totalResults;
@Key private long totalResults;

@Key
private long resultsPerPage;
@Key private long resultsPerPage;

public long getTotalResults() {
return totalResults;
Expand All @@ -57,14 +53,12 @@ public long getResultsPerPage() {
}

public static class SearchResult {
@Key
private String kind;
@Key private String kind;

@Key("id")
private VideoId videoId;

@Key
private Snippet snippet;
@Key private Snippet snippet;

public String getKind() {
return kind;
Expand All @@ -80,11 +74,9 @@ public Snippet getSnippet() {
}

public static class VideoId {
@Key
private String kind;
@Key private String kind;

@Key
private String videoId;
@Key private String videoId;

public String getKind() {
return kind;
Expand All @@ -96,20 +88,15 @@ public String getVideoId() {
}

public static class Snippet {
@Key
private String publishedAt;
@Key private String publishedAt;

@Key
private String channelId;
@Key private String channelId;

@Key
private String title;
@Key private String title;

@Key
private String description;
@Key private String description;

@Key
private Map<String, Thumbnail> thumbnails;
@Key private Map<String, Thumbnail> thumbnails;

public String getPublishedAt() {
return publishedAt;
Expand All @@ -133,14 +120,11 @@ public Map<String, Thumbnail> getThumbnails() {
}

public static class Thumbnail {
@Key
private String url;
@Key private String url;

@Key
private long width;
@Key private long width;

@Key
private long height;
@Key private long height;

public String getUrl() {
return url;
Expand Down Expand Up @@ -171,5 +155,4 @@ public static ListResponse parseJson(HttpResponse httpResponse) throws IOExcepti
}
return listResponse;
}

}
}
Expand Up @@ -19,10 +19,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import org.junit.Test;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
Expand All @@ -36,12 +32,17 @@
import com.google.api.client.testing.http.MockLowLevelHttpRequest;
import com.google.api.client.testing.http.MockLowLevelHttpResponse;
import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import org.junit.Test;

public class YouTubeSampleTest {

@Test
public void testParsing() throws IOException {
final InputStream contents = getClass().getClassLoader().getResourceAsStream("youtube-search.json");
final InputStream contents =
getClass().getClassLoader().getResourceAsStream("youtube-search.json");
Preconditions.checkNotNull(contents);
HttpTransport transport =
new MockHttpTransport() {
Expand Down Expand Up @@ -91,4 +92,4 @@ public LowLevelHttpResponse execute() throws IOException {
}
}
}
}
}