refactor: AssertJ best practices

Use this link to re-run the recipe: https://app.moderne.io/recipes/builder/bGVuS?organizationId=RGVmYXVsdA%3D%3D

Co-authored-by: Moderne <team@moderne.io>
This commit is contained in:
Tim te Beek
2023-08-06 19:29:47 +00:00
committed by Josh Cummings
parent 36a488a360
commit 9df9cb5aed
69 changed files with 336 additions and 335 deletions

View File

@@ -46,7 +46,7 @@ public class InetOrgPersonTests {
InetOrgPerson p2 = (InetOrgPerson) essence.createUserDetails();
Set<InetOrgPerson> set = new HashSet<>();
set.add(p);
assertThat(set.contains(p2)).isTrue();
assertThat(set).contains(p2);
}
@Test

View File

@@ -60,7 +60,7 @@ public class LdapUserDetailsServiceTests {
UserDetails user = service.loadUserByUsername("doesntmatterwegetjoeanyway");
Set<String> authorities = AuthorityUtils.authorityListToSet(user.getAuthorities());
assertThat(authorities).hasSize(1);
assertThat(authorities.contains("ROLE_FROM_POPULATOR")).isTrue();
assertThat(authorities).contains("ROLE_FROM_POPULATOR");
}
@Test

View File

@@ -47,7 +47,7 @@ public class UserDetailsServiceLdapAuthoritiesPopulatorTests {
UserDetailsServiceLdapAuthoritiesPopulator populator = new UserDetailsServiceLdapAuthoritiesPopulator(uds);
Collection<? extends GrantedAuthority> auths = populator.getGrantedAuthorities(new DirContextAdapter(), "joe");
assertThat(auths).hasSize(1);
assertThat(AuthorityUtils.authorityListToSet(auths).contains("ROLE_USER")).isTrue();
assertThat(AuthorityUtils.authorityListToSet(auths)).contains("ROLE_USER");
}
}