From 8ef3436f960686a41a25925639c0c4ceca4bc56d Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Sun, 26 Dec 2021 11:55:24 +0100 Subject: [PATCH] add ID to exception message --- .../main/java/de/cotto/lndmanagej/model/ChannelId.java | 2 +- .../java/de/cotto/lndmanagej/model/ChannelIdTest.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/model/src/main/java/de/cotto/lndmanagej/model/ChannelId.java b/model/src/main/java/de/cotto/lndmanagej/model/ChannelId.java index c94d0862..459f93f3 100644 --- a/model/src/main/java/de/cotto/lndmanagej/model/ChannelId.java +++ b/model/src/main/java/de/cotto/lndmanagej/model/ChannelId.java @@ -15,7 +15,7 @@ public final class ChannelId implements Comparable { public static ChannelId fromShortChannelId(long shortChannelId) { if (shortChannelId < NOT_BEFORE) { - throw new IllegalArgumentException("Illegal channel ID"); + throw new IllegalArgumentException("Illegal channel ID " + shortChannelId); } return new ChannelId(shortChannelId); } diff --git a/model/src/test/java/de/cotto/lndmanagej/model/ChannelIdTest.java b/model/src/test/java/de/cotto/lndmanagej/model/ChannelIdTest.java index e4aad63c..abd6abea 100644 --- a/model/src/test/java/de/cotto/lndmanagej/model/ChannelIdTest.java +++ b/model/src/test/java/de/cotto/lndmanagej/model/ChannelIdTest.java @@ -11,7 +11,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException class ChannelIdTest { - private static final String ILLEGAL_CHANNEL_ID = "Illegal channel ID"; + private static final String ILLEGAL_CHANNEL_ID = "Illegal channel ID "; private static final String UNEXPECTED_FORMAT = "Unexpected format for compact channel ID"; @Nested @@ -28,7 +28,7 @@ class ChannelIdTest { void before_2016() { assertThatIllegalArgumentException().isThrownBy( () -> ChannelId.fromCompactForm("391176:999:999") - ).withMessage(ILLEGAL_CHANNEL_ID); + ).withMessageStartingWith(ILLEGAL_CHANNEL_ID); } @Test @@ -70,21 +70,21 @@ class ChannelIdTest { void negative() { assertThatIllegalArgumentException().isThrownBy( () -> ChannelId.fromShortChannelId(-1L) - ).withMessage(ILLEGAL_CHANNEL_ID); + ).withMessageStartingWith(ILLEGAL_CHANNEL_ID); } @Test void zero() { assertThatIllegalArgumentException().isThrownBy( () -> ChannelId.fromShortChannelId(0L) - ).withMessage(ILLEGAL_CHANNEL_ID); + ).withMessageStartingWith(ILLEGAL_CHANNEL_ID); } @Test void before_2016() { assertThatIllegalArgumentException().isThrownBy( () -> ChannelId.fromShortChannelId(430_103_660_018_532_351L) - ).withMessage(ILLEGAL_CHANNEL_ID); + ).withMessageStartingWith(ILLEGAL_CHANNEL_ID); } @Test