From 20da212aca715d18e4a7aff4f58d624b37ec8d02 Mon Sep 17 00:00:00 2001 From: Charlie Yu Date: Wed, 16 Nov 2022 16:39:22 -0500 Subject: [PATCH 1/3] Remove migrated files --- samples/snippets/pom.xml | 65 ------------- .../snippets/resources/sync_request.textproto | 64 ------------- .../com/example/optimizationai/AsyncApi.java | 85 ----------------- .../example/optimizationai/GetOperation.java | 57 ------------ .../com/example/optimizationai/SyncApi.java | 57 ------------ .../SyncApiWithLongTimeout.java | 66 ------------- .../example/optimizationai/AsyncApiTest.java | 93 ------------------- .../optimizationai/GetOperationTest.java | 67 ------------- .../example/optimizationai/SyncApiTest.java | 57 ------------ .../SyncApiWithLongTimeoutTest.java | 57 ------------ 10 files changed, 668 deletions(-) delete mode 100644 samples/snippets/pom.xml delete mode 100644 samples/snippets/resources/sync_request.textproto delete mode 100644 samples/snippets/src/main/java/com/example/optimizationai/AsyncApi.java delete mode 100644 samples/snippets/src/main/java/com/example/optimizationai/GetOperation.java delete mode 100644 samples/snippets/src/main/java/com/example/optimizationai/SyncApi.java delete mode 100644 samples/snippets/src/main/java/com/example/optimizationai/SyncApiWithLongTimeout.java delete mode 100644 samples/snippets/src/test/java/com/example/optimizationai/AsyncApiTest.java delete mode 100644 samples/snippets/src/test/java/com/example/optimizationai/GetOperationTest.java delete mode 100644 samples/snippets/src/test/java/com/example/optimizationai/SyncApiTest.java delete mode 100644 samples/snippets/src/test/java/com/example/optimizationai/SyncApiWithLongTimeoutTest.java diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml deleted file mode 100644 index 5e9b482..0000000 --- a/samples/snippets/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - 4.0.0 - com.google.cloud - optimization-ai-snippets - pom - Google Cloud Fleet Routing Samples Parent - https://github.com/googleapis/java-optimization - - Java idiomatic client for Google Cloud Platform services. - - - - - com.google.cloud.samples - shared-configuration - 1.2.0 - - - - 1.8 - 1.8 - UTF-8 - - - - - - - com.google.cloud - libraries-bom - 26.1.4 - pom - import - - - - - - - com.google.cloud - google-cloud-optimization - 1.1.14 - - - com.google.cloud - google-cloud-storage - - - junit - junit - 4.13.2 - test - - - com.google.truth - truth - 1.1.3 - test - - - \ No newline at end of file diff --git a/samples/snippets/resources/sync_request.textproto b/samples/snippets/resources/sync_request.textproto deleted file mode 100644 index d1026f9..0000000 --- a/samples/snippets/resources/sync_request.textproto +++ /dev/null @@ -1,64 +0,0 @@ -# proto-file: google3/google/cloud/optimization/v1/fleet_routing.proto -# proto-message: OptimizeToursRequest -model { - shipments { - pickups { - arrival_location { latitude: 48.874507 longitude: 2.30361 } - time_windows { - start_time { seconds: 1000 } - end_time { seconds: 2000 } - } - duration { seconds: 150 } - } - deliveries { - arrival_location { latitude: 48.880942 longitude: 2.323866 } - time_windows { - start_time { seconds: 3000 } - end_time { seconds: 4000 } - } - duration: { seconds: 250 } - } - load_demands { - key: "weight" - value: { amount: 10 } - } - } - shipments { - pickups { - arrival_location { latitude: 48.880943 longitude: 2.323867 } - time_windows { - start_time { seconds: 1001 } - end_time { seconds: 2001 } - } - duration { seconds: 151 } - } - deliveries { - arrival_location { latitude: 48.880940 longitude: 2.323844 } - time_windows { - start_time { seconds: 3001 } - end_time { seconds: 4001 } - } - duration { seconds: 251 } - } - load_demands { - key: "weight" - value: { amount: 20 } - } - } - vehicles { - start_location { latitude: 48.863102 longitude: 2.341204 } - end_location { latitude: 48.863110 longitude: 2.341205 } - load_limits { - key: "weight" - value: { max_load: 50 } - } - } - vehicles { - start_location { latitude: 48.863112 longitude: 2.341214 } - end_location { latitude: 48.863120 longitude: 2.341215 } - load_limits { - key: "weight" - value: { max_load: 60 } - } - } - } \ No newline at end of file diff --git a/samples/snippets/src/main/java/com/example/optimizationai/AsyncApi.java b/samples/snippets/src/main/java/com/example/optimizationai/AsyncApi.java deleted file mode 100644 index 97430d3..0000000 --- a/samples/snippets/src/main/java/com/example/optimizationai/AsyncApi.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2022 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 - * - * http://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. - */ - -package com.optimizationai; - -// [START cloudoptimization_async_api] -import com.google.api.gax.longrunning.OperationFuture; -import com.google.cloud.optimization.v1.AsyncModelMetadata; -import com.google.cloud.optimization.v1.BatchOptimizeToursRequest; -import com.google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig; -import com.google.cloud.optimization.v1.BatchOptimizeToursResponse; -import com.google.cloud.optimization.v1.DataFormat; -import com.google.cloud.optimization.v1.FleetRoutingClient; -import com.google.cloud.optimization.v1.GcsDestination; -import com.google.cloud.optimization.v1.GcsSource; -import com.google.cloud.optimization.v1.InputConfig; -import com.google.cloud.optimization.v1.OutputConfig; - -/** - * This is an example to send a request to Cloud Fleet Routing asynchronous API via Java API Client. - * A sample async_request_java.textproto file and a sample request_model_java.json file can be found - * in the resources folder. - */ -public class AsyncApi { - public static void callAsyncApi() throws Exception { - // TODO(developer): Replace these variables before running the sample. - String projectParent = "projects/{YOUR_GCP_PROJECT_ID}"; - String inputUri = "gs://YOUR_GCS_PATH"; - String outputUri = "gs://YOUR_SOLUTION_PATH"; - callAsyncApi(projectParent, inputUri, outputUri); - } - - public static void callAsyncApi(String projectParent, String inputUri, String outputUri) - throws Exception { - GcsSource gcsSource = GcsSource.newBuilder().setUri(inputUri).build(); - InputConfig inputConfig = - InputConfig.newBuilder().setGcsSource(gcsSource).setDataFormat(DataFormat.JSON).build(); - GcsDestination gcsDestination = GcsDestination.newBuilder().setUri(outputUri).build(); - OutputConfig outputConfig = - OutputConfig.newBuilder() - .setGcsDestination(gcsDestination) - .setDataFormat(DataFormat.JSON) - .build(); - - AsyncModelConfig asyncModelConfig = - AsyncModelConfig.newBuilder() - .setInputConfig(inputConfig) - .setOutputConfig(outputConfig) - .build(); - BatchOptimizeToursRequest request = - BatchOptimizeToursRequest.newBuilder() - .setParent(projectParent) - .addModelConfigs(asyncModelConfig) - .build(); - - FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create(); - OperationFuture response = - fleetRoutingClient.batchOptimizeToursAsync(request); - System.out.format("the response name: %s\n", response.getInitialFuture().get().getName()); - - // Block to wait for the job to finish. - response.getPollingFuture().get(); - if (response.getMetadata().get().getState() == AsyncModelMetadata.State.SUCCEEDED) { - // Code to do your stuff - System.out.println("Job finished successfully."); - } else { - System.out.println( - "Job failed with message:" + response.getPollingFuture().get().getErrorMessage()); - } - } -} -// [END cloudoptimization_async_api] diff --git a/samples/snippets/src/main/java/com/example/optimizationai/GetOperation.java b/samples/snippets/src/main/java/com/example/optimizationai/GetOperation.java deleted file mode 100644 index 6a6e8fd..0000000 --- a/samples/snippets/src/main/java/com/example/optimizationai/GetOperation.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2022 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 - * - * http://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. - */ - -package com.example.optimizationai; - -// [START cloudoptimization_get_operation] -import com.google.cloud.optimization.v1.FleetRoutingClient; -import com.google.longrunning.Operation; -import java.io.IOException; - -class GetOperation { - - static void getOperation() throws IOException { - // TODO(developer): Replace these variables before running the sample. - String operationFullId = "projects/[projectId]/operations/[operationId]"; - getOperation(operationFullId); - } - - // Get the status of an operation - static void getOperation(String operationFullId) throws IOException { - // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - try (FleetRoutingClient client = FleetRoutingClient.create()) { - // Get the latest state of a long-running operation. - Operation operation = client.getOperationsClient().getOperation(operationFullId); - - // Display operation details. - System.out.println("Operation details:"); - System.out.format("\tName: %s\n", operation.getName()); - System.out.format("\tMetadata Type Url: %s\n", operation.getMetadata().getTypeUrl()); - System.out.format("\tDone: %s\n", operation.getDone()); - if (operation.hasResponse()) { - System.out.format("\tResponse Type Url: %s\n", operation.getResponse().getTypeUrl()); - } - if (operation.hasError()) { - System.out.println("\tResponse:"); - System.out.format("\t\tError code: %s\n", operation.getError().getCode()); - System.out.format("\t\tError message: %s\n", operation.getError().getMessage()); - } - } - } -} -// [END cloudoptimization_get_operation] diff --git a/samples/snippets/src/main/java/com/example/optimizationai/SyncApi.java b/samples/snippets/src/main/java/com/example/optimizationai/SyncApi.java deleted file mode 100644 index 5e73344..0000000 --- a/samples/snippets/src/main/java/com/example/optimizationai/SyncApi.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2022 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 - * - * http://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. - */ - -package com.example.optimizationai; - -// [START cloudoptimization_sync_api] - -import com.google.cloud.optimization.v1.FleetRoutingClient; -import com.google.cloud.optimization.v1.OptimizeToursRequest; -import com.google.cloud.optimization.v1.OptimizeToursResponse; -import com.google.protobuf.Duration; -import com.google.protobuf.TextFormat; -import java.io.FileInputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; - -/** - * This is an example to send a request to Cloud Fleet Routing synchronous API via Java API Client. - * A sample sync_request.textproto file can be found in the resources folder. - */ -public class SyncApi { - public static void callSyncApi() throws Exception { - // TODO(developer): Replace these variables before running the sample. - String projectParent = "projects/{YOUR_GCP_PROJECT_ID}"; - String modelPath = "YOUR_MODEL_PATH"; - callSyncApi(projectParent, modelPath); - } - - public static void callSyncApi(String projectParent, String modelPath) throws Exception { - int timeoutSeconds = 100; - InputStream modelInputstream = new FileInputStream(modelPath); - Reader modelInputStreamReader = new InputStreamReader(modelInputstream); - OptimizeToursRequest.Builder requestBuilder = - OptimizeToursRequest.newBuilder() - .setTimeout(Duration.newBuilder().setSeconds(timeoutSeconds).build()) - .setParent(projectParent); - TextFormat.getParser().merge(modelInputStreamReader, requestBuilder); - FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create(); - OptimizeToursResponse response = fleetRoutingClient.optimizeTours(requestBuilder.build()); - System.out.println(response.toString()); - } -} -// [END cloudoptimization_sync_api] diff --git a/samples/snippets/src/main/java/com/example/optimizationai/SyncApiWithLongTimeout.java b/samples/snippets/src/main/java/com/example/optimizationai/SyncApiWithLongTimeout.java deleted file mode 100644 index 152fd08..0000000 --- a/samples/snippets/src/main/java/com/example/optimizationai/SyncApiWithLongTimeout.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2022 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 - * - * http://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. - */ - -package com.example.optimizationai; - -// [START cloudoptimization_long_timeout] - -import com.google.cloud.optimization.v1.FleetRoutingClient; -import com.google.cloud.optimization.v1.FleetRoutingSettings; -import com.google.cloud.optimization.v1.OptimizeToursRequest; -import com.google.cloud.optimization.v1.OptimizeToursResponse; -import com.google.protobuf.Duration; -import com.google.protobuf.TextFormat; -import java.io.FileInputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; - -/** - * This is an example to send a request to Cloud Fleet Routing synchronous API via Java API Client. - */ -public class SyncApiWithLongTimeout { - public static void longTimeout() throws Exception { - // TODO(developer): Replace these variables before running the sample. - String projectParent = "projects/{YOUR_GCP_PROJECT_ID}"; - String modelPath = "YOUR_MODEL_PATH"; - longTimeout(projectParent, modelPath); - } - - public static void longTimeout(String projectParent, String modelPath) throws Exception { - int timeoutSeconds = 100; - InputStream modelInputstream = new FileInputStream(modelPath); - Reader modelInputStreamReader = new InputStreamReader(modelInputstream); - OptimizeToursRequest.Builder requestBuilder = - OptimizeToursRequest.newBuilder() - .setTimeout(Duration.newBuilder().setSeconds(timeoutSeconds).build()) - .setParent(projectParent); - TextFormat.getParser().merge(modelInputStreamReader, requestBuilder); - - // Checks the gRPC connection every 5 mins and keeps it alive. - FleetRoutingClient fleetRoutingClientClient = - FleetRoutingClient.create( - FleetRoutingSettings.newBuilder() - .setTransportChannelProvider( - FleetRoutingSettings.defaultGrpcTransportProviderBuilder() - .setKeepAliveTime(org.threeten.bp.Duration.ofSeconds(300)) - .build()) - .build()); - OptimizeToursResponse response = fleetRoutingClientClient.optimizeTours(requestBuilder.build()); - System.out.println(response.toString()); - } -} -// [END cloudoptimization_long_timeout] diff --git a/samples/snippets/src/test/java/com/example/optimizationai/AsyncApiTest.java b/samples/snippets/src/test/java/com/example/optimizationai/AsyncApiTest.java deleted file mode 100644 index 058b46a..0000000 --- a/samples/snippets/src/test/java/com/example/optimizationai/AsyncApiTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2022 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 - * - * http://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. - */ - -package com.optimizationai; - -import static com.google.common.truth.Truth.assertThat; - -import com.google.api.gax.paging.Page; -import com.google.cloud.storage.Blob; -import com.google.cloud.storage.BucketInfo; -import com.google.cloud.storage.Storage; -import com.google.cloud.storage.StorageOptions; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.util.UUID; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** Tests for AsyncApi sample. */ -public class AsyncApiTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String PROJECT_PARENT = String.format("projects/%s", PROJECT_ID); - private static final String BUCKET_NAME = - String.format("optimizationai-test-%s", UUID.randomUUID()); - private static final String INPUT_URI = - "gs://cloud-samples-data/optimization-ai/async_request_model.json"; - private static final String BATCH_OUTPUT_URI = - String.format("gs://%s/code_snippets_test_output.json", BUCKET_NAME); - - private ByteArrayOutputStream bout; - private PrintStream out; - private PrintStream originalPrintStream; - - private static void cleanUpBucket() { - Storage storage = StorageOptions.getDefaultInstance().getService(); - Page blobs = storage.list(BUCKET_NAME, Storage.BlobListOption.currentDirectory()); - - deleteDirectory(storage, blobs); - } - - private static void deleteDirectory(Storage storage, Page blobs) { - for (Blob blob : blobs.iterateAll()) { - if (!blob.delete()) { - Page subBlobs = - storage.list( - BUCKET_NAME, - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix(blob.getName())); - - deleteDirectory(storage, subBlobs); - } - } - } - - @Before - public void setUp() { - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - originalPrintStream = System.out; - System.setOut(out); - - Storage storage = StorageOptions.getDefaultInstance().getService(); - storage.create(BucketInfo.of(BUCKET_NAME)); - } - - @After - public void tearDown() { - cleanUpBucket(); - System.out.flush(); - System.setOut(originalPrintStream); - } - - @Test - public void testAsyncApi() throws Exception { - AsyncApi.callAsyncApi(PROJECT_PARENT, INPUT_URI, BATCH_OUTPUT_URI); - String got = bout.toString(); - assertThat(got).contains("Job"); - } -} diff --git a/samples/snippets/src/test/java/com/example/optimizationai/GetOperationTest.java b/samples/snippets/src/test/java/com/example/optimizationai/GetOperationTest.java deleted file mode 100644 index 32ef2cb..0000000 --- a/samples/snippets/src/test/java/com/example/optimizationai/GetOperationTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2022 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 - * - * http://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. - */ - -package com.example.optimizationai; - -import static com.google.common.truth.Truth.assertThat; - -import com.google.api.gax.longrunning.OperationFuture; -import com.google.cloud.optimization.v1.AsyncModelMetadata; -import com.google.cloud.optimization.v1.BatchOptimizeToursRequest; -import com.google.cloud.optimization.v1.BatchOptimizeToursResponse; -import com.google.cloud.optimization.v1.FleetRoutingClient; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** Tests for GetOperation sample. */ -public class GetOperationTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String PROJECT_PARENT = String.format("projects/%s", PROJECT_ID); - - private ByteArrayOutputStream bout; - private PrintStream out; - private PrintStream originalPrintStream; - - @Before - public void setUp() { - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - originalPrintStream = System.out; - System.setOut(out); - } - - @After - public void tearDown() { - System.out.flush(); - System.setOut(originalPrintStream); - } - - @Test - public void testSyncApi() throws Exception { - FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create(); - BatchOptimizeToursRequest request = - BatchOptimizeToursRequest.newBuilder().setParent(PROJECT_PARENT).build(); - OperationFuture response = - fleetRoutingClient.batchOptimizeToursAsync(request); - - GetOperation.getOperation(response.getInitialFuture().get().getName()); - String got = bout.toString(); - assertThat(got).contains("operations"); - } -} diff --git a/samples/snippets/src/test/java/com/example/optimizationai/SyncApiTest.java b/samples/snippets/src/test/java/com/example/optimizationai/SyncApiTest.java deleted file mode 100644 index e663a92..0000000 --- a/samples/snippets/src/test/java/com/example/optimizationai/SyncApiTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2022 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 - * - * http://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. - */ - -package com.example.optimizationai; - -import static com.google.common.truth.Truth.assertThat; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** Tests for SyncApi sample. */ -public class SyncApiTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String PROJECT_PARENT = String.format("projects/%s", PROJECT_ID); - private static final String MODEL_PATH = "resources/sync_request.textproto"; - - private ByteArrayOutputStream bout; - private PrintStream out; - private PrintStream originalPrintStream; - - @Before - public void setUp() { - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - originalPrintStream = System.out; - System.setOut(out); - } - - @After - public void tearDown() { - System.out.flush(); - System.setOut(originalPrintStream); - } - - @Test - public void testSyncApi() throws Exception { - SyncApi.callSyncApi(PROJECT_PARENT, MODEL_PATH); - String got = bout.toString(); - assertThat(got).contains("routes"); - } -} diff --git a/samples/snippets/src/test/java/com/example/optimizationai/SyncApiWithLongTimeoutTest.java b/samples/snippets/src/test/java/com/example/optimizationai/SyncApiWithLongTimeoutTest.java deleted file mode 100644 index 0dc7b11..0000000 --- a/samples/snippets/src/test/java/com/example/optimizationai/SyncApiWithLongTimeoutTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2022 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 - * - * http://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. - */ - -package com.example.optimizationai; - -import static com.google.common.truth.Truth.assertThat; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** Tests for SyncApiWithLongTimeout sample. */ -public class SyncApiWithLongTimeoutTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String PROJECT_PARENT = String.format("projects/%s", PROJECT_ID); - private static final String MODEL_PATH = "resources/sync_request.textproto"; - - private ByteArrayOutputStream bout; - private PrintStream out; - private PrintStream originalPrintStream; - - @Before - public void setUp() { - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - originalPrintStream = System.out; - System.setOut(out); - } - - @After - public void tearDown() { - System.out.flush(); - System.setOut(originalPrintStream); - } - - @Test - public void testSyncApi() throws Exception { - SyncApiWithLongTimeout.longTimeout(PROJECT_PARENT, MODEL_PATH); - String got = bout.toString(); - assertThat(got).contains("routes"); - } -} From 82d5170852a2e4f92d8eb7c9a75fa5af271c7047 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 16 Nov 2022 21:44:30 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= 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 --- README.md | 18 +++------------ samples/snippets/pom.xml | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 samples/snippets/pom.xml diff --git a/README.md b/README.md index 5c6aa40..855e98b 100644 --- a/README.md +++ b/README.md @@ -26,20 +26,20 @@ If you are using Maven, add this to your pom.xml file: com.google.cloud google-cloud-optimization - 1.3.0 + 1.4.0 ``` If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-optimization:1.3.0' +implementation 'com.google.cloud:google-cloud-optimization:1.4.0' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-optimization" % "1.3.0" +libraryDependencies += "com.google.cloud" % "google-cloud-optimization" % "1.4.0" ``` ## Authentication @@ -77,18 +77,6 @@ use this Cloud Fleet Routing Client Library. -## Samples - -Samples are in the [`samples/`](https://github.com/googleapis/java-optimization/tree/main/samples) directory. - -| Sample | Source Code | Try it | -| --------------------------- | --------------------------------- | ------ | -| Async Api | [source code](https://github.com/googleapis/java-optimization/blob/main/samples/snippets/src/main/java/com/example/optimizationai/AsyncApi.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-optimization&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/optimizationai/AsyncApi.java) | -| Get Operation | [source code](https://github.com/googleapis/java-optimization/blob/main/samples/snippets/src/main/java/com/example/optimizationai/GetOperation.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-optimization&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/optimizationai/GetOperation.java) | -| Sync Api | [source code](https://github.com/googleapis/java-optimization/blob/main/samples/snippets/src/main/java/com/example/optimizationai/SyncApi.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-optimization&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/optimizationai/SyncApi.java) | -| Sync Api With Long Timeout | [source code](https://github.com/googleapis/java-optimization/blob/main/samples/snippets/src/main/java/com/example/optimizationai/SyncApiWithLongTimeout.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-optimization&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/optimizationai/SyncApiWithLongTimeout.java) | - - ## Troubleshooting diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml new file mode 100644 index 0000000..5a2976a --- /dev/null +++ b/samples/snippets/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + com.google.cloud + -snippets + jar + Google Cloud Fleet Routing Snippets + https://github.com/googleapis/java-optimization + + + + com.google.cloud.samples + shared-configuration + 1.2.0 + + + + 1.8 + 1.8 + UTF-8 + + + + + + com.google.cloud + google-cloud-optimization + 1.4.0 + + + + junit + junit + 4.13.2 + test + + + com.google.truth + truth + 1.1.3 + test + + + From 35401e9b67292b94b8b3f5af3f21b61603e441e0 Mon Sep 17 00:00:00 2001 From: Charlie Yu Date: Thu, 17 Nov 2022 11:22:39 -0500 Subject: [PATCH 3/3] reverted pom file --- samples/snippets/pom.xml | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 5a2976a..5e9b482 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -2,14 +2,17 @@ 4.0.0 com.google.cloud - -snippets - jar - Google Cloud Fleet Routing Snippets + optimization-ai-snippets + pom + Google Cloud Fleet Routing Samples Parent https://github.com/googleapis/java-optimization + + Java idiomatic client for Google Cloud Platform services. + com.google.cloud.samples @@ -23,14 +26,29 @@ UTF-8 + + + + + com.google.cloud + libraries-bom + 26.1.4 + pom + import + + + + - com.google.cloud google-cloud-optimization - 1.4.0 + 1.1.14 + + + com.google.cloud + google-cloud-storage - junit junit @@ -44,4 +62,4 @@ test - + \ No newline at end of file