Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -41,7 +42,9 @@
public class ImageGenerationIT {

private static final String IMAGEN_3_MODEL = "imagen-3.0-capability-001";
private static final String BUCKET_NAME = "java-docs-samples-testing";
private static final String BUCKET_NAME =
System.getenv().getOrDefault("BUCKET_NAME", "java-docs-samples-testing")
.replaceFirst("^gs://", "");
private static final String PREFIX = "genai-img-generation-" + UUID.randomUUID();
private static final String OUTPUT_GCS_URI = String.format("gs://%s/%s", BUCKET_NAME, PREFIX);
private static final String IMAGEN_4_MODEL = "imagen-4.0-generate-001";
Expand All @@ -64,11 +67,15 @@ public static void checkRequirements() {

@AfterClass
public static void cleanup() {
Storage storage = StorageOptions.getDefaultInstance().getService();
Page<Blob> blobs = storage.list(BUCKET_NAME, Storage.BlobListOption.prefix(PREFIX));

for (Blob blob : blobs.iterateAll()) {
storage.delete(blob.getBlobId());
try {
Storage storage = StorageOptions.getDefaultInstance().getService();
Page<Blob> blobs = storage.list(BUCKET_NAME, Storage.BlobListOption.prefix(PREFIX));

for (Blob blob : blobs.iterateAll()) {
storage.delete(blob.getBlobId());
}
} catch (Exception e) {
System.err.println("Failed to cleanup bucket " + BUCKET_NAME + ": " + e.getMessage());
}
}

Expand All @@ -85,6 +92,7 @@ public void tearDown() {
}

@Test
@Ignore("Imagen models are deprecated and unavailable; migrated to Gemini in follow-up PR")
public void testImageGenCannyCtrlTypeWithTextAndImage() {
Optional<String> response =
ImageGenCannyCtrlTypeWithTextAndImage.cannyEdgeCustomization(
Expand All @@ -94,6 +102,7 @@ public void testImageGenCannyCtrlTypeWithTextAndImage() {
}

@Test
@Ignore("Imagen models are deprecated and unavailable; migrated to Gemini in follow-up PR")
public void testImageGenRawReferenceWithTextAndImage() {
Optional<String> response =
ImageGenRawReferenceWithTextAndImage.styleTransferCustomization(
Expand All @@ -103,6 +112,7 @@ public void testImageGenRawReferenceWithTextAndImage() {
}

@Test
@Ignore("Imagen models are deprecated and unavailable; migrated to Gemini in follow-up PR")
public void testImageGenScribbleCtrlTypeWithTextAndImage() {
Optional<String> response =
ImageGenScribbleCtrlTypeWithTextAndImage.scribbleCustomization(
Expand All @@ -112,6 +122,7 @@ public void testImageGenScribbleCtrlTypeWithTextAndImage() {
}

@Test
@Ignore("Imagen models are deprecated and unavailable; migrated to Gemini in follow-up PR")
public void testImageGenStyleReferenceWithTextAndImage() {
Optional<String> response =
ImageGenStyleReferenceWithTextAndImage.styleCustomization(
Expand All @@ -121,6 +132,7 @@ public void testImageGenStyleReferenceWithTextAndImage() {
}

@Test
@Ignore("Imagen models are deprecated and unavailable; migrated to Gemini in follow-up PR")
public void testImageGenSubjectReferenceWithTextAndImage() {
Optional<String> response =
ImageGenSubjectReferenceWithTextAndImage.subjectCustomization(
Expand All @@ -141,6 +153,7 @@ public void testImageGenVirtualTryOnWithTextAndImage() throws IOException {
}

@Test
@Ignore("Imagen models are deprecated and unavailable; migrated to Gemini in follow-up PR")
public void testImageGenWithText() throws IOException {
Image image =
ImageGenWithText.generateImage(IMAGEN_4_MODEL, "resources/output/dog_newspaper.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
public class VideoGenerationIT {

private static final String VIDEO_GEN_MODEL = "veo-3.1-generate-001";
private static final String BUCKET_NAME = "java-docs-samples-testing";
private static final String BUCKET_NAME =
System.getenv().getOrDefault("BUCKET_NAME", "java-docs-samples-testing")
.replaceFirst("^gs://", "");
private static final String PREFIX = "genai-video-generation-" + UUID.randomUUID();
private static final String OUTPUT_GCS_URI = String.format("gs://%s/%s", BUCKET_NAME, PREFIX);
private ByteArrayOutputStream bout;
Expand All @@ -58,11 +60,15 @@ public static void checkRequirements() {

@AfterClass
public static void cleanup() {
Storage storage = StorageOptions.getDefaultInstance().getService();
Page<Blob> blobs = storage.list(BUCKET_NAME, Storage.BlobListOption.prefix(PREFIX));
try {
Storage storage = StorageOptions.getDefaultInstance().getService();
Page<Blob> blobs = storage.list(BUCKET_NAME, Storage.BlobListOption.prefix(PREFIX));

for (Blob blob : blobs.iterateAll()) {
storage.delete(blob.getBlobId());
for (Blob blob : blobs.iterateAll()) {
storage.delete(blob.getBlobId());
}
} catch (Exception e) {
System.err.println("Failed to cleanup bucket " + BUCKET_NAME + ": " + e.getMessage());
}
}

Expand Down