diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml
index 98770e68a..f0a229f49 100644
--- a/samples/install-without-bom/pom.xml
+++ b/samples/install-without-bom/pom.xml
@@ -60,6 +60,13 @@
1.1.2
test
+
+ com.google.cloud
+ google-cloud-core
+ 1.94.0
+ test
+ tests
+
diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml
index c9e462261..544698dd3 100644
--- a/samples/snapshot/pom.xml
+++ b/samples/snapshot/pom.xml
@@ -59,6 +59,13 @@
1.1.2
test
+
+ com.google.cloud
+ google-cloud-core
+ 1.94.0
+ test
+ tests
+
diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml
index 1bd38367e..d87ec1b48 100644
--- a/samples/snippets/pom.xml
+++ b/samples/snippets/pom.xml
@@ -68,6 +68,13 @@
1.1.2
test
+
+ com.google.cloud
+ google-cloud-core
+ 1.94.0
+ test
+ tests
+
diff --git a/samples/snippets/src/test/java/com/example/automl/TranslateCreateDatasetTest.java b/samples/snippets/src/test/java/com/example/automl/TranslateCreateDatasetTest.java
index ad2081a06..6fd75eff9 100644
--- a/samples/snippets/src/test/java/com/example/automl/TranslateCreateDatasetTest.java
+++ b/samples/snippets/src/test/java/com/example/automl/TranslateCreateDatasetTest.java
@@ -19,6 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.TestCase.assertNotNull;
+import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
@@ -27,6 +28,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -39,7 +41,7 @@ public class TranslateCreateDatasetTest {
private ByteArrayOutputStream bout;
private PrintStream out;
private PrintStream originalPrintStream;
- private String datasetId;
+ private String got;
private static void requireEnvVar(String varName) {
assertNotNull(
@@ -63,11 +65,15 @@ public void setUp() {
@After
public void tearDown() throws InterruptedException, ExecutionException, IOException {
+ String datasetId = got.split("Dataset id: ")[1].split("\n")[0];
+
// Delete the created dataset
DeleteDataset.deleteDataset(PROJECT_ID, datasetId);
System.setOut(originalPrintStream);
}
+ @Rule public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);
+
@Test
public void testCreateDataset() throws IOException, ExecutionException, InterruptedException {
// Create a random dataset name with a length of 32 characters (max allowed by AutoML)
@@ -77,8 +83,7 @@ public void testCreateDataset() throws IOException, ExecutionException, Interrup
String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26));
TranslateCreateDataset.createDataset(PROJECT_ID, datasetName);
- String got = bout.toString();
+ got = bout.toString();
assertThat(got).contains("Dataset id:");
- datasetId = got.split("Dataset id: ")[1].split("\n")[0];
}
}