Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/main/java/sbt/testing/OptionalThrowable.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ public final class OptionalThrowable implements Serializable {

/**
* Constructs an <code>OptionalThrowable</code> containing a <code>Throwable</code>.
* @param exception if null an empty OptionalThrowable will be created
* @see sbt.testing.OptionalThrowable#isEmpty()
*/
public OptionalThrowable(Throwable exception) {
if (exception == null) {
throw new NullPointerException("Cannot pass a null exception to OptionalThrowable's constructor.");
}
this.exception = exception;
}

Expand Down
7 changes: 3 additions & 4 deletions src/test/scala/sbt/testing/OptionalThrowableSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ class OptionalThrowableSpec extends UnitSpec {
}
}
}
def `should throw NPE from constructor if null passed` {
a [NullPointerException] should be thrownBy {
new OptionalThrowable(null)
}
def `should be empty and not-defined if constructed with null` {
new OptionalThrowable(null).isEmpty shouldBe true
new OptionalThrowable(null).isDefined shouldBe false
}
def `should have a properly behaving equals method` {
def1 shouldEqual def1
Expand Down