Use diamond type
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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)) {
|
||||
|
||||
+2
-2
@@ -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() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
+2
-2
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user