Skip to content

Commit 330bd38

Browse files
authored
Improve readability of testReadMarkerCompatibility (#4759)
* Refactor Improves the readability of the test. Replaces manual exception handling with the testing framework's built-in features (e.g., assertThrows), improving readability, maintainability, and debugging efficiency. Signed-off-by: pedro_Simoes <pelusimoes3@gmail.com> Signed-off-by: pedro_Simoes <115429183+pedrinhoeu@users.noreply.github.com>
1 parent 5ee7151 commit 330bd38

File tree

1 file changed

+7
-11
lines changed
  • janusgraph-backend-testutils/src/main/java/org/janusgraph/diskstorage/log

1 file changed

+7
-11
lines changed

janusgraph-backend-testutils/src/main/java/org/janusgraph/diskstorage/log/LogTest.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import static org.junit.jupiter.api.Assertions.assertEquals;
4141
import static org.junit.jupiter.api.Assertions.assertNotNull;
4242
import static org.junit.jupiter.api.Assertions.assertTrue;
43-
import static org.junit.jupiter.api.Assertions.fail;
43+
import static org.junit.jupiter.api.Assertions.assertThrows;
4444

4545
/**
4646
* Tests general log implementations
@@ -228,16 +228,12 @@ public void testFuzzMessagesSerial() throws Exception {
228228
@Test
229229
public void testReadMarkerCompatibility() throws Exception {
230230
Log l1 = manager.openLog("testx");
231-
l1.registerReader(ReadMarker.fromIdentifierOrNow("mark"),new StoringReader(0));
232-
l1.registerReader(ReadMarker.fromIdentifierOrTime("mark", Instant.now().minusMillis(100)),new StoringReader(1));
233-
try {
234-
l1.registerReader(ReadMarker.fromIdentifierOrNow("other"));
235-
fail();
236-
} catch (IllegalArgumentException ignored) {}
237-
try {
238-
l1.registerReader(ReadMarker.fromTime(Instant.now().minusMillis(100)));
239-
fail();
240-
} catch (IllegalArgumentException ignored) {}
231+
l1.registerReader(ReadMarker.fromIdentifierOrNow("mark"), new StoringReader(0));
232+
l1.registerReader(ReadMarker.fromIdentifierOrTime("mark", Instant.now().minusMillis(100)), new StoringReader(1));
233+
234+
assertThrows(IllegalArgumentException.class, () -> l1.registerReader(ReadMarker.fromIdentifierOrNow("other")));
235+
assertThrows(IllegalArgumentException.class, () -> l1.registerReader(ReadMarker.fromTime(Instant.now().minusMillis(100))));
236+
241237
l1.registerReader(ReadMarker.fromNow(), new StoringReader(2));
242238
}
243239

0 commit comments

Comments
 (0)