Skip to content

Commit c94ece8

Browse files
committed
bug: add tests
1 parent 6d30545 commit c94ece8

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

src/test/java/io/getstream/FeedIntegrationTests.java

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,75 @@ void test32_RealWorldUsageDemo() throws Exception {
15391539
System.out.println("✅ Completed real-world usage scenario demonstration");
15401540
}
15411541

1542+
/** Test file upload functionality */
1543+
@Test
1544+
@Order(37)
1545+
void test37_UploadImage() throws Exception {
1546+
System.out.println("\n🖼️ Testing image upload...");
1547+
1548+
// snippet-start: UploadImage
1549+
UploadImageRequest imageUploadRequest =
1550+
UploadImageRequest.builder()
1551+
.file("img.png")
1552+
.user(OnlyUserID.builder().id(testUserId).build())
1553+
.uploadSizes(
1554+
List.of(
1555+
ImageSize.builder()
1556+
.width(100)
1557+
.height(100)
1558+
.resize("scale")
1559+
.crop("center")
1560+
.build()))
1561+
.build();
1562+
1563+
ImageUploadResponse imageResponse = common.uploadImage(imageUploadRequest).execute().getData();
1564+
// snippet-end: UploadImage
1565+
1566+
Assertions.assertNotNull(imageResponse, "Image upload response should not be null");
1567+
Assertions.assertNotNull(imageResponse.getFile(), "Uploaded image URL should not be null");
1568+
Assertions.assertTrue(
1569+
imageResponse.getFile().contains("http"), "Image URL should be a valid HTTP URL");
1570+
1571+
System.out.println("✅ Image uploaded successfully: " + imageResponse.getFile());
1572+
}
1573+
1574+
/** Test file upload functionality */
1575+
@Test
1576+
@Order(38)
1577+
void test38_UploadFile() throws Exception {
1578+
System.out.println("\n📄 Testing file upload...");
1579+
1580+
// Create a temporary test file
1581+
java.io.File tempFile = java.io.File.createTempFile("test-file-", ".txt");
1582+
java.nio.file.Files.writeString(
1583+
tempFile.toPath(),
1584+
"This is a test file for integration testing\nContains multiple lines\nWith various content");
1585+
1586+
try {
1587+
// snippet-start: UploadFile
1588+
UploadFileRequest fileUploadRequest =
1589+
UploadFileRequest.builder()
1590+
.file(tempFile.getAbsolutePath())
1591+
.user(OnlyUserID.builder().id(testUserId).build())
1592+
.build();
1593+
1594+
FileUploadResponse fileResponse = common.uploadFile(fileUploadRequest).execute().getData();
1595+
// snippet-end: UploadFile
1596+
1597+
Assertions.assertNotNull(fileResponse, "File upload response should not be null");
1598+
Assertions.assertNotNull(fileResponse.getFile(), "Uploaded file URL should not be null");
1599+
Assertions.assertTrue(
1600+
fileResponse.getFile().contains("http"), "File URL should be a valid HTTP URL");
1601+
1602+
System.out.println("✅ File uploaded successfully: " + fileResponse.getFile());
1603+
} finally {
1604+
// Clean up temp file
1605+
if (tempFile.exists()) {
1606+
tempFile.delete();
1607+
}
1608+
}
1609+
}
1610+
15421611
// =================================================================
15431612
// HELPER METHODS
15441613
// =================================================================

0 commit comments

Comments
 (0)