diff --git a/changelog/@unreleased/pr-607.v2.yml b/changelog/@unreleased/pr-607.v2.yml
new file mode 100644
index 00000000..25051505
--- /dev/null
+++ b/changelog/@unreleased/pr-607.v2.yml
@@ -0,0 +1,6 @@
+type: feature
+feature:
+ description: '`LoggableExceptionAssert` now contains a `hasNoArgs` method for asserting
+ that an exception has no args.'
+ links:
+ - https://github.com/palantir/safe-logging/pull/607
diff --git a/preconditions-assertj/src/main/java/com/palantir/logsafe/testing/LoggableExceptionAssert.java b/preconditions-assertj/src/main/java/com/palantir/logsafe/testing/LoggableExceptionAssert.java
index ba6cf381..8ff99eb9 100755
--- a/preconditions-assertj/src/main/java/com/palantir/logsafe/testing/LoggableExceptionAssert.java
+++ b/preconditions-assertj/src/main/java/com/palantir/logsafe/testing/LoggableExceptionAssert.java
@@ -40,7 +40,7 @@ private LoggableExceptionAssert(T actual) {
}
/**
- * Verifies that the actual group contains exactly the given values and nothing else, in any order.
+ * Verifies that the actual exception contains exactly the given args and nothing else, in any order.
*
* @param args the given arguments.
* @return {@code this} assertion object
@@ -68,7 +68,7 @@ public LoggableExceptionAssert hasArgs(Arg>... args) {
}
/**
- * Verifies that the actual group contains the given values, in any order.
+ * Verifies that the actual exception contains the given args, in any order.
*
* @param args the given arguments.
* @return {@code this} assertion object
@@ -85,6 +85,16 @@ public LoggableExceptionAssert containsArgs(Arg>... args) {
return this;
}
+ /**
+ * Verifies that the actual exception does not contain any args.
+ */
+ public LoggableExceptionAssert hasNoArgs() {
+ isNotNull();
+
+ argsAssert.isEmpty();
+ return this;
+ }
+
public LoggableExceptionAssert hasLogMessage(String logMessage) {
isNotNull();
diff --git a/preconditions-assertj/src/test/java/com/palantir/logsafe/testing/LoggableExceptionAssertionsTest.java b/preconditions-assertj/src/test/java/com/palantir/logsafe/testing/LoggableExceptionAssertionsTest.java
index 2cf72e79..6aaca816 100755
--- a/preconditions-assertj/src/test/java/com/palantir/logsafe/testing/LoggableExceptionAssertionsTest.java
+++ b/preconditions-assertj/src/test/java/com/palantir/logsafe/testing/LoggableExceptionAssertionsTest.java
@@ -58,11 +58,19 @@ public void testIllegalArgumentException(LoggableExceptionAssert assertion) {
- assertion.isInstanceOf(SafeNullPointerException.class).hasMessage("").hasExactlyArgs();
+ assertion
+ .isInstanceOf(SafeNullPointerException.class)
+ .hasMessage("")
+ .hasExactlyArgs()
+ .hasNoArgs();
}
public void testIllegalStateException(LoggableExceptionAssert assertion) {
- assertion.isInstanceOf(SafeIllegalStateException.class).hasMessage("").hasExactlyArgs();
+ assertion
+ .isInstanceOf(SafeIllegalStateException.class)
+ .hasMessage("")
+ .hasExactlyArgs()
+ .hasNoArgs();
}
public void testLoggableException(LoggableExceptionAssert assertion) {