1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Use diamond type

This commit is contained in:
Johnny Lim
2017-11-20 02:25:30 +09:00
committed by Rob Winch
parent cfe40358bd
commit 57353d18e5
221 changed files with 423 additions and 428 deletions
@@ -56,7 +56,7 @@ import org.springframework.util.Assert;
*/
public final class TestSecurityContextHolder {
private static final ThreadLocal<SecurityContext> contextHolder = new ThreadLocal<SecurityContext>();
private static final ThreadLocal<SecurityContext> contextHolder = new ThreadLocal<>();
/**
* Clears the {@link SecurityContext} from {@link TestSecurityContextHolder} and
@@ -46,7 +46,7 @@ final class WithMockUserSecurityContextFactory implements
+ " cannot have null username on both username and value properites");
}
List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
for (String authority : withUser.authorities()) {
grantedAuthorities.add(new SimpleGrantedAuthority(authority));
}
@@ -71,4 +71,4 @@ final class WithMockUserSecurityContextFactory implements
context.setAuthentication(authentication);
return context;
}
}
}
@@ -796,7 +796,7 @@ public final class SecurityMockMvcRequestPostProcessors {
* @return the UserRequestPostProcessor for further customizations
*/
public UserRequestPostProcessor roles(String... roles) {
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(
List<GrantedAuthority> authorities = new ArrayList<>(
roles.length);
for (String role : roles) {
if (role.startsWith(ROLE_PREFIX)) {
@@ -213,7 +213,7 @@ public final class SecurityMockMvcResultMatchers {
* @return the {@link AuthenticatedMatcher} for further customization
*/
public AuthenticatedMatcher withRoles(String... roles) {
Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
Collection<GrantedAuthority> authorities = new ArrayList<>();
for (String role : roles) {
authorities.add(new SimpleGrantedAuthority("ROLE_" + role));
}
@@ -251,4 +251,4 @@ public final class SecurityMockMvcResultMatchers {
private SecurityMockMvcResultMatchers() {
}
}
}
@@ -114,7 +114,7 @@ public class WithSecurityContextTestExcecutionListenerTests {
AbstractTestExecutionListener otherListener = new AbstractTestExecutionListener() {
};
List<TestExecutionListener> listeners = new ArrayList<TestExecutionListener>();
List<TestExecutionListener> listeners = new ArrayList<>();
listeners.add(otherListener);
listeners.add(this.listener);
@@ -62,7 +62,7 @@ public class SecurityMockWithAuthoritiesMvcResultMatchersTests {
@Test
public void withAuthoritiesNotOrderSensitive() throws Exception {
List<SimpleGrantedAuthority> grantedAuthorities = new ArrayList<SimpleGrantedAuthority>();
List<SimpleGrantedAuthority> grantedAuthorities = new ArrayList<>();
grantedAuthorities.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
grantedAuthorities.add(new SimpleGrantedAuthority("ROLE_SELLER"));
mockMvc.perform(formLogin())
@@ -71,7 +71,7 @@ public class SecurityMockWithAuthoritiesMvcResultMatchersTests {
@Test(expected = AssertionError.class)
public void withAuthoritiesFailsIfNotAllRoles() throws Exception {
List<SimpleGrantedAuthority> grantedAuthorities = new ArrayList<SimpleGrantedAuthority>();
List<SimpleGrantedAuthority> grantedAuthorities = new ArrayList<>();
grantedAuthorities.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
mockMvc.perform(formLogin()).andExpect(authenticated().withAuthorities(grantedAuthorities));
}