-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improves error messages around modules
- Loading branch information
Showing
5 changed files
with
145 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...rifier-core/src/main/java/nl/jqno/equalsverifier/internal/exceptions/ModuleException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package nl.jqno.equalsverifier.internal.exceptions; | ||
|
||
/** Signals that a class was inaccessible. */ | ||
@SuppressWarnings("serial") | ||
public class ModuleException extends MessagingException { | ||
|
||
public ModuleException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ModulesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package nl.jqno.equalsverifier.integration.extended_contract; | ||
|
||
import java.text.AttributedString; | ||
import java.util.Objects; | ||
import nl.jqno.equalsverifier.EqualsVerifier; | ||
import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/* | ||
* Let's hope nobody needs prefab values for `java.text.AttributedString`, | ||
* because we need a class here from je Java APIs that doesn't already | ||
* have prefab values. | ||
*/ | ||
public class ModulesTest { | ||
|
||
@Test | ||
public void giveProperErrorMessage_whenClassUnderTestIsInaccessible() { | ||
ExpectedException | ||
.when(() -> EqualsVerifier.forClass(AttributedString.class).verify()) | ||
.assertFailure() | ||
.assertMessageContains("The class", "Consider opening"); | ||
} | ||
|
||
@Test | ||
public void giveProperErrorMessage_whenFieldIsInaccessible() { | ||
ExpectedException | ||
.when(() -> EqualsVerifier.forClass(InaccessibleContainer.class).verify()) | ||
.assertFailure() | ||
.assertMessageContains("Field x", "Consider opening", "add prefab values"); | ||
} | ||
|
||
static final class InaccessibleContainer { | ||
|
||
private final AttributedString x; | ||
|
||
public InaccessibleContainer(AttributedString x) { | ||
this.x = x; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof InaccessibleContainer)) { | ||
return false; | ||
} | ||
InaccessibleContainer other = (InaccessibleContainer) obj; | ||
return Objects.equals(x, other.x); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(x); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters