Skip to content

Commit ca5babb

Browse files
Migrate to AssertJ
1 parent 9f91852 commit ca5babb

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/test/java/org/gridsuite/gateway/ElementAccessControlTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
import java.util.UUID;
3333

3434
import static com.github.tomakehurst.wiremock.client.WireMock.*;
35-
import static org.junit.jupiter.api.Assertions.assertEquals;
36-
import static org.junit.jupiter.api.Assertions.assertThrows;
3735

3836
/**
3937
* @author Slimane Amar <slimane.amar at rte-france.com>
@@ -524,10 +522,7 @@ void testDeleteElements() {
524522

525523
@Test
526524
void testAccessControlInfos() {
527-
List<UUID> emptyList = List.of();
528-
529-
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> AccessControlInfos.create(emptyList));
530-
assertEquals("List of elements is empty", exception.getMessage());
525+
assertThatIllegalArgumentException().isThrownBy(() -> AccessControlInfos.create(List.of())).withMessage("List of elements is empty");
531526
}
532527

533528
private void initStubForJwk() {

src/test/java/org/gridsuite/gateway/TokenValidationTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.nimbusds.jose.jwk.gen.RSAKeyGenerator;
1919
import com.nimbusds.jwt.JWTClaimsSet;
2020
import com.nimbusds.jwt.SignedJWT;
21-
import org.junit.jupiter.api.Assertions;
21+
import org.assertj.core.api.WithAssertions;
2222
import org.junit.jupiter.api.BeforeEach;
2323
import org.junit.jupiter.api.Test;
2424
import org.springframework.beans.factory.annotation.Autowired;
@@ -73,7 +73,7 @@
7373
"allowed-issuers=http://localhost:${wiremock.server.port}"
7474
})
7575
@AutoConfigureWireMock(port = 0)
76-
class TokenValidationTest {
76+
class TokenValidationTest implements WithAssertions {
7777

7878
@Value("${wiremock.server.port}")
7979
int port;
@@ -186,11 +186,11 @@ private void testWebsocket(String name) throws InterruptedException {
186186
}
187187
}
188188
if (!done) {
189-
Assertions.fail("Wiremock didn't receive the websocket connection");
189+
fail("Wiremock didn't receive the websocket connection");
190190
}
191191
try {
192192
wsconnection.timeout(Duration.ofMillis(100)).block();
193-
Assertions.fail("websocket client was closed but should remain open");
193+
fail("websocket client was closed but should remain open");
194194
} catch (Exception ignored) {
195195
//should timeout
196196
}
@@ -550,7 +550,7 @@ void invalidToken() {
550550
.exchange()
551551
.expectStatus().isEqualTo(401);
552552

553-
//test with a incorrect Authorization value
553+
//test with an incorrect Authorization value
554554
webClient
555555
.get().uri("case/v1/cases")
556556
.header("Authorization", token)
@@ -559,9 +559,8 @@ void invalidToken() {
559559

560560
// test without a token
561561
WebSocketClient client = new StandardWebSocketClient();
562-
client.execute(URI.create("ws://localhost:" +
563-
this.localServerPort + "/study-notification/notify"),
564-
ws -> ws.receive().then()).doOnSuccess(s -> Assertions.fail("Should have thrown"));
562+
client.execute(URI.create("ws://localhost:" + this.localServerPort + "/study-notification/notify"), ws -> ws.receive().then())
563+
.doOnSuccess(s -> fail("Should have thrown"));
565564
}
566565

567566
@Test

0 commit comments

Comments
 (0)