Skip to content

Commit

Permalink
🦉 Updates from OwlBot
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] authored and t-karasova committed Feb 7, 2022
1 parent 04120c7 commit 62a59b8
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 107 deletions.
24 changes: 0 additions & 24 deletions .kokoro/build.sh
Expand Up @@ -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=$?
Expand Down
4 changes: 0 additions & 4 deletions README.md
Expand Up @@ -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) |



Expand Down
Expand Up @@ -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);
}
Expand All @@ -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);

Expand All @@ -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();
Expand Down
Expand Up @@ -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);
}
Expand All @@ -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\"))";

Expand All @@ -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);

Expand All @@ -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();
Expand Down
Expand Up @@ -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);
}
Expand All @@ -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);

Expand All @@ -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;

Expand Down
Expand Up @@ -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<String> stringFuture = Executors.newSingleThreadExecutor()
.submit(streamGobbler);
Future<String> stringFuture = Executors.newSingleThreadExecutor().submit(streamGobbler);

output = stringFuture.get();
}
Expand All @@ -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());

Expand Down
Expand Up @@ -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<String> stringFuture = Executors.newSingleThreadExecutor()
.submit(streamGobbler);
Future<String> stringFuture = Executors.newSingleThreadExecutor().submit(streamGobbler);

output = stringFuture.get();
}
Expand All @@ -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());

Expand Down
Expand Up @@ -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<String> stringFuture = Executors.newSingleThreadExecutor()
.submit(streamGobbler);
Future<String> stringFuture = Executors.newSingleThreadExecutor().submit(streamGobbler);

output = stringFuture.get();
}
Expand All @@ -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());

Expand Down

0 comments on commit 62a59b8

Please sign in to comment.