@@ -292,35 +292,79 @@ void testGetExpirationTimeForFailures() {
292292 @ Test
293293 @ Disabled ("Always fails with AUTORENEW_DURATION_NOT_IN_RANGE. Needs to be investigated further." )
294294 void testUpdateExpirationTime () throws Exception {
295- //given
296- final byte [] contents = "Hello, Hedera !" .getBytes ();
295+ // given
296+ final byte [] contents = "Hello, Hiero !" .getBytes ();
297297 final Instant definedExpirationTime = Instant .now ().plus (Duration .of (20 , ChronoUnit .MINUTES ));
298298 final FileId fileId = fileClient .createFile (contents );
299299 fileClient .updateExpirationTime (fileId , definedExpirationTime );
300300
301- //when
301+ // when
302302 final Instant expirationTime = fileClient .getExpirationTime (fileId );
303303
304- //then
304+ // then
305305 Assertions .assertTrue (expirationTime .isAfter (definedExpirationTime .minusSeconds (1 )));
306306 Assertions .assertTrue (expirationTime .isBefore (definedExpirationTime .plusSeconds (1 )));
307307 }
308308
309309 @ Test
310310 @ Disabled ("Always fails with AUTORENEW_DURATION_NOT_IN_RANGE. Needs to be investigated further." )
311311 void testUpdateExpirationTimeDoesNotChangeContent () throws Exception {
312- //given
313- final byte [] contents = "Hello, Hedera !" .getBytes ();
312+ // given
313+ final byte [] contents = "Hello, Hiero !" .getBytes ();
314314 final Instant definedExpirationTime = Instant .now ().plus (Duration .of (20 , ChronoUnit .MINUTES ));
315315 final FileId fileId = fileClient .createFile (contents );
316316 fileClient .updateExpirationTime (fileId , definedExpirationTime );
317317
318318 final byte [] result = fileClient .readFile (fileId );
319319
320- //then
320+ // then
321321 Assertions .assertArrayEquals (contents , result );
322322 }
323323
324+ @ Test
325+ void testUpdateExpirationTimeThrowsExceptionForPastExpirationTime () throws HieroException {
326+ // given
327+ final byte [] contents = "Hello, Hiero!" .getBytes ();
328+ final Instant definedExpirationTime = Instant .now ().minusSeconds (1 );
329+ final FileId fileId = fileClient .createFile (contents );
330+
331+ // then
332+ Assertions .assertThrows (
333+ IllegalArgumentException .class , () -> fileClient .updateExpirationTime (fileId , definedExpirationTime )
334+ );
335+ }
336+
337+ @ Test
338+ void testUpdateExpirationTimeThrowsExceptionForInvalidId () {
339+ // given
340+ final FileId fileId = FileId .fromString ("1.2.3" );
341+ final Instant definedExpirationTime = Instant .now ().plusSeconds (120 );
342+
343+ // then
344+ Assertions .assertThrows (
345+ HieroException .class , () -> fileClient .updateExpirationTime (fileId , definedExpirationTime )
346+ );
347+ }
348+
349+ @ Test
350+ void testUpdateExpirationTimeThrowsExceptionForNullArgs () throws HieroException {
351+ // given
352+ final byte [] contents = "Hello, Hiero!" .getBytes ();
353+ final Instant definedExpirationTime = Instant .now ().plusSeconds (120 );
354+ final FileId fileId = fileClient .createFile (contents );
355+
356+ // then
357+ Assertions .assertThrows (
358+ NullPointerException .class , () -> fileClient .updateExpirationTime (null , definedExpirationTime )
359+ );
360+ Assertions .assertThrows (
361+ NullPointerException .class , () -> fileClient .updateExpirationTime (fileId , null )
362+ );
363+ Assertions .assertThrows (
364+ NullPointerException .class , () -> fileClient .updateExpirationTime (null , null )
365+ );
366+ }
367+
324368 @ Test
325369 void testGetFileSize () throws HieroException {
326370 final byte [] contents = "Hello, Hiero!" .getBytes ();
0 commit comments