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

View File

@@ -51,7 +51,7 @@ public class PortMapperImplTests {
PortMapperImpl portMapper = new PortMapperImpl();
try {
portMapper.setPortMappings(new HashMap<String, String>());
portMapper.setPortMappings(new HashMap<>());
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException expected) {
@@ -81,7 +81,7 @@ public class PortMapperImplTests {
@Test
public void testRejectsOutOfRangeMappings() {
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("79", "80559");
try {
@@ -102,7 +102,7 @@ public class PortMapperImplTests {
@Test
public void testSupportsCustomMappings() {
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("79", "442");
portMapper.setPortMappings(map);

View File

@@ -148,7 +148,7 @@ public class RetryWithHttpEntryPointTests {
MockHttpServletResponse response = new MockHttpServletResponse();
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("8888", "9999");
portMapper.setPortMappings(map);

View File

@@ -138,7 +138,7 @@ public class RetryWithHttpsEntryPointTests {
MockHttpServletResponse response = new MockHttpServletResponse();
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("8888", "9999");
portMapper.setPortMappings(map);

View File

@@ -60,7 +60,7 @@ public class DelegatingEvaluationContextTests {
@Test
public void getConstructorResolvers() {
List<ConstructorResolver> expected = new ArrayList<ConstructorResolver>();
List<ConstructorResolver> expected = new ArrayList<>();
when(this.delegate.getConstructorResolvers()).thenReturn(expected);
assertThat(this.context.getConstructorResolvers()).isEqualTo(expected);
@@ -68,7 +68,7 @@ public class DelegatingEvaluationContextTests {
@Test
public void getMethodResolvers() {
List<MethodResolver> expected = new ArrayList<MethodResolver>();
List<MethodResolver> expected = new ArrayList<>();
when(this.delegate.getMethodResolvers()).thenReturn(expected);
assertThat(this.context.getMethodResolvers()).isEqualTo(expected);
@@ -76,7 +76,7 @@ public class DelegatingEvaluationContextTests {
@Test
public void getPropertyAccessors() {
List<PropertyAccessor> expected = new ArrayList<PropertyAccessor>();
List<PropertyAccessor> expected = new ArrayList<>();
when(this.delegate.getPropertyAccessors()).thenReturn(expected);
assertThat(this.context.getPropertyAccessors()).isEqualTo(expected);

View File

@@ -44,7 +44,7 @@ public class DelegatingAuthenticationEntryPointTests {
@Before
public void before() {
defaultEntryPoint = mock(AuthenticationEntryPoint.class);
entryPoints = new LinkedHashMap<RequestMatcher, AuthenticationEntryPoint>();
entryPoints = new LinkedHashMap<>();
daep = new DelegatingAuthenticationEntryPoint(entryPoints);
daep.setDefaultEntryPoint(defaultEntryPoint);
}

View File

@@ -43,7 +43,7 @@ public class ExceptionMappingAuthenticationFailureHandlerTests {
@Test
public void exceptionMapIsUsedIfMappingExists() throws Exception {
ExceptionMappingAuthenticationFailureHandler fh = new ExceptionMappingAuthenticationFailureHandler();
HashMap<String, String> mapping = new HashMap<String, String>();
HashMap<String, String> mapping = new HashMap<>();
mapping.put(
"org.springframework.security.authentication.BadCredentialsException",
"/badcreds");

View File

@@ -109,7 +109,7 @@ public class LoginUrlAuthenticationEntryPointTests {
assertThat(response.getRedirectedUrl()).isEqualTo("https://www.example.com:8443/bigWebApp/hello");
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("8888", "9999");
portMapper.setPortMappings(map);
response = new MockHttpServletResponse();

View File

@@ -63,7 +63,7 @@ public class DelegatingLogoutSuccessHandlerTests {
@Before
public void setup() {
LinkedHashMap<RequestMatcher, LogoutSuccessHandler> matcherToHandler = new LinkedHashMap<RequestMatcher, LogoutSuccessHandler>();
LinkedHashMap<RequestMatcher, LogoutSuccessHandler> matcherToHandler = new LinkedHashMap<>();
matcherToHandler.put(this.matcher, this.handler);
matcherToHandler.put(this.matcher2, this.handler2);
this.delegatingHandler = new DelegatingLogoutSuccessHandler(matcherToHandler);

View File

@@ -55,7 +55,7 @@ public class PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetailsTests {
private HttpServletRequest getRequest(final String userName, final String[] aRoles) {
MockHttpServletRequest req = new MockHttpServletRequest() {
private Set<String> roles = new HashSet<String>(Arrays.asList(aRoles));
private Set<String> roles = new HashSet<>(Arrays.asList(aRoles));
public boolean isUserInRole(String arg0) {
return roles.contains(arg0);

View File

@@ -127,7 +127,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSourceTests {
assertThat(gas).hasSize(expectedRoles.length);
Collection<String> expectedRolesColl = Arrays.asList(expectedRoles);
Collection<String> gasRolesSet = new HashSet<String>();
Collection<String> gasRolesSet = new HashSet<>();
for (int i = 0; i < gas.size(); i++) {
gasRolesSet.add(gas.get(i).getAuthority());
}
@@ -170,7 +170,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSourceTests {
private HttpServletRequest getRequest(final String userName, final String[] aRoles) {
MockHttpServletRequest req = new MockHttpServletRequest() {
private Set<String> roles = new HashSet<String>(Arrays.asList(aRoles));
private Set<String> roles = new HashSet<>(Arrays.asList(aRoles));
public boolean isUserInRole(String arg0) {
return roles.contains(arg0);

View File

@@ -53,7 +53,7 @@ public class J2eePreAuthenticatedProcessingFilterTests {
final String[] aRoles) {
MockHttpServletRequest req = new MockHttpServletRequest() {
private Set<String> roles = new HashSet<String>(Arrays.asList(aRoles));
private Set<String> roles = new HashSet<>(Arrays.asList(aRoles));
public boolean isUserInRole(String arg0) {
return roles.contains(arg0);

View File

@@ -232,7 +232,7 @@ public class SwitchUserFilterTests {
"dano", "hawaii50", ROLES_12);
// set current user (Admin)
List<GrantedAuthority> adminAuths = new ArrayList<GrantedAuthority>();
List<GrantedAuthority> adminAuths = new ArrayList<>();
adminAuths.addAll(ROLES_12);
adminAuths.add(new SwitchUserGrantedAuthority("PREVIOUS_ADMINISTRATOR", source));
UsernamePasswordAuthenticationToken admin = new UsernamePasswordAuthenticationToken(
@@ -394,7 +394,7 @@ public class SwitchUserFilterTests {
public Collection<GrantedAuthority> modifyGrantedAuthorities(
UserDetails targetUser, Authentication currentAuthentication,
Collection<? extends GrantedAuthority> authoritiesToBeGranted) {
List<GrantedAuthority> auths = new ArrayList<GrantedAuthority>();
List<GrantedAuthority> auths = new ArrayList<>();
auths.add(new SimpleGrantedAuthority("ROLE_NEW"));
return auths;
}

View File

@@ -33,7 +33,7 @@ import org.springframework.mock.web.MockHttpServletRequest;
* @author Luke Taylor
*/
public class RequestWrapperTests {
private static Map<String, String> testPaths = new LinkedHashMap<String, String>();
private static Map<String, String> testPaths = new LinkedHashMap<>();
@BeforeClass
// Some of these may be unrealistic values, but we can't be sure because of the

View File

@@ -48,7 +48,7 @@ public class HeaderWriterFilterTests {
@Test(expected = IllegalArgumentException.class)
public void noHeadersConfigured() throws Exception {
List<HeaderWriter> headerWriters = new ArrayList<HeaderWriter>();
List<HeaderWriter> headerWriters = new ArrayList<>();
new HeaderWriterFilter(headerWriters);
}
@@ -59,7 +59,7 @@ public class HeaderWriterFilterTests {
@Test
public void additionalHeadersShouldBeAddedToTheResponse() throws Exception {
List<HeaderWriter> headerWriters = new ArrayList<HeaderWriter>();
List<HeaderWriter> headerWriters = new ArrayList<>();
headerWriters.add(writer1);
headerWriters.add(writer2);

View File

@@ -37,7 +37,7 @@ public class HpkpHeaderWriterTests {
private static final Map<String, String> DEFAULT_PINS;
static
{
Map<String, String> defaultPins = new LinkedHashMap<String, String>();
Map<String, String> defaultPins = new LinkedHashMap<>();
defaultPins.put("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=", "sha256");
DEFAULT_PINS = Collections.unmodifiableMap(defaultPins);
}
@@ -54,7 +54,7 @@ public class HpkpHeaderWriterTests {
writer = new HpkpHeaderWriter();
Map<String, String> defaultPins = new LinkedHashMap<String, String>();
Map<String, String> defaultPins = new LinkedHashMap<>();
defaultPins.put("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=", "sha256");
writer.setPins(defaultPins);

View File

@@ -33,7 +33,7 @@ public class WhiteListedAllowFromStrategyTests {
@Test(expected = IllegalArgumentException.class)
public void emptyListShouldThrowException() {
new WhiteListedAllowFromStrategy(new ArrayList<String>());
new WhiteListedAllowFromStrategy(new ArrayList<>());
}
@Test(expected = IllegalArgumentException.class)
@@ -43,7 +43,7 @@ public class WhiteListedAllowFromStrategyTests {
@Test
public void listWithSingleElementShouldMatch() {
List<String> allowed = new ArrayList<String>();
List<String> allowed = new ArrayList<>();
allowed.add("http://www.test.com");
WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
strategy.setAllowFromParameterName("from");
@@ -56,7 +56,7 @@ public class WhiteListedAllowFromStrategyTests {
@Test
public void listWithMultipleElementShouldMatch() {
List<String> allowed = new ArrayList<String>();
List<String> allowed = new ArrayList<>();
allowed.add("http://www.test.com");
allowed.add("http://www.springsource.org");
WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
@@ -70,7 +70,7 @@ public class WhiteListedAllowFromStrategyTests {
@Test
public void listWithSingleElementShouldNotMatch() {
List<String> allowed = new ArrayList<String>();
List<String> allowed = new ArrayList<>();
allowed.add("http://www.test.com");
WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
strategy.setAllowFromParameterName("from");
@@ -83,7 +83,7 @@ public class WhiteListedAllowFromStrategyTests {
@Test
public void requestWithoutParameterShouldNotMatch() {
List<String> allowed = new ArrayList<String>();
List<String> allowed = new ArrayList<>();
allowed.add("http://www.test.com");
WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
strategy.setAllowFromParameterName("from");

View File

@@ -122,7 +122,7 @@ public class JaasApiIntegrationFilterTests {
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
return new AppConfigurationEntry[] { new AppConfigurationEntry(
TestLoginModule.class.getName(), LoginModuleControlFlag.REQUIRED,
new HashMap<String, String>()) };
new HashMap<>()) };
}
};
LoginContext ctx = new LoginContext("SubjectDoAsFilterTest", authenticatedSubject,

View File

@@ -75,7 +75,7 @@ public class SavedCookieMixinTests extends AbstractMixinTests {
@Test
public void serializeSavedCookieWithList() throws JsonProcessingException, JSONException {
List<SavedCookie> savedCookies = new ArrayList<SavedCookie>();
List<SavedCookie> savedCookies = new ArrayList<>();
savedCookies.add(new SavedCookie(new Cookie("SESSION", "123456789")));
String actualJson = mapper.writeValueAsString(savedCookies);
JSONAssert.assertEquals(COOKIES_JSON, actualJson, true);

View File

@@ -42,7 +42,7 @@ public class CsrfRequestDataValueProcessorTests {
private CsrfRequestDataValueProcessor processor = new CsrfRequestDataValueProcessor();
private CsrfToken token = new DefaultCsrfToken("1", "a", "b");
private Map<String, String> expected = new HashMap<String, String>();
private Map<String, String> expected = new HashMap<>();
@Before
public void setup() {

View File

@@ -39,7 +39,7 @@ public class CsrfRequestDataValueProcessorTests {
private CsrfRequestDataValueProcessor processor;
private CsrfToken token;
private Map<String, String> expected = new HashMap<String, String>();
private Map<String, String> expected = new HashMap<>();
@Before
public void setup() {
@@ -129,7 +129,7 @@ public class CsrfRequestDataValueProcessorTests {
public void createGetExtraHiddenFieldsHasCsrfToken() {
CsrfToken token = new DefaultCsrfToken("1", "a", "b");
request.setAttribute(CsrfToken.class.getName(), token);
Map<String, String> expected = new HashMap<String, String>();
Map<String, String> expected = new HashMap<>();
expected.put(token.getParameterName(), token.getToken());
RequestDataValueProcessor processor = new CsrfRequestDataValueProcessor();