Skip to content

Commit c2c34bb

Browse files
committed
Changed deprecated ExpectedException.none
1 parent 6ed5b10 commit c2c34bb

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
package com.mastercard.developer.encryption;
2-
3-
import org.junit.Rule;
42
import org.junit.Test;
5-
import org.junit.rules.ExpectedException;
63

74
import java.io.IOException;
85

9-
import static org.hamcrest.core.Is.isA;
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
108

119
public class EncryptionExceptionTest {
1210

13-
@Rule
14-
public ExpectedException expectedException = ExpectedException.none();
15-
1611
@Test
17-
public void testConstructor() throws Exception {
18-
19-
expectedException.expect(EncryptionException.class);
20-
expectedException.expectMessage("Something happened!");
21-
expectedException.expectCause(isA(IOException.class));
22-
23-
throw new EncryptionException("Something happened!", new IOException());
12+
public void testConstructor() {
13+
try {
14+
throw new EncryptionException("Something happened!", new IOException());
15+
} catch (EncryptionException e) {
16+
// Assert that the exception message is correct
17+
assertEquals("Something happened!", e.getMessage());
18+
19+
// Assert that the cause of the exception is of type IOException
20+
assertTrue(e.getCause() instanceof IOException);
21+
}
2422
}
2523
}

0 commit comments

Comments
 (0)