Optimize AssertJ exception checks

This commit is contained in:
Richard Körber
2023-05-07 09:25:04 +02:00
parent aa5e78c525
commit c26d6b1f8a
5 changed files with 22 additions and 24 deletions

View File

@@ -14,8 +14,7 @@
package org.shredzone.acme4j.smime.csr;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.ByteArrayOutputStream;
@@ -155,16 +154,16 @@ public class SMIMECSRBuilderTest {
assertThat(builder.toString()).isEqualTo(",TYPE=SIGNING_AND_ENCRYPTION");
assertThatExceptionOfType(NullPointerException.class)
assertThatNullPointerException()
.as("addValue(String, String)")
.isThrownBy(() -> new SMIMECSRBuilder().addValue((String) null, "value"));
assertThatExceptionOfType(NullPointerException.class)
assertThatNullPointerException()
.as("addValue(ASN1ObjectIdentifier, String)")
.isThrownBy(() -> new SMIMECSRBuilder().addValue((ASN1ObjectIdentifier) null, "value"));
assertThatExceptionOfType(NullPointerException.class)
assertThatNullPointerException()
.as("addValue(String, null)")
.isThrownBy(() -> new SMIMECSRBuilder().addValue("C", null));
assertThatExceptionOfType(IllegalArgumentException.class)
assertThatIllegalArgumentException()
.as("addValue(String, null)")
.isThrownBy(() -> new SMIMECSRBuilder().addValue("UNKNOWNATT", "val"))
.withMessage(invAttNameExMessage);

View File

@@ -234,7 +234,7 @@ public class EmailProcessorTest extends SMIMETests {
@Test
public void textNoChallengeFails1() {
assertThatExceptionOfType(IllegalStateException.class)
assertThatIllegalStateException()
.isThrownBy(() -> {
var processor = EmailProcessor.plainMessage(message);
processor.getToken();
@@ -244,7 +244,7 @@ public class EmailProcessorTest extends SMIMETests {
@Test
public void textNoChallengeFails2() {
assertThatExceptionOfType(IllegalStateException.class)
assertThatIllegalStateException()
.isThrownBy(() -> {
var processor = EmailProcessor.plainMessage(message);
processor.getAuthorization();
@@ -254,7 +254,7 @@ public class EmailProcessorTest extends SMIMETests {
@Test
public void textNoChallengeFails3() {
assertThatExceptionOfType(IllegalStateException.class)
assertThatIllegalStateException()
.isThrownBy(() -> {
var processor = EmailProcessor.plainMessage(message);
processor.respond();