From 62a59b847739a45015038d697c0a790af94ffda2 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 3 Feb 2022 21:07:49 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .kokoro/build.sh | 24 ------------------- README.md | 4 ---- .../main/java/search/SearchSimpleQuery.java | 20 +++++----------- .../main/java/search/SearchWithBoostSpec.java | 21 ++++++---------- .../main/java/search/SearchWithFacetSpec.java | 23 +++++++----------- .../java/search/SearchSimpleQueryTest.java | 18 +++++--------- .../java/search/SearchWithBoostSpecTest.java | 18 +++++--------- .../java/search/SearchWithFacetSpecTest.java | 18 +++++--------- 8 files changed, 39 insertions(+), 107 deletions(-) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index d03448be..e8f4fb89 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -103,30 +103,6 @@ samples) echo "no sample pom.xml found - skipping sample tests" fi ;; -tutorials-samples) - SAMPLES_DIR=samples/interactive-tutorials - - if [[ -f ${SAMPLES_DIR}/pom.xml ]] - then - for FILE in ${KOKORO_GFILE_DIR}/secret_manager/*-samples-secrets; do - [[ -f "$FILE" ]] || continue - source "$FILE" - done - - pushd ${SAMPLES_DIR} - mvn -B \ - -ntp \ - -DtrimStackTrace=false \ - -Dclirr.skip=true \ - -Denforcer.skip=true \ - -fae \ - verify - RETURN_CODE=$? - popd - else - echo "no interactive-tutorials pom.xml found - skipping interactive-tutorials tests" - fi - ;; clirr) mvn -B -Denforcer.skip=true clirr:check RETURN_CODE=$? diff --git a/README.md b/README.md index ec4c35d2..2907907c 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,6 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-retail/tree/m | Search Simple Query | [source code](https://github.com/googleapis/java-retail/blob/main/samples/interactive-tutorials/src/main/java/search/SearchSimpleQuery.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-retail&page=editor&open_in_editor=samples/interactive-tutorials/src/main/java/search/SearchSimpleQuery.java) | | Search With Boost Spec | [source code](https://github.com/googleapis/java-retail/blob/main/samples/interactive-tutorials/src/main/java/search/SearchWithBoostSpec.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-retail&page=editor&open_in_editor=samples/interactive-tutorials/src/main/java/search/SearchWithBoostSpec.java) | | Search With Facet Spec | [source code](https://github.com/googleapis/java-retail/blob/main/samples/interactive-tutorials/src/main/java/search/SearchWithFacetSpec.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-retail&page=editor&open_in_editor=samples/interactive-tutorials/src/main/java/search/SearchWithFacetSpec.java) | -| Search With Filtering | [source code](https://github.com/googleapis/java-retail/blob/main/samples/interactive-tutorials/src/main/java/search/SearchWithFiltering.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-retail&page=editor&open_in_editor=samples/interactive-tutorials/src/main/java/search/SearchWithFiltering.java) | -| Search With Ordering | [source code](https://github.com/googleapis/java-retail/blob/main/samples/interactive-tutorials/src/main/java/search/SearchWithOrdering.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-retail&page=editor&open_in_editor=samples/interactive-tutorials/src/main/java/search/SearchWithOrdering.java) | -| Search With Pagination | [source code](https://github.com/googleapis/java-retail/blob/main/samples/interactive-tutorials/src/main/java/search/SearchWithPagination.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-retail&page=editor&open_in_editor=samples/interactive-tutorials/src/main/java/search/SearchWithPagination.java) | -| Search With Query Expansion Spec | [source code](https://github.com/googleapis/java-retail/blob/main/samples/interactive-tutorials/src/main/java/search/SearchWithQueryExpansionSpec.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-retail&page=editor&open_in_editor=samples/interactive-tutorials/src/main/java/search/SearchWithQueryExpansionSpec.java) | diff --git a/samples/interactive-tutorials/src/main/java/search/SearchSimpleQuery.java b/samples/interactive-tutorials/src/main/java/search/SearchSimpleQuery.java index ada58801..a6c47d93 100644 --- a/samples/interactive-tutorials/src/main/java/search/SearchSimpleQuery.java +++ b/samples/interactive-tutorials/src/main/java/search/SearchSimpleQuery.java @@ -36,11 +36,9 @@ public static void main(String[] args) throws IOException { String projectNumber = System.getenv("PROJECT_NUMBER"); String defaultCatalogName = - String.format("projects/%s/locations/global/catalogs/default_catalog", - projectNumber); + String.format("projects/%s/locations/global/catalogs/default_catalog", projectNumber); - String defaultSearchPlacementName = - defaultCatalogName + "/placements/default_search"; + String defaultSearchPlacementName = defaultCatalogName + "/placements/default_search"; search(defaultSearchPlacementName); } @@ -51,19 +49,14 @@ public static void main(String[] args) throws IOException { * @return SearchResponse. * @throws IOException if endpoint is not provided. */ - public static SearchResponse search(String defaultSearchPlacementName) - throws IOException { + public static SearchResponse search(String defaultSearchPlacementName) throws IOException { // TRY DIFFERENT QUERY PHRASES HERE: String queryPhrase = "Hoodie"; - SearchRequest searchRequest = - getSearchRequest(queryPhrase, defaultSearchPlacementName); + SearchRequest searchRequest = getSearchRequest(queryPhrase, defaultSearchPlacementName); SearchResponse searchResponse = - SearchServiceClient.create() - .search(searchRequest) - .getPage() - .getResponse(); + SearchServiceClient.create().search(searchRequest).getPage().getResponse(); System.out.println("Search response: " + searchResponse); @@ -76,8 +69,7 @@ public static SearchResponse search(String defaultSearchPlacementName) * @param query search keyword. * @return SearchRequest. */ - public static SearchRequest getSearchRequest(String query, - String defaultSearchPlacementName) { + public static SearchRequest getSearchRequest(String query, String defaultSearchPlacementName) { int pageSize = 10; String visitorId = UUID.randomUUID().toString(); diff --git a/samples/interactive-tutorials/src/main/java/search/SearchWithBoostSpec.java b/samples/interactive-tutorials/src/main/java/search/SearchWithBoostSpec.java index 10b00c59..8dae9db0 100644 --- a/samples/interactive-tutorials/src/main/java/search/SearchWithBoostSpec.java +++ b/samples/interactive-tutorials/src/main/java/search/SearchWithBoostSpec.java @@ -38,11 +38,9 @@ public static void main(String[] args) throws IOException { String projectNumber = System.getenv("PROJECT_NUMBER"); String defaultCatalogName = - String.format("projects/%s/locations/global/catalogs/default_catalog", - projectNumber); + String.format("projects/%s/locations/global/catalogs/default_catalog", projectNumber); - String defaultSearchPlacementName = - defaultCatalogName + "/placements/default_search"; + String defaultSearchPlacementName = defaultCatalogName + "/placements/default_search"; search(defaultSearchPlacementName); } @@ -53,8 +51,7 @@ public static void main(String[] args) throws IOException { * @return SearchResponse. * @throws IOException if endpoint is not provided. */ - public static SearchResponse search(String defaultSearchPlacementName) - throws IOException { + public static SearchResponse search(String defaultSearchPlacementName) throws IOException { // TRY DIFFERENT CONDITIONS HERE: String condition = "(colorFamilies: ANY(\"Blue\"))"; @@ -64,10 +61,7 @@ public static SearchResponse search(String defaultSearchPlacementName) getSearchRequest("Tee", condition, boost, defaultSearchPlacementName); SearchResponse searchResponse = - SearchServiceClient.create() - .search(searchRequest) - .getPage() - .getResponse(); + SearchServiceClient.create().search(searchRequest).getPage().getResponse(); System.out.println("Search response: " + searchResponse); @@ -77,14 +71,13 @@ public static SearchResponse search(String defaultSearchPlacementName) /** * Get search service request. * - * @param query search keyword. - * @param condition provides search clarification. + * @param query search keyword. + * @param condition provides search clarification. * @param boostStrength is a rate of boost strength. * @return SearchRequest. */ public static SearchRequest getSearchRequest( - String query, String condition, float boostStrength, - String defaultSearchPlacementName) { + String query, String condition, float boostStrength, String defaultSearchPlacementName) { int pageSize = 10; String visitorId = UUID.randomUUID().toString(); diff --git a/samples/interactive-tutorials/src/main/java/search/SearchWithFacetSpec.java b/samples/interactive-tutorials/src/main/java/search/SearchWithFacetSpec.java index e139a987..8410f86f 100644 --- a/samples/interactive-tutorials/src/main/java/search/SearchWithFacetSpec.java +++ b/samples/interactive-tutorials/src/main/java/search/SearchWithFacetSpec.java @@ -33,11 +33,9 @@ public static void main(String[] args) throws IOException { String projectNumber = System.getenv("PROJECT_NUMBER"); String defaultCatalogName = - String.format("projects/%s/locations/global/catalogs/default_catalog", - projectNumber); + String.format("projects/%s/locations/global/catalogs/default_catalog", projectNumber); - String defaultSearchPlacementName = - defaultCatalogName + "/placements/default_search"; + String defaultSearchPlacementName = defaultCatalogName + "/placements/default_search"; search(defaultSearchPlacementName); } @@ -48,19 +46,14 @@ public static void main(String[] args) throws IOException { * @return SearchResponse. * @throws IOException if endpoint is not provided. */ - public static SearchResponse search(String defaultSearchPlacementName) - throws IOException { + public static SearchResponse search(String defaultSearchPlacementName) throws IOException { // TRY DIFFERENT CONDITIONS HERE: String facetKey = "colorFamilies"; - SearchRequest searchRequest = - getSearchRequest("Tee", facetKey, defaultSearchPlacementName); + SearchRequest searchRequest = getSearchRequest("Tee", facetKey, defaultSearchPlacementName); SearchResponse searchResponse = - SearchServiceClient.create() - .search(searchRequest) - .getPage() - .getResponse(); + SearchServiceClient.create().search(searchRequest).getPage().getResponse(); System.out.println("Search response: " + searchResponse); @@ -70,12 +63,12 @@ public static SearchResponse search(String defaultSearchPlacementName) /** * Get search service request. * - * @param query search keyword. + * @param query search keyword. * @param facetKeyParam Supported textual and numerical facet keys. * @return SearchRequest. */ - public static SearchRequest getSearchRequest(String query, - String facetKeyParam, String defaultSearchPlacementName) { + public static SearchRequest getSearchRequest( + String query, String facetKeyParam, String defaultSearchPlacementName) { int pageSize = 10; diff --git a/samples/interactive-tutorials/src/test/java/search/SearchSimpleQueryTest.java b/samples/interactive-tutorials/src/test/java/search/SearchSimpleQueryTest.java index be8487da..b4588c48 100644 --- a/samples/interactive-tutorials/src/test/java/search/SearchSimpleQueryTest.java +++ b/samples/interactive-tutorials/src/test/java/search/SearchSimpleQueryTest.java @@ -33,27 +33,22 @@ public class SearchSimpleQueryTest { private String defaultSearchPlacementName; @Before - public void setUp() - throws IOException, InterruptedException, ExecutionException { + public void setUp() throws IOException, InterruptedException, ExecutionException { String projectNumber = System.getenv("PROJECT_NUMBER"); String defaultCatalogName = - String.format("projects/%s/locations/global/catalogs/default_catalog", - projectNumber); + String.format("projects/%s/locations/global/catalogs/default_catalog", projectNumber); - defaultSearchPlacementName = - defaultCatalogName + "/placements/default_search"; + defaultSearchPlacementName = defaultCatalogName + "/placements/default_search"; Process exec = Runtime.getRuntime() - .exec( - "mvn compile exec:java -Dexec.mainClass=search.SearchSimpleQuery"); + .exec("mvn compile exec:java -Dexec.mainClass=search.SearchSimpleQuery"); StreamGobbler streamGobbler = new StreamGobbler(exec.getInputStream()); - Future stringFuture = Executors.newSingleThreadExecutor() - .submit(streamGobbler); + Future stringFuture = Executors.newSingleThreadExecutor().submit(streamGobbler); output = stringFuture.get(); } @@ -71,8 +66,7 @@ public void testOutput() { @Test public void testSearchSimpleQuery() throws IOException { - SearchResponse response = SearchSimpleQuery.search( - defaultSearchPlacementName); + SearchResponse response = SearchSimpleQuery.search(defaultSearchPlacementName); Assert.assertEquals(10, response.getResultsCount()); diff --git a/samples/interactive-tutorials/src/test/java/search/SearchWithBoostSpecTest.java b/samples/interactive-tutorials/src/test/java/search/SearchWithBoostSpecTest.java index 51b7d91e..4a410cb0 100644 --- a/samples/interactive-tutorials/src/test/java/search/SearchWithBoostSpecTest.java +++ b/samples/interactive-tutorials/src/test/java/search/SearchWithBoostSpecTest.java @@ -33,27 +33,22 @@ public class SearchWithBoostSpecTest { private String defaultSearchPlacementName; @Before - public void setUp() - throws IOException, InterruptedException, ExecutionException { + public void setUp() throws IOException, InterruptedException, ExecutionException { String projectNumber = System.getenv("PROJECT_NUMBER"); String defaultCatalogName = - String.format("projects/%s/locations/global/catalogs/default_catalog", - projectNumber); + String.format("projects/%s/locations/global/catalogs/default_catalog", projectNumber); - defaultSearchPlacementName = - defaultCatalogName + "/placements/default_search"; + defaultSearchPlacementName = defaultCatalogName + "/placements/default_search"; Process exec = Runtime.getRuntime() - .exec( - "mvn compile exec:java -Dexec.mainClass=search.SearchWithBoostSpec"); + .exec("mvn compile exec:java -Dexec.mainClass=search.SearchWithBoostSpec"); StreamGobbler streamGobbler = new StreamGobbler(exec.getInputStream()); - Future stringFuture = Executors.newSingleThreadExecutor() - .submit(streamGobbler); + Future stringFuture = Executors.newSingleThreadExecutor().submit(streamGobbler); output = stringFuture.get(); } @@ -71,8 +66,7 @@ public void testOutput() { @Test public void testSearchWithBoostSpec() throws IOException { - SearchResponse response = - SearchWithBoostSpec.search(defaultSearchPlacementName); + SearchResponse response = SearchWithBoostSpec.search(defaultSearchPlacementName); Assert.assertEquals(10, response.getResultsCount()); diff --git a/samples/interactive-tutorials/src/test/java/search/SearchWithFacetSpecTest.java b/samples/interactive-tutorials/src/test/java/search/SearchWithFacetSpecTest.java index 3e861a7a..b627cb70 100644 --- a/samples/interactive-tutorials/src/test/java/search/SearchWithFacetSpecTest.java +++ b/samples/interactive-tutorials/src/test/java/search/SearchWithFacetSpecTest.java @@ -33,27 +33,22 @@ public class SearchWithFacetSpecTest { private String defaultSearchPlacementName; @Before - public void setUp() - throws IOException, InterruptedException, ExecutionException { + public void setUp() throws IOException, InterruptedException, ExecutionException { String projectNumber = System.getenv("PROJECT_NUMBER"); String defaultCatalogName = - String.format("projects/%s/locations/global/catalogs/default_catalog", - projectNumber); + String.format("projects/%s/locations/global/catalogs/default_catalog", projectNumber); - defaultSearchPlacementName = - defaultCatalogName + "/placements/default_search"; + defaultSearchPlacementName = defaultCatalogName + "/placements/default_search"; Process exec = Runtime.getRuntime() - .exec( - "mvn compile exec:java -Dexec.mainClass=search.SearchWithFacetSpec"); + .exec("mvn compile exec:java -Dexec.mainClass=search.SearchWithFacetSpec"); StreamGobbler streamGobbler = new StreamGobbler(exec.getInputStream()); - Future stringFuture = Executors.newSingleThreadExecutor() - .submit(streamGobbler); + Future stringFuture = Executors.newSingleThreadExecutor().submit(streamGobbler); output = stringFuture.get(); } @@ -73,8 +68,7 @@ public void testOutput() { @Test public void testSearchWithFacetSpec() throws IOException { - SearchResponse response = - SearchWithFacetSpec.search(defaultSearchPlacementName); + SearchResponse response = SearchWithFacetSpec.search(defaultSearchPlacementName); Assert.assertEquals(10, response.getResultsCount());