Skip to content

Commit a344dbd

Browse files
committed
Use AssertJ
Issue gh-3384
1 parent 8cbdcfe commit a344dbd

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/authentication/OpenSamlAuthenticationProviderTests.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454
import org.springframework.security.core.Authentication;
5555
import org.springframework.security.saml2.credentials.Saml2X509Credential;
5656

57-
import static org.junit.Assert.assertEquals;
58-
import static org.junit.Assert.assertTrue;
57+
import static org.assertj.core.api.Assertions.assertThat;
5958
import static org.mockito.ArgumentMatchers.any;
6059
import static org.mockito.Mockito.atLeastOnce;
6160
import static org.mockito.Mockito.mock;
@@ -95,18 +94,16 @@ public class OpenSamlAuthenticationProviderTests {
9594
@Test
9695
public void supportsWhenSaml2AuthenticationTokenThenReturnTrue() {
9796

98-
assertTrue(
99-
OpenSamlAuthenticationProvider.class + "should support " + Saml2AuthenticationToken.class,
100-
this.provider.supports(Saml2AuthenticationToken.class)
101-
);
97+
assertThat(this.provider.supports(Saml2AuthenticationToken.class))
98+
.withFailMessage(OpenSamlAuthenticationProvider.class + "should support " + Saml2AuthenticationToken.class)
99+
.isTrue();
102100
}
103101

104102
@Test
105103
public void supportsWhenNotSaml2AuthenticationTokenThenReturnFalse() {
106-
assertTrue(
107-
OpenSamlAuthenticationProvider.class + "should not support " + Authentication.class,
108-
!this.provider.supports(Authentication.class)
109-
);
104+
assertThat(!this.provider.supports(Authentication.class))
105+
.withFailMessage(OpenSamlAuthenticationProvider.class + "should not support " + Authentication.class)
106+
.isTrue();
110107
}
111108

112109
@Test
@@ -237,8 +234,8 @@ public void authenticateWhenAssertionContainsAttributesThenItSucceeds() {
237234
Instant registeredDate = Instant.ofEpochMilli(DateTime.parse("1970-01-01T00:00:00Z").getMillis());
238235
expected.put("registeredDate", Collections.singletonList(registeredDate));
239236

240-
assertEquals("John Doe", principal.getFirstAttribute("name"));
241-
assertEquals(expected, principal.getAttributes());
237+
assertThat((String) principal.getFirstAttribute("name")).isEqualTo("John Doe");
238+
assertThat(principal.getAttributes()).isEqualTo(expected);
242239
}
243240

244241
@Test

0 commit comments

Comments
 (0)