Skip to content

Commit 38ea11c

Browse files
committed
chore: added test to verify append chunk tx
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent ec1332d commit 38ea11c

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

hiero-enterprise-microprofile/src/test/java/org/hiero/microprofile/test/FileClientTests.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ void testAppendFile() throws HieroException {
4848
final byte[] contents = "Hello,".getBytes();
4949
final FileId fileId = fileClient.createFile(contents);
5050

51+
Assertions.assertNotNull(fileId);
52+
5153
fileClient.appendFile(fileId, " Hiero!");
5254
byte[] bytes = fileClient.readFile(fileId);
5355

56+
Assertions.assertNotNull(bytes);
5457
Assertions.assertEquals("Hello, Hiero!", new String(bytes));
5558
}
5659

@@ -59,6 +62,21 @@ void testAppendFileThrowsExceptionWhenContentExceedMaxSize() throws HieroExcepti
5962
final byte[] content = new byte[FileCreateRequest.FILE_MAX_SIZE + 1];
6063
final FileId fileId = fileClient.createFile(new byte[0]);
6164

65+
Assertions.assertNotNull(fileId);
6266
Assertions.assertThrows(HieroException.class, () -> fileClient.appendFile(fileId, content));
6367
}
68+
69+
@Test
70+
void testChunkedAppendFile() throws HieroException {
71+
final String content = "A".repeat(FileCreateRequest.FILE_CREATE_MAX_SIZE * 2);
72+
final FileId fileId = fileClient.createFile(new byte[0]);
73+
74+
Assertions.assertNotNull(fileId);
75+
76+
fileClient.appendFile(fileId, content);
77+
byte[] bytes = fileClient.readFile(fileId);
78+
79+
Assertions.assertNotNull(bytes);
80+
Assertions.assertEquals(content, new String(bytes));
81+
}
6482
}

hiero-enterprise-spring/src/test/java/org/hiero/spring/test/FileClientTests.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,12 @@ void testAppendFile() throws HieroException {
372372
final byte[] contents = "Hello,".getBytes();
373373
final FileId fileId = fileClient.createFile(contents);
374374

375+
Assertions.assertNotNull(fileId);
376+
375377
fileClient.appendFile(fileId, " Hiero!");
376378
byte[] bytes = fileClient.readFile(fileId);
377379

380+
Assertions.assertNotNull(bytes);
378381
Assertions.assertEquals("Hello, Hiero!", new String(bytes));
379382
}
380383

@@ -383,9 +386,25 @@ void testAppendFileThrowsExceptionWhenContentExceedMaxSize() throws HieroExcepti
383386
final byte[] content = new byte[FileCreateRequest.FILE_MAX_SIZE + 1];
384387
final FileId fileId = fileClient.createFile(new byte[0]);
385388

389+
Assertions.assertNotNull(fileId);
386390
Assertions.assertThrows(HieroException.class, () -> fileClient.appendFile(fileId, content));
387391
}
388392

393+
@Test
394+
void testChunkedAppendFile() throws HieroException {
395+
// 2048 * 2 = 2 chunk
396+
final String content = "A".repeat(FileCreateRequest.FILE_CREATE_MAX_SIZE * 2);
397+
final FileId fileId = fileClient.createFile(new byte[0]);
398+
399+
Assertions.assertNotNull(fileId);
400+
401+
fileClient.appendFile(fileId, content);
402+
byte[] bytes = fileClient.readFile(fileId);
403+
404+
Assertions.assertNotNull(bytes);
405+
Assertions.assertEquals(content, new String(bytes));
406+
}
407+
389408
@Test
390409
void testGetFileSize() throws HieroException {
391410
final byte[] contents = "Hello, Hiero!".getBytes();

0 commit comments

Comments
 (0)