Explicit type can be replaced by <>
Issue: SPR-13188
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -170,7 +170,7 @@ public class CollectionFactoryTests {
|
||||
|
||||
@Test
|
||||
public void createApproximateCollectionFromNonEmptyHashSet() {
|
||||
HashSet<String> hashSet = new HashSet<String>();
|
||||
HashSet<String> hashSet = new HashSet<>();
|
||||
hashSet.add("foo");
|
||||
Collection<String> set = createApproximateCollection(hashSet, 2);
|
||||
assertThat(set.size(), is(0));
|
||||
@@ -196,7 +196,7 @@ public class CollectionFactoryTests {
|
||||
|
||||
@Test
|
||||
public void createApproximateMapFromNonEmptyHashMap() {
|
||||
Map<String, String> hashMap = new HashMap<String, String>();
|
||||
Map<String, String> hashMap = new HashMap<>();
|
||||
hashMap.put("foo", "bar");
|
||||
Map<String, String> map = createApproximateMap(hashMap, 2);
|
||||
assertThat(map.size(), is(0));
|
||||
@@ -210,7 +210,7 @@ public class CollectionFactoryTests {
|
||||
|
||||
@Test
|
||||
public void createApproximateMapFromNonEmptyEnumMap() {
|
||||
EnumMap<Color, String> enumMap = new EnumMap<Color, String>(Color.class);
|
||||
EnumMap<Color, String> enumMap = new EnumMap<>(Color.class);
|
||||
enumMap.put(Color.BLUE, "blue");
|
||||
Map<Color, String> colors = createApproximateMap(enumMap, 2);
|
||||
assertThat(colors.size(), is(0));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,7 +61,7 @@ public class GenericTypeResolverTests {
|
||||
|
||||
@Test
|
||||
public void nullIfNotResolvable() {
|
||||
GenericClass<String> obj = new GenericClass<String>();
|
||||
GenericClass<String> obj = new GenericClass<>();
|
||||
assertNull(resolveTypeArgument(obj.getClass(), GenericClass.class));
|
||||
}
|
||||
|
||||
@@ -82,13 +82,13 @@ public class GenericTypeResolverTests {
|
||||
Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class);
|
||||
MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0);
|
||||
assertEquals(MyInterfaceType.class,
|
||||
resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
|
||||
resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<>()));
|
||||
|
||||
Method intArrMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerArrayInputMessage",
|
||||
MyInterfaceType[].class);
|
||||
MethodParameter intArrMessageMethodParam = new MethodParameter(intArrMessageMethod, 0);
|
||||
assertEquals(MyInterfaceType[].class,
|
||||
resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
|
||||
resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap<>()));
|
||||
|
||||
Method genericArrMessageMethod = findMethod(MySimpleTypeWithMethods.class, "readGenericArrayInputMessage",
|
||||
Object[].class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -149,7 +149,7 @@ public class ResolvableTypeTests {
|
||||
|
||||
@Test
|
||||
public void forInstanceProvider() {
|
||||
ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType<String>(String.class));
|
||||
ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType<>(String.class));
|
||||
assertThat(type.getRawClass(), equalTo(MyGenericInterfaceType.class));
|
||||
assertThat(type.getGeneric().resolve(), equalTo(String.class));
|
||||
}
|
||||
@@ -401,7 +401,7 @@ public class ResolvableTypeTests {
|
||||
public void getInterfaces() throws Exception {
|
||||
ResolvableType type = ResolvableType.forClass(ExtendsList.class);
|
||||
assertThat(type.getInterfaces().length, equalTo(0));
|
||||
SortedSet<String> interfaces = new TreeSet<String>();
|
||||
SortedSet<String> interfaces = new TreeSet<>();
|
||||
for (ResolvableType interfaceType : type.getSuperType().getInterfaces()) {
|
||||
interfaces.add(interfaceType.toString());
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MapAnnotationAttributeExtractorTests extends AbstractAliasAwareAnno
|
||||
|
||||
@Test
|
||||
public void enrichAndValidateAttributesWithImplicitAliasesAndMinimalAttributes() {
|
||||
Map<String, Object> attributes = new HashMap<String, Object>();
|
||||
Map<String, Object> attributes = new HashMap<>();
|
||||
Map<String, Object> expectedAttributes = new HashMap<String, Object>() {{
|
||||
put("groovyScript", "");
|
||||
put("xmlFile", "");
|
||||
@@ -127,7 +127,7 @@ public class MapAnnotationAttributeExtractorTests extends AbstractAliasAwareAnno
|
||||
|
||||
// Declare aliases in an order that will cause enrichAndValidateAttributes() to
|
||||
// fail unless it considers all aliases in the set of implicit aliases.
|
||||
MultiValueMap<String, String> aliases = new LinkedMultiValueMap<String, String>();
|
||||
MultiValueMap<String, String> aliases = new LinkedMultiValueMap<>();
|
||||
aliases.put("xmlFile", Arrays.asList("value", "groovyScript", "location1", "location2", "location3"));
|
||||
aliases.put("groovyScript", Arrays.asList("value", "xmlFile", "location1", "location2", "location3"));
|
||||
aliases.put("value", Arrays.asList("xmlFile", "groovyScript", "location1", "location2", "location3"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,7 +38,7 @@ public class OrderSourceProviderTests {
|
||||
|
||||
@Test
|
||||
public void plainComparator() {
|
||||
List<Object> items = new ArrayList<Object>();
|
||||
List<Object> items = new ArrayList<>();
|
||||
C c = new C(5);
|
||||
C c2 = new C(-5);
|
||||
items.add(c);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -533,7 +533,7 @@ public class TypeDescriptorTests {
|
||||
public void elementTypePreserveContext() throws Exception {
|
||||
TypeDescriptor desc = new TypeDescriptor(getClass().getField("listPreserveContext"));
|
||||
assertEquals(Integer.class, desc.getElementTypeDescriptor().getElementTypeDescriptor().getType());
|
||||
List<Integer> value = new ArrayList<Integer>(3);
|
||||
List<Integer> value = new ArrayList<>(3);
|
||||
desc = desc.elementTypeDescriptor(value);
|
||||
assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
|
||||
assertNotNull(desc.getAnnotation(FieldAnnotation.class));
|
||||
@@ -551,7 +551,7 @@ public class TypeDescriptorTests {
|
||||
public void mapKeyTypePreserveContext() throws Exception {
|
||||
TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext"));
|
||||
assertEquals(Integer.class, desc.getMapKeyTypeDescriptor().getElementTypeDescriptor().getType());
|
||||
List<Integer> value = new ArrayList<Integer>(3);
|
||||
List<Integer> value = new ArrayList<>(3);
|
||||
desc = desc.getMapKeyTypeDescriptor(value);
|
||||
assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
|
||||
assertNotNull(desc.getAnnotation(FieldAnnotation.class));
|
||||
@@ -569,7 +569,7 @@ public class TypeDescriptorTests {
|
||||
public void mapValueTypePreserveContext() throws Exception {
|
||||
TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext"));
|
||||
assertEquals(Integer.class, desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getType());
|
||||
List<Integer> value = new ArrayList<Integer>(3);
|
||||
List<Integer> value = new ArrayList<>(3);
|
||||
desc = desc.getMapValueTypeDescriptor(value);
|
||||
assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
|
||||
assertNotNull(desc.getAnnotation(FieldAnnotation.class));
|
||||
@@ -841,19 +841,19 @@ public class TypeDescriptorTests {
|
||||
|
||||
public List<String> listOfString;
|
||||
|
||||
public List<List<String>> listOfListOfString = new ArrayList<List<String>>();
|
||||
public List<List<String>> listOfListOfString = new ArrayList<>();
|
||||
|
||||
public List<List> listOfListOfUnknown = new ArrayList<List>();
|
||||
public List<List> listOfListOfUnknown = new ArrayList<>();
|
||||
|
||||
public int[] intArray;
|
||||
|
||||
public List<String>[] arrayOfListOfString;
|
||||
|
||||
public List<Integer> listField = new ArrayList<Integer>();
|
||||
public List<Integer> listField = new ArrayList<>();
|
||||
|
||||
public Map<String, Integer> mapField = new HashMap<String, Integer>();
|
||||
public Map<String, Integer> mapField = new HashMap<>();
|
||||
|
||||
public Map<String, List<Integer>> nestedMapField = new HashMap<String, List<Integer>>();
|
||||
public Map<String, List<Integer>> nestedMapField = new HashMap<>();
|
||||
|
||||
public Map<List<Integer>, List<Long>> fieldMap;
|
||||
|
||||
@@ -879,9 +879,9 @@ public class TypeDescriptorTests {
|
||||
|
||||
public Map<CharSequence, Number> isAssignableMapKeyValueTypes;
|
||||
|
||||
public MultiValueMap<String, Integer> multiValueMap = new LinkedMultiValueMap<String, Integer>();
|
||||
public MultiValueMap<String, Integer> multiValueMap = new LinkedMultiValueMap<>();
|
||||
|
||||
public PassDownGeneric<Integer> passDownGeneric = new PassDownGeneric<Integer>();
|
||||
public PassDownGeneric<Integer> passDownGeneric = new PassDownGeneric<>();
|
||||
|
||||
|
||||
// Classes designed for test introspection
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,7 +47,7 @@ public class ConvertingComparatorTests {
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void shouldThrowOnNullComparator() throws Exception {
|
||||
new ConvertingComparator<String, Integer>(null, this.converter);
|
||||
new ConvertingComparator<>(null, this.converter);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@@ -68,21 +68,21 @@ public class ConvertingComparatorTests {
|
||||
|
||||
@Test
|
||||
public void shouldUseConverterOnCompare() throws Exception {
|
||||
ConvertingComparator<String, Integer> convertingComparator = new ConvertingComparator<String, Integer>(
|
||||
this.comparator, this.converter);
|
||||
ConvertingComparator<String, Integer> convertingComparator = new ConvertingComparator<>(
|
||||
this.comparator, this.converter);
|
||||
testConversion(convertingComparator);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldUseConversionServiceOnCompare() throws Exception {
|
||||
ConvertingComparator<String, Integer> convertingComparator = new ConvertingComparator<String, Integer>(
|
||||
comparator, conversionService, Integer.class);
|
||||
ConvertingComparator<String, Integer> convertingComparator = new ConvertingComparator<>(
|
||||
comparator, conversionService, Integer.class);
|
||||
testConversion(convertingComparator);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetForConverter() throws Exception {
|
||||
testConversion(new ConvertingComparator<String, Integer>(comparator, converter));
|
||||
testConversion(new ConvertingComparator<>(comparator, converter));
|
||||
}
|
||||
|
||||
private void testConversion(ConvertingComparator<String, Integer> convertingComparator) {
|
||||
@@ -109,11 +109,11 @@ public class ConvertingComparatorTests {
|
||||
}
|
||||
|
||||
private ArrayList<Entry<String, Integer>> createReverseOrderMapEntryList() {
|
||||
Map<String, Integer> map = new LinkedHashMap<String, Integer>();
|
||||
Map<String, Integer> map = new LinkedHashMap<>();
|
||||
map.put("b", 2);
|
||||
map.put("a", 1);
|
||||
ArrayList<Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(
|
||||
map.entrySet());
|
||||
ArrayList<Entry<String, Integer>> list = new ArrayList<>(
|
||||
map.entrySet());
|
||||
assertThat(list.get(0).getKey(), is("b"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,7 +60,7 @@ public class CollectionToCollectionConverterTests {
|
||||
|
||||
@Test
|
||||
public void scalarList() throws Exception {
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("9");
|
||||
list.add("37");
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(list);
|
||||
@@ -85,7 +85,7 @@ public class CollectionToCollectionConverterTests {
|
||||
public void emptyListToList() throws Exception {
|
||||
conversionService.addConverter(new CollectionToCollectionConverter(conversionService));
|
||||
conversionService.addConverterFactory(new StringToNumberConverterFactory());
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(list);
|
||||
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyListTarget"));
|
||||
assertTrue(conversionService.canConvert(sourceType, targetType));
|
||||
@@ -96,7 +96,7 @@ public class CollectionToCollectionConverterTests {
|
||||
public void emptyListToListDifferentTargetType() throws Exception {
|
||||
conversionService.addConverter(new CollectionToCollectionConverter(conversionService));
|
||||
conversionService.addConverterFactory(new StringToNumberConverterFactory());
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(list);
|
||||
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyListDifferentTarget"));
|
||||
assertTrue(conversionService.canConvert(sourceType, targetType));
|
||||
@@ -108,7 +108,7 @@ public class CollectionToCollectionConverterTests {
|
||||
|
||||
@Test
|
||||
public void collectionToObjectInteraction() throws Exception {
|
||||
List<List<String>> list = new ArrayList<List<String>>();
|
||||
List<List<String>> list = new ArrayList<>();
|
||||
list.add(Arrays.asList("9", "12"));
|
||||
list.add(Arrays.asList("37", "23"));
|
||||
conversionService.addConverter(new CollectionToObjectConverter(conversionService));
|
||||
@@ -131,7 +131,7 @@ public class CollectionToCollectionConverterTests {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void objectToCollection() throws Exception {
|
||||
List<List<String>> list = new ArrayList<List<String>>();
|
||||
List<List<String>> list = new ArrayList<>();
|
||||
list.add(Arrays.asList("9", "12"));
|
||||
list.add(Arrays.asList("37", "23"));
|
||||
conversionService.addConverterFactory(new StringToNumberConverterFactory());
|
||||
@@ -150,7 +150,7 @@ public class CollectionToCollectionConverterTests {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void stringToCollection() throws Exception {
|
||||
List<List<String>> list = new ArrayList<List<String>>();
|
||||
List<List<String>> list = new ArrayList<>();
|
||||
list.add(Arrays.asList("9,12"));
|
||||
list.add(Arrays.asList("37,23"));
|
||||
conversionService.addConverterFactory(new StringToNumberConverterFactory());
|
||||
@@ -169,14 +169,14 @@ public class CollectionToCollectionConverterTests {
|
||||
|
||||
@Test
|
||||
public void convertEmptyVector_shouldReturnEmptyArrayList() {
|
||||
Vector<String> vector = new Vector<String>();
|
||||
Vector<String> vector = new Vector<>();
|
||||
vector.add("Element");
|
||||
testCollectionConversionToArrayList(vector);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertNonEmptyVector_shouldReturnNonEmptyArrayList() {
|
||||
Vector<String> vector = new Vector<String>();
|
||||
Vector<String> vector = new Vector<>();
|
||||
vector.add("Element");
|
||||
testCollectionConversionToArrayList(vector);
|
||||
}
|
||||
@@ -198,14 +198,14 @@ public class CollectionToCollectionConverterTests {
|
||||
|
||||
@Test
|
||||
public void listToCollectionNoCopyRequired() throws NoSuchFieldException {
|
||||
List<?> input = new ArrayList<String>(Arrays.asList("foo", "bar"));
|
||||
List<?> input = new ArrayList<>(Arrays.asList("foo", "bar"));
|
||||
assertSame(input, conversionService.convert(input, TypeDescriptor.forObject(input),
|
||||
new TypeDescriptor(getClass().getField("wildcardCollection"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void differentImpls() throws Exception {
|
||||
List<Resource> resources = new ArrayList<Resource>();
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
resources.add(new ClassPathResource("test"));
|
||||
resources.add(new FileSystemResource("test"));
|
||||
resources.add(new TestResource());
|
||||
@@ -215,7 +215,7 @@ public class CollectionToCollectionConverterTests {
|
||||
|
||||
@Test
|
||||
public void mixedInNulls() throws Exception {
|
||||
List<Resource> resources = new ArrayList<Resource>();
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
resources.add(new ClassPathResource("test"));
|
||||
resources.add(null);
|
||||
resources.add(new FileSystemResource("test"));
|
||||
@@ -226,7 +226,7 @@ public class CollectionToCollectionConverterTests {
|
||||
|
||||
@Test
|
||||
public void allNulls() throws Exception {
|
||||
List<Resource> resources = new ArrayList<Resource>();
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
resources.add(null);
|
||||
resources.add(null);
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(resources);
|
||||
@@ -235,7 +235,7 @@ public class CollectionToCollectionConverterTests {
|
||||
|
||||
@Test(expected = ConverterNotFoundException.class)
|
||||
public void elementTypesNotConvertible() throws Exception {
|
||||
List<String> resources = new ArrayList<String>();
|
||||
List<String> resources = new ArrayList<>();
|
||||
resources.add(null);
|
||||
resources.add(null);
|
||||
TypeDescriptor sourceType = new TypeDescriptor(getClass().getField("strings"));
|
||||
@@ -244,7 +244,7 @@ public class CollectionToCollectionConverterTests {
|
||||
|
||||
@Test(expected = ConversionFailedException.class)
|
||||
public void nothingInCommon() throws Exception {
|
||||
List<Object> resources = new ArrayList<Object>();
|
||||
List<Object> resources = new ArrayList<>();
|
||||
resources.add(new ClassPathResource("test"));
|
||||
resources.add(3);
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(resources);
|
||||
@@ -254,7 +254,7 @@ public class CollectionToCollectionConverterTests {
|
||||
@Test
|
||||
public void testStringToEnumSet() throws Exception {
|
||||
conversionService.addConverterFactory(new StringToEnumConverterFactory());
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("A");
|
||||
list.add("C");
|
||||
assertEquals(EnumSet.of(MyEnum.A, MyEnum.C),
|
||||
|
||||
@@ -477,7 +477,7 @@ public class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void convertCollectionToArray() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("1");
|
||||
list.add("2");
|
||||
list.add("3");
|
||||
@@ -489,7 +489,7 @@ public class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void convertCollectionToArrayWithElementConversion() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("1");
|
||||
list.add("2");
|
||||
list.add("3");
|
||||
@@ -558,7 +558,7 @@ public class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void convertCollectionToObjectAssignableTarget() throws Exception {
|
||||
Collection<String> source = new ArrayList<String>();
|
||||
Collection<String> source = new ArrayList<>();
|
||||
source.add("foo");
|
||||
Object result = conversionService.convert(source, new TypeDescriptor(getClass().getField("assignableTarget")));
|
||||
assertEquals(source, result);
|
||||
@@ -567,7 +567,7 @@ public class DefaultConversionServiceTests {
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void convertCollectionToObjectWithCustomConverter() throws Exception {
|
||||
List<String> source = new ArrayList<String>();
|
||||
List<String> source = new ArrayList<>();
|
||||
source.add("A");
|
||||
source.add("B");
|
||||
conversionService.addConverter(new Converter<List, ListWrapper>() {
|
||||
@@ -640,7 +640,7 @@ public class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void convertCollectionToCollection() throws Exception {
|
||||
Set<String> foo = new LinkedHashSet<String>();
|
||||
Set<String> foo = new LinkedHashSet<>();
|
||||
foo.add("1");
|
||||
foo.add("2");
|
||||
foo.add("3");
|
||||
@@ -663,7 +663,7 @@ public class DefaultConversionServiceTests {
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void convertCollectionToCollectionNotGeneric() throws Exception {
|
||||
Set<String> foo = new LinkedHashSet<String>();
|
||||
Set<String> foo = new LinkedHashSet<>();
|
||||
foo.add("1");
|
||||
foo.add("2");
|
||||
foo.add("3");
|
||||
@@ -692,7 +692,7 @@ public class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void collection() {
|
||||
List<String> strings = new ArrayList<String>();
|
||||
List<String> strings = new ArrayList<>();
|
||||
strings.add("3");
|
||||
strings.add("9");
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -704,7 +704,7 @@ public class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void convertMapToMap() throws Exception {
|
||||
Map<String, String> foo = new HashMap<String, String>();
|
||||
Map<String, String> foo = new HashMap<>();
|
||||
foo.put("1", "BAR");
|
||||
foo.put("2", "BAZ");
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -717,7 +717,7 @@ public class DefaultConversionServiceTests {
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void convertHashMapValuesToList() {
|
||||
Map<String, Integer> hashMap = new LinkedHashMap<String, Integer>();
|
||||
Map<String, Integer> hashMap = new LinkedHashMap<>();
|
||||
hashMap.put("1", 1);
|
||||
hashMap.put("2", 2);
|
||||
List converted = conversionService.convert(hashMap.values(), List.class);
|
||||
@@ -726,7 +726,7 @@ public class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void map() {
|
||||
Map<String, String> strings = new HashMap<String, String>();
|
||||
Map<String, String> strings = new HashMap<>();
|
||||
strings.put("3", "9");
|
||||
strings.put("6", "31");
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -941,11 +941,11 @@ public class DefaultConversionServiceTests {
|
||||
|
||||
// test fields and helpers
|
||||
|
||||
public List<Integer> genericList = new ArrayList<Integer>();
|
||||
public List<Integer> genericList = new ArrayList<>();
|
||||
|
||||
public Stream<Integer> genericStream;
|
||||
|
||||
public Map<Integer, FooEnum> genericMap = new HashMap<Integer, FooEnum>();
|
||||
public Map<Integer, FooEnum> genericMap = new HashMap<>();
|
||||
|
||||
public EnumSet<Foo> enumSet;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -229,7 +229,7 @@ public class GenericConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void testListToIterableConversion() {
|
||||
List<Object> raw = new ArrayList<Object>();
|
||||
List<Object> raw = new ArrayList<>();
|
||||
raw.add("one");
|
||||
raw.add("two");
|
||||
Object converted = conversionService.convert(raw, Iterable.class);
|
||||
@@ -238,7 +238,7 @@ public class GenericConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void testListToObjectConversion() {
|
||||
List<Object> raw = new ArrayList<Object>();
|
||||
List<Object> raw = new ArrayList<>();
|
||||
raw.add("one");
|
||||
raw.add("two");
|
||||
Object converted = conversionService.convert(raw, Object.class);
|
||||
@@ -247,7 +247,7 @@ public class GenericConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void testMapToObjectConversion() {
|
||||
Map<Object, Object> raw = new HashMap<Object, Object>();
|
||||
Map<Object, Object> raw = new HashMap<>();
|
||||
raw.put("key", "value");
|
||||
Object converted = conversionService.convert(raw, Object.class);
|
||||
assertSame(raw, converted);
|
||||
@@ -301,7 +301,7 @@ public class GenericConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void testWildcardMap() throws Exception {
|
||||
Map<String, String> input = new LinkedHashMap<String, String>();
|
||||
Map<String, String> input = new LinkedHashMap<>();
|
||||
input.put("key", "value");
|
||||
Object converted = conversionService.convert(input, TypeDescriptor.forObject(input), new TypeDescriptor(getClass().getField("wildcardMap")));
|
||||
assertEquals(input, converted);
|
||||
@@ -333,7 +333,7 @@ public class GenericConversionServiceTests {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
StopWatch watch = new StopWatch("list<string> -> list<integer> conversionPerformance");
|
||||
watch.start("convert 4,000,000 with conversion service");
|
||||
List<String> source = new LinkedList<String>();
|
||||
List<String> source = new LinkedList<>();
|
||||
source.add("1");
|
||||
source.add("2");
|
||||
source.add("3");
|
||||
@@ -344,7 +344,7 @@ public class GenericConversionServiceTests {
|
||||
watch.stop();
|
||||
watch.start("convert 4,000,000 manually");
|
||||
for (int i = 0; i < 4000000; i++) {
|
||||
List<Integer> target = new ArrayList<Integer>(source.size());
|
||||
List<Integer> target = new ArrayList<>(source.size());
|
||||
for (String element : source) {
|
||||
target.add(Integer.valueOf(element));
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public class GenericConversionServiceTests {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
StopWatch watch = new StopWatch("map<string, string> -> map<string, integer> conversionPerformance");
|
||||
watch.start("convert 4,000,000 with conversion service");
|
||||
Map<String, String> source = new HashMap<String, String>();
|
||||
Map<String, String> source = new HashMap<>();
|
||||
source.put("1", "1");
|
||||
source.put("2", "2");
|
||||
source.put("3", "3");
|
||||
@@ -369,7 +369,7 @@ public class GenericConversionServiceTests {
|
||||
watch.stop();
|
||||
watch.start("convert 4,000,000 manually");
|
||||
for (int i = 0; i < 4000000; i++) {
|
||||
Map<String, Integer> target = new HashMap<String, Integer>(source.size());
|
||||
Map<String, Integer> target = new HashMap<>(source.size());
|
||||
for (Map.Entry<String, String> entry : source.entrySet()) {
|
||||
target.put(entry.getKey(), Integer.valueOf(entry.getValue()));
|
||||
}
|
||||
@@ -382,7 +382,7 @@ public class GenericConversionServiceTests {
|
||||
public void emptyListToArray() {
|
||||
conversionService.addConverter(new CollectionToArrayConverter(conversionService));
|
||||
conversionService.addConverterFactory(new StringToNumberConverterFactory());
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(list);
|
||||
TypeDescriptor targetType = TypeDescriptor.valueOf(String[].class);
|
||||
assertTrue(conversionService.canConvert(sourceType, targetType));
|
||||
@@ -393,7 +393,7 @@ public class GenericConversionServiceTests {
|
||||
public void emptyListToObject() {
|
||||
conversionService.addConverter(new CollectionToObjectConverter(conversionService));
|
||||
conversionService.addConverterFactory(new StringToNumberConverterFactory());
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(list);
|
||||
TypeDescriptor targetType = TypeDescriptor.valueOf(Integer.class);
|
||||
assertTrue(conversionService.canConvert(sourceType, targetType));
|
||||
@@ -420,7 +420,7 @@ public class GenericConversionServiceTests {
|
||||
|
||||
@Test
|
||||
public void testConvertiblePairsInSet() {
|
||||
Set<GenericConverter.ConvertiblePair> set = new HashSet<GenericConverter.ConvertiblePair>();
|
||||
Set<GenericConverter.ConvertiblePair> set = new HashSet<>();
|
||||
set.add(new GenericConverter.ConvertiblePair(Number.class, String.class));
|
||||
assert set.contains(new GenericConverter.ConvertiblePair(Number.class, String.class));
|
||||
}
|
||||
@@ -771,7 +771,7 @@ public class GenericConversionServiceTests {
|
||||
|
||||
private static class MyConditionalGenericConverter implements GenericConverter, ConditionalConverter {
|
||||
|
||||
private final List<TypeDescriptor> sourceTypes = new ArrayList<TypeDescriptor>();
|
||||
private final List<TypeDescriptor> sourceTypes = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> getConvertibleTypes() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,7 +54,7 @@ public class MapToMapConverterTests {
|
||||
|
||||
@Test
|
||||
public void scalarMap() throws Exception {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("1", "9");
|
||||
map.put("2", "37");
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(map);
|
||||
@@ -79,7 +79,7 @@ public class MapToMapConverterTests {
|
||||
|
||||
@Test
|
||||
public void scalarMapNotGenericTarget() throws Exception {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("1", "9");
|
||||
map.put("2", "37");
|
||||
|
||||
@@ -89,7 +89,7 @@ public class MapToMapConverterTests {
|
||||
|
||||
@Test
|
||||
public void scalarMapNotGenericSourceField() throws Exception {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("1", "9");
|
||||
map.put("2", "37");
|
||||
TypeDescriptor sourceType = new TypeDescriptor(getClass().getField("notGenericMapSource"));
|
||||
@@ -114,7 +114,7 @@ public class MapToMapConverterTests {
|
||||
|
||||
@Test
|
||||
public void collectionMap() throws Exception {
|
||||
Map<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
map.put("1", Arrays.asList("9", "12"));
|
||||
map.put("2", Arrays.asList("37", "23"));
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(map);
|
||||
@@ -140,7 +140,7 @@ public class MapToMapConverterTests {
|
||||
|
||||
@Test
|
||||
public void collectionMapSourceTarget() throws Exception {
|
||||
Map<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
map.put("1", Arrays.asList("9", "12"));
|
||||
map.put("2", Arrays.asList("37", "23"));
|
||||
TypeDescriptor sourceType = new TypeDescriptor(getClass().getField("sourceCollectionMapTarget"));
|
||||
@@ -167,7 +167,7 @@ public class MapToMapConverterTests {
|
||||
|
||||
@Test
|
||||
public void collectionMapNotGenericTarget() throws Exception {
|
||||
Map<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
map.put("1", Arrays.asList("9", "12"));
|
||||
map.put("2", Arrays.asList("37", "23"));
|
||||
|
||||
@@ -177,7 +177,7 @@ public class MapToMapConverterTests {
|
||||
|
||||
@Test
|
||||
public void collectionMapNotGenericTargetCollectionToObjectInteraction() throws Exception {
|
||||
Map<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
map.put("1", Arrays.asList("9", "12"));
|
||||
map.put("2", Arrays.asList("37", "23"));
|
||||
conversionService.addConverter(new CollectionToCollectionConverter(conversionService));
|
||||
@@ -189,7 +189,7 @@ public class MapToMapConverterTests {
|
||||
|
||||
@Test
|
||||
public void emptyMap() throws Exception {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(map);
|
||||
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyMapTarget"));
|
||||
|
||||
@@ -199,7 +199,7 @@ public class MapToMapConverterTests {
|
||||
|
||||
@Test
|
||||
public void emptyMapNoTargetGenericInfo() throws Exception {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
assertTrue(conversionService.canConvert(Map.class, Map.class));
|
||||
assertSame(map, conversionService.convert(map, Map.class));
|
||||
@@ -207,7 +207,7 @@ public class MapToMapConverterTests {
|
||||
|
||||
@Test
|
||||
public void emptyMapDifferentTargetImplType() throws Exception {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
TypeDescriptor sourceType = TypeDescriptor.forObject(map);
|
||||
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyMapDifferentTarget"));
|
||||
|
||||
@@ -221,8 +221,8 @@ public class MapToMapConverterTests {
|
||||
@Test
|
||||
public void noDefaultConstructorCopyNotRequired() throws Exception {
|
||||
// SPR-9284
|
||||
NoDefaultConstructorMap<String, Integer> map = new NoDefaultConstructorMap<String,Integer>(
|
||||
Collections.<String, Integer> singletonMap("1", 1));
|
||||
NoDefaultConstructorMap<String, Integer> map = new NoDefaultConstructorMap<>(
|
||||
Collections.<String, Integer>singletonMap("1", 1));
|
||||
TypeDescriptor sourceType = TypeDescriptor.map(NoDefaultConstructorMap.class,
|
||||
TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class));
|
||||
TypeDescriptor targetType = TypeDescriptor.map(NoDefaultConstructorMap.class,
|
||||
@@ -239,7 +239,7 @@ public class MapToMapConverterTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void multiValueMapToMultiValueMap() throws Exception {
|
||||
DefaultConversionService.addDefaultConverters(conversionService);
|
||||
MultiValueMap<String, Integer> source = new LinkedMultiValueMap<String, Integer>();
|
||||
MultiValueMap<String, Integer> source = new LinkedMultiValueMap<>();
|
||||
source.put("a", Arrays.asList(1, 2, 3));
|
||||
source.put("b", Arrays.asList(4, 5, 6));
|
||||
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("multiValueMapTarget"));
|
||||
@@ -254,7 +254,7 @@ public class MapToMapConverterTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void mapToMultiValueMap() throws Exception {
|
||||
DefaultConversionService.addDefaultConverters(conversionService);
|
||||
Map<String, Integer> source = new HashMap<String, Integer>();
|
||||
Map<String, Integer> source = new HashMap<>();
|
||||
source.put("a", 1);
|
||||
source.put("b", 2);
|
||||
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("multiValueMapTarget"));
|
||||
@@ -268,10 +268,10 @@ public class MapToMapConverterTests {
|
||||
@Test
|
||||
public void testStringToEnumMap() throws Exception {
|
||||
conversionService.addConverterFactory(new StringToEnumConverterFactory());
|
||||
Map<String, Integer> source = new HashMap<String, Integer>();
|
||||
Map<String, Integer> source = new HashMap<>();
|
||||
source.put("A", 1);
|
||||
source.put("C", 2);
|
||||
EnumMap<MyEnum, Integer> result = new EnumMap<MyEnum, Integer>(MyEnum.class);
|
||||
EnumMap<MyEnum, Integer> result = new EnumMap<>(MyEnum.class);
|
||||
result.put(MyEnum.A, 1);
|
||||
result.put(MyEnum.C, 2);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,7 +67,7 @@ public class PropertySourceTests {
|
||||
|
||||
PropertySource<?> ps1 = new MapPropertySource("ps1", map1);
|
||||
ps1.getSource();
|
||||
List<PropertySource<?>> propertySources = new ArrayList<PropertySource<?>>();
|
||||
List<PropertySource<?>> propertySources = new ArrayList<>();
|
||||
assertThat(propertySources.add(ps1), equalTo(true));
|
||||
assertThat(propertySources.contains(ps1), is(true));
|
||||
assertThat(propertySources.contains(PropertySource.named("ps1")), is(true));
|
||||
|
||||
@@ -87,7 +87,7 @@ public class PropertySourcesPropertyResolverTests {
|
||||
@Test
|
||||
public void getProperty_withExplicitNullValue() {
|
||||
// java.util.Properties does not allow null values (because Hashtable does not)
|
||||
Map<String, Object> nullableProperties = new HashMap<String, Object>();
|
||||
Map<String, Object> nullableProperties = new HashMap<>();
|
||||
propertySources.addLast(new MapPropertySource("nullableProperties", nullableProperties));
|
||||
nullableProperties.put("foo", null);
|
||||
assertThat(propertyResolver.getProperty("foo"), nullValue());
|
||||
@@ -127,7 +127,7 @@ public class PropertySourcesPropertyResolverTests {
|
||||
String value1 = "bar";
|
||||
String value2 = "biz";
|
||||
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put(key, value1); // before construction
|
||||
MutablePropertySources propertySources = new MutablePropertySources();
|
||||
propertySources.addFirst(new MapPropertySource("testProperties", map));
|
||||
@@ -139,7 +139,7 @@ public class PropertySourcesPropertyResolverTests {
|
||||
|
||||
@Test
|
||||
public void getProperty_doesNotCache_addNewKeyPostConstruction() {
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
MutablePropertySources propertySources = new MutablePropertySources();
|
||||
propertySources.addFirst(new MapPropertySource("testProperties", map));
|
||||
PropertyResolver propertyResolver = new PropertySourcesPropertyResolver(propertySources);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ public class SystemEnvironmentPropertySourceTests {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
envMap = new HashMap<String, Object>();
|
||||
envMap = new HashMap<>();
|
||||
ps = new SystemEnvironmentPropertySource("sysEnv", envMap);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class SystemEnvironmentPropertySourceTests {
|
||||
}
|
||||
@Override
|
||||
public Set<String> keySet() {
|
||||
return new HashSet<String>(super.keySet());
|
||||
return new HashSet<>(super.keySet());
|
||||
}
|
||||
};
|
||||
envMap.put("A_KEY", "a_value");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -95,7 +95,7 @@ public class ResourceTests {
|
||||
assertEquals(resource, resource3);
|
||||
|
||||
// Check whether equal/hashCode works in a HashSet.
|
||||
HashSet<Resource> resources = new HashSet<Resource>();
|
||||
HashSet<Resource> resources = new HashSet<>();
|
||||
resources.add(resource);
|
||||
resources.add(resource2);
|
||||
assertEquals(1, resources.size());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,7 +85,7 @@ public class PathMatchingResourcePatternResolverTests {
|
||||
Resource[] resources = resolver.getResources("classpath*:org/springframework/core/io/sup*/*.class");
|
||||
// Have to exclude Clover-generated class files here,
|
||||
// as we might be running as part of a Clover test run.
|
||||
List<Resource> noCloverResources = new ArrayList<Resource>();
|
||||
List<Resource> noCloverResources = new ArrayList<>();
|
||||
for (Resource resource : resources) {
|
||||
if (!resource.getFilename().contains("$__CLOVER_")) {
|
||||
noCloverResources.add(resource);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -292,9 +292,9 @@ public class AnnotationMetadataTests {
|
||||
MethodMetadata method = methods.iterator().next();
|
||||
assertEquals("direct", method.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value"));
|
||||
List<Object> allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
|
||||
assertThat(new HashSet<Object>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct", "meta")))));
|
||||
assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct", "meta")))));
|
||||
allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional");
|
||||
assertThat(new HashSet<Object>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct")))));
|
||||
assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct")))));
|
||||
|
||||
assertTrue(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName()));
|
||||
|
||||
@@ -334,9 +334,9 @@ public class AnnotationMetadataTests {
|
||||
|
||||
assertEquals("direct", metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value"));
|
||||
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
|
||||
assertThat(new HashSet<Object>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct", "meta")))));
|
||||
assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct", "meta")))));
|
||||
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional");
|
||||
assertThat(new HashSet<Object>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct")))));
|
||||
assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct")))));
|
||||
}
|
||||
{ // perform tests with classValuesAsString = true
|
||||
AnnotationAttributes specialAttrs = (AnnotationAttributes) metadata.getAnnotationAttributes(
|
||||
@@ -365,7 +365,7 @@ public class AnnotationMetadataTests {
|
||||
|
||||
assertEquals(metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value"), "direct");
|
||||
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
|
||||
assertThat(new HashSet<Object>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct", "meta")))));
|
||||
assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct", "meta")))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -81,7 +81,7 @@ public enum TestGroup {
|
||||
return EnumSet.allOf(TestGroup.class);
|
||||
}
|
||||
if (value.toUpperCase().startsWith("ALL-")) {
|
||||
Set<TestGroup> groups = new HashSet<TestGroup>(EnumSet.allOf(TestGroup.class));
|
||||
Set<TestGroup> groups = new HashSet<>(EnumSet.allOf(TestGroup.class));
|
||||
groups.removeAll(parseGroups(value.substring(4)));
|
||||
return groups;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public enum TestGroup {
|
||||
}
|
||||
|
||||
private static Set<TestGroup> parseGroups(String value) {
|
||||
Set<TestGroup> groups = new HashSet<TestGroup>();
|
||||
Set<TestGroup> groups = new HashSet<>();
|
||||
for (String group : value.split(",")) {
|
||||
try {
|
||||
groups.add(valueOf(group.trim().toUpperCase()));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,7 +76,7 @@ public class TestGroupTests {
|
||||
|
||||
@Test
|
||||
public void parseAllExcept() throws Exception {
|
||||
Set<TestGroup> expected = new HashSet<TestGroup>(EnumSet.allOf(TestGroup.class));
|
||||
Set<TestGroup> expected = new HashSet<>(EnumSet.allOf(TestGroup.class));
|
||||
expected.remove(TestGroup.CUSTOM_COMPILATION);
|
||||
expected.remove(TestGroup.PERFORMANCE);
|
||||
assertThat(TestGroup.parse("all-custom_compilation,performance"), equalTo(expected));
|
||||
|
||||
@@ -331,7 +331,7 @@ public class AntPathMatcherTests {
|
||||
assertEquals(Collections.singletonMap("hotel", "1"), result);
|
||||
|
||||
result = pathMatcher.extractUriTemplateVariables("/hotels/{hotel}/bookings/{booking}", "/hotels/1/bookings/2");
|
||||
Map<String, String> expected = new LinkedHashMap<String, String>();
|
||||
Map<String, String> expected = new LinkedHashMap<>();
|
||||
expected.put("hotel", "1");
|
||||
expected.put("booking", "2");
|
||||
assertEquals(expected, result);
|
||||
@@ -349,7 +349,7 @@ public class AntPathMatcherTests {
|
||||
assertEquals(Collections.singletonMap("B", "b"), result);
|
||||
|
||||
result = pathMatcher.extractUriTemplateVariables("/{name}.{extension}", "/test.html");
|
||||
expected = new LinkedHashMap<String, String>();
|
||||
expected = new LinkedHashMap<>();
|
||||
expected.put("name", "test");
|
||||
expected.put("extension", "html");
|
||||
assertEquals(expected, result);
|
||||
@@ -499,7 +499,7 @@ public class AntPathMatcherTests {
|
||||
@Test
|
||||
public void patternComparatorSort() {
|
||||
Comparator<String> comparator = pathMatcher.getPatternComparator("/hotels/new");
|
||||
List<String> paths = new ArrayList<String>(3);
|
||||
List<String> paths = new ArrayList<>(3);
|
||||
|
||||
paths.add(null);
|
||||
paths.add("/hotels/new");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,12 +45,12 @@ public class AssertTests {
|
||||
|
||||
@Test
|
||||
public void instanceOf() {
|
||||
Assert.isInstanceOf(HashSet.class, new HashSet<Object>());
|
||||
Assert.isInstanceOf(HashSet.class, new HashSet<>());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void instanceOfWithTypeMismatch() {
|
||||
Assert.isInstanceOf(HashMap.class, new HashSet<Object>());
|
||||
Assert.isInstanceOf(HashMap.class, new HashSet<>());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,12 +136,12 @@ public class AssertTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void assertNotEmptyWithEmptyCollectionThrowsException() throws Exception {
|
||||
Assert.notEmpty(new ArrayList<Object>());
|
||||
Assert.notEmpty(new ArrayList<>());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assertNotEmptyWithCollectionSunnyDay() throws Exception {
|
||||
List<String> collection = new ArrayList<String>();
|
||||
List<String> collection = new ArrayList<>();
|
||||
collection.add("");
|
||||
Assert.notEmpty(collection);
|
||||
}
|
||||
@@ -153,12 +153,12 @@ public class AssertTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void assertNotEmptyWithEmptyMapThrowsException() throws Exception {
|
||||
Assert.notEmpty(new HashMap<Object, Object>());
|
||||
Assert.notEmpty(new HashMap<>());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assertNotEmptyWithMapSunnyDay() throws Exception {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("", "");
|
||||
Assert.notEmpty(map);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,22 +32,22 @@ public class AutoPopulatingListTests {
|
||||
|
||||
@Test
|
||||
public void withClass() throws Exception {
|
||||
doTestWithClass(new AutoPopulatingList<Object>(TestObject.class));
|
||||
doTestWithClass(new AutoPopulatingList<>(TestObject.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withClassAndUserSuppliedBackingList() throws Exception {
|
||||
doTestWithClass(new AutoPopulatingList<Object>(new LinkedList<Object>(), TestObject.class));
|
||||
doTestWithClass(new AutoPopulatingList<Object>(new LinkedList<>(), TestObject.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withElementFactory() throws Exception {
|
||||
doTestWithElementFactory(new AutoPopulatingList<Object>(new MockElementFactory()));
|
||||
doTestWithElementFactory(new AutoPopulatingList<>(new MockElementFactory()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withElementFactoryAndUserSuppliedBackingList() throws Exception {
|
||||
doTestWithElementFactory(new AutoPopulatingList<Object>(new LinkedList<Object>(), new MockElementFactory()));
|
||||
doTestWithElementFactory(new AutoPopulatingList<Object>(new LinkedList<>(), new MockElementFactory()));
|
||||
}
|
||||
|
||||
private void doTestWithClass(AutoPopulatingList<Object> list) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,13 +44,13 @@ public class CollectionUtilsTests {
|
||||
assertTrue(CollectionUtils.isEmpty((Set<Object>) null));
|
||||
assertTrue(CollectionUtils.isEmpty((Map<String, String>) null));
|
||||
assertTrue(CollectionUtils.isEmpty(new HashMap<String, String>()));
|
||||
assertTrue(CollectionUtils.isEmpty(new HashSet<Object>()));
|
||||
assertTrue(CollectionUtils.isEmpty(new HashSet<>()));
|
||||
|
||||
List<Object> list = new LinkedList<Object>();
|
||||
List<Object> list = new LinkedList<>();
|
||||
list.add(new Object());
|
||||
assertFalse(CollectionUtils.isEmpty(list));
|
||||
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("foo", "bar");
|
||||
assertFalse(CollectionUtils.isEmpty(map));
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class CollectionUtilsTests {
|
||||
@Test
|
||||
public void testMergeArrayIntoCollection() {
|
||||
Object[] arr = new Object[] {"value1", "value2"};
|
||||
List<Comparable<?>> list = new LinkedList<Comparable<?>>();
|
||||
List<Comparable<?>> list = new LinkedList<>();
|
||||
list.add("value3");
|
||||
|
||||
CollectionUtils.mergeArrayIntoCollection(arr, list);
|
||||
@@ -70,7 +70,7 @@ public class CollectionUtilsTests {
|
||||
@Test
|
||||
public void testMergePrimitiveArrayIntoCollection() {
|
||||
int[] arr = new int[] {1, 2};
|
||||
List<Comparable<?>> list = new LinkedList<Comparable<?>>();
|
||||
List<Comparable<?>> list = new LinkedList<>();
|
||||
list.add(new Integer(3));
|
||||
|
||||
CollectionUtils.mergeArrayIntoCollection(arr, list);
|
||||
@@ -87,7 +87,7 @@ public class CollectionUtilsTests {
|
||||
props.setProperty("prop2", "value2");
|
||||
props.put("prop3", new Integer(3));
|
||||
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("prop4", "value4");
|
||||
|
||||
CollectionUtils.mergePropertiesIntoMap(props, map);
|
||||
@@ -104,23 +104,23 @@ public class CollectionUtilsTests {
|
||||
assertFalse(CollectionUtils.contains(new LinkedList<String>().iterator(), "myElement"));
|
||||
assertFalse(CollectionUtils.contains(new Hashtable<String, Object>().keys(), "myElement"));
|
||||
|
||||
List<String> list = new LinkedList<String>();
|
||||
List<String> list = new LinkedList<>();
|
||||
list.add("myElement");
|
||||
assertTrue(CollectionUtils.contains(list.iterator(), "myElement"));
|
||||
|
||||
Hashtable<String, String> ht = new Hashtable<String, String>();
|
||||
Hashtable<String, String> ht = new Hashtable<>();
|
||||
ht.put("myElement", "myValue");
|
||||
assertTrue(CollectionUtils.contains(ht.keys(), "myElement"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContainsAny() throws Exception {
|
||||
List<String> source = new ArrayList<String>();
|
||||
List<String> source = new ArrayList<>();
|
||||
source.add("abc");
|
||||
source.add("def");
|
||||
source.add("ghi");
|
||||
|
||||
List<String> candidates = new ArrayList<String>();
|
||||
List<String> candidates = new ArrayList<>();
|
||||
candidates.add("xyz");
|
||||
candidates.add("def");
|
||||
candidates.add("abc");
|
||||
@@ -140,7 +140,7 @@ public class CollectionUtilsTests {
|
||||
|
||||
@Test
|
||||
public void testContainsInstanceWithInstancesThatAreEqualButDistinct() throws Exception {
|
||||
List<Instance> list = new ArrayList<Instance>();
|
||||
List<Instance> list = new ArrayList<>();
|
||||
list.add(new Instance("fiona"));
|
||||
assertFalse("Must return false if instance is not in the supplied Collection argument",
|
||||
CollectionUtils.containsInstance(list, new Instance("fiona")));
|
||||
@@ -148,7 +148,7 @@ public class CollectionUtilsTests {
|
||||
|
||||
@Test
|
||||
public void testContainsInstanceWithSameInstance() throws Exception {
|
||||
List<Instance> list = new ArrayList<Instance>();
|
||||
List<Instance> list = new ArrayList<>();
|
||||
list.add(new Instance("apple"));
|
||||
Instance instance = new Instance("fiona");
|
||||
list.add(instance);
|
||||
@@ -158,7 +158,7 @@ public class CollectionUtilsTests {
|
||||
|
||||
@Test
|
||||
public void testContainsInstanceWithNullInstance() throws Exception {
|
||||
List<Instance> list = new ArrayList<Instance>();
|
||||
List<Instance> list = new ArrayList<>();
|
||||
list.add(new Instance("apple"));
|
||||
list.add(new Instance("fiona"));
|
||||
assertFalse("Must return false if null instance is supplied",
|
||||
@@ -167,12 +167,12 @@ public class CollectionUtilsTests {
|
||||
|
||||
@Test
|
||||
public void testFindFirstMatch() throws Exception {
|
||||
List<String> source = new ArrayList<String>();
|
||||
List<String> source = new ArrayList<>();
|
||||
source.add("abc");
|
||||
source.add("def");
|
||||
source.add("ghi");
|
||||
|
||||
List<String> candidates = new ArrayList<String>();
|
||||
List<String> candidates = new ArrayList<>();
|
||||
candidates.add("xyz");
|
||||
candidates.add("def");
|
||||
candidates.add("abc");
|
||||
@@ -182,35 +182,35 @@ public class CollectionUtilsTests {
|
||||
|
||||
@Test
|
||||
public void testHasUniqueObject() {
|
||||
List<String> list = new LinkedList<String>();
|
||||
List<String> list = new LinkedList<>();
|
||||
list.add("myElement");
|
||||
list.add("myOtherElement");
|
||||
assertFalse(CollectionUtils.hasUniqueObject(list));
|
||||
|
||||
list = new LinkedList<String>();
|
||||
list = new LinkedList<>();
|
||||
list.add("myElement");
|
||||
assertTrue(CollectionUtils.hasUniqueObject(list));
|
||||
|
||||
list = new LinkedList<String>();
|
||||
list = new LinkedList<>();
|
||||
list.add("myElement");
|
||||
list.add(null);
|
||||
assertFalse(CollectionUtils.hasUniqueObject(list));
|
||||
|
||||
list = new LinkedList<String>();
|
||||
list = new LinkedList<>();
|
||||
list.add(null);
|
||||
list.add("myElement");
|
||||
assertFalse(CollectionUtils.hasUniqueObject(list));
|
||||
|
||||
list = new LinkedList<String>();
|
||||
list = new LinkedList<>();
|
||||
list.add(null);
|
||||
list.add(null);
|
||||
assertTrue(CollectionUtils.hasUniqueObject(list));
|
||||
|
||||
list = new LinkedList<String>();
|
||||
list = new LinkedList<>();
|
||||
list.add(null);
|
||||
assertTrue(CollectionUtils.hasUniqueObject(list));
|
||||
|
||||
list = new LinkedList<String>();
|
||||
list = new LinkedList<>();
|
||||
assertFalse(CollectionUtils.hasUniqueObject(list));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ public class CompositeIteratorTests {
|
||||
|
||||
@Test
|
||||
public void testNoIterators() {
|
||||
CompositeIterator<String> it = new CompositeIterator<String>();
|
||||
CompositeIterator<String> it = new CompositeIterator<>();
|
||||
assertFalse(it.hasNext());
|
||||
try {
|
||||
it.next();
|
||||
@@ -49,7 +49,7 @@ public class CompositeIteratorTests {
|
||||
|
||||
@Test
|
||||
public void testSingleIterator() {
|
||||
CompositeIterator<String> it = new CompositeIterator<String>();
|
||||
CompositeIterator<String> it = new CompositeIterator<>();
|
||||
it.add(Arrays.asList("0", "1").iterator());
|
||||
for (int i = 0; i < 2; i++) {
|
||||
assertTrue(it.hasNext());
|
||||
@@ -67,7 +67,7 @@ public class CompositeIteratorTests {
|
||||
|
||||
@Test
|
||||
public void testMultipleIterators() {
|
||||
CompositeIterator<String> it = new CompositeIterator<String>();
|
||||
CompositeIterator<String> it = new CompositeIterator<>();
|
||||
it.add(Arrays.asList("0", "1").iterator());
|
||||
it.add(Arrays.asList("2").iterator());
|
||||
it.add(Arrays.asList("3", "4").iterator());
|
||||
@@ -88,7 +88,7 @@ public class CompositeIteratorTests {
|
||||
@Test
|
||||
public void testInUse() {
|
||||
List<String> list = Arrays.asList("0", "1");
|
||||
CompositeIterator<String> it = new CompositeIterator<String>();
|
||||
CompositeIterator<String> it = new CompositeIterator<>();
|
||||
it.add(list.iterator());
|
||||
it.hasNext();
|
||||
try {
|
||||
@@ -98,7 +98,7 @@ public class CompositeIteratorTests {
|
||||
catch (IllegalStateException ex) {
|
||||
// expected
|
||||
}
|
||||
it = new CompositeIterator<String>();
|
||||
it = new CompositeIterator<>();
|
||||
it.add(list.iterator());
|
||||
it.next();
|
||||
try {
|
||||
@@ -114,7 +114,7 @@ public class CompositeIteratorTests {
|
||||
public void testDuplicateIterators() {
|
||||
List<String> list = Arrays.asList("0", "1");
|
||||
Iterator<String> iterator = list.iterator();
|
||||
CompositeIterator<String> it = new CompositeIterator<String>();
|
||||
CompositeIterator<String> it = new CompositeIterator<>();
|
||||
it.add(iterator);
|
||||
it.add(list.iterator());
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,12 +56,12 @@ public class ConcurrentReferenceHashMapTests {
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private TestWeakConcurrentCache<Integer, String> map = new TestWeakConcurrentCache<Integer, String>();
|
||||
private TestWeakConcurrentCache<Integer, String> map = new TestWeakConcurrentCache<>();
|
||||
|
||||
|
||||
@Test
|
||||
public void shouldCreateWithDefaults() throws Exception {
|
||||
ConcurrentReferenceHashMap<Integer, String> map = new ConcurrentReferenceHashMap<Integer, String>();
|
||||
ConcurrentReferenceHashMap<Integer, String> map = new ConcurrentReferenceHashMap<>();
|
||||
assertThat(map.getSegmentsSize(), is(16));
|
||||
assertThat(map.getSegment(0).getSize(), is(1));
|
||||
assertThat(map.getLoadFactor(), is(0.75f));
|
||||
@@ -69,7 +69,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
|
||||
@Test
|
||||
public void shouldCreateWithInitialCapacity() throws Exception {
|
||||
ConcurrentReferenceHashMap<Integer, String> map = new ConcurrentReferenceHashMap<Integer, String>(32);
|
||||
ConcurrentReferenceHashMap<Integer, String> map = new ConcurrentReferenceHashMap<>(32);
|
||||
assertThat(map.getSegmentsSize(), is(16));
|
||||
assertThat(map.getSegment(0).getSize(), is(2));
|
||||
assertThat(map.getLoadFactor(), is(0.75f));
|
||||
@@ -77,7 +77,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
|
||||
@Test
|
||||
public void shouldCreateWithInitialCapacityAndLoadFactor() throws Exception {
|
||||
ConcurrentReferenceHashMap<Integer, String> map = new ConcurrentReferenceHashMap<Integer, String>(32, 0.5f);
|
||||
ConcurrentReferenceHashMap<Integer, String> map = new ConcurrentReferenceHashMap<>(32, 0.5f);
|
||||
assertThat(map.getSegmentsSize(), is(16));
|
||||
assertThat(map.getSegment(0).getSize(), is(2));
|
||||
assertThat(map.getLoadFactor(), is(0.5f));
|
||||
@@ -85,7 +85,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
|
||||
@Test
|
||||
public void shouldCreateWithInitialCapacityAndConcurrenyLevel() throws Exception {
|
||||
ConcurrentReferenceHashMap<Integer, String> map = new ConcurrentReferenceHashMap<Integer, String>(16, 2);
|
||||
ConcurrentReferenceHashMap<Integer, String> map = new ConcurrentReferenceHashMap<>(16, 2);
|
||||
assertThat(map.getSegmentsSize(), is(2));
|
||||
assertThat(map.getSegment(0).getSize(), is(8));
|
||||
assertThat(map.getLoadFactor(), is(0.75f));
|
||||
@@ -93,7 +93,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
|
||||
@Test
|
||||
public void shouldCreateFullyCustom() throws Exception {
|
||||
ConcurrentReferenceHashMap<Integer, String> map = new ConcurrentReferenceHashMap<Integer, String>(5, 0.5f, 3);
|
||||
ConcurrentReferenceHashMap<Integer, String> map = new ConcurrentReferenceHashMap<>(5, 0.5f, 3);
|
||||
// concurrencyLevel of 3 ends up as 4 (nearest power of 2)
|
||||
assertThat(map.getSegmentsSize(), is(4));
|
||||
// initialCapacity is 5/4 (rounded up, to nearest power of 2)
|
||||
@@ -174,7 +174,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
@Test
|
||||
public void shouldGetFollowingNexts() throws Exception {
|
||||
// Use loadFactor to disable resize
|
||||
this.map = new TestWeakConcurrentCache<Integer, String>(1, 10.0f, 1);
|
||||
this.map = new TestWeakConcurrentCache<>(1, 10.0f, 1);
|
||||
this.map.put(1, "1");
|
||||
this.map.put(2, "2");
|
||||
this.map.put(3, "3");
|
||||
@@ -187,7 +187,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
|
||||
@Test
|
||||
public void shouldResize() throws Exception {
|
||||
this.map = new TestWeakConcurrentCache<Integer, String>(1, 0.75f, 1);
|
||||
this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1);
|
||||
this.map.put(1, "1");
|
||||
assertThat(this.map.getSegment(0).getSize(), is(1));
|
||||
assertThat(this.map.get(1), is("1"));
|
||||
@@ -217,7 +217,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
|
||||
@Test
|
||||
public void shouldPurgeOnGet() throws Exception {
|
||||
this.map = new TestWeakConcurrentCache<Integer, String>(1, 0.75f, 1);
|
||||
this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1);
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
this.map.put(i, String.valueOf(i));
|
||||
}
|
||||
@@ -232,7 +232,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
|
||||
@Test
|
||||
public void shouldPergeOnPut() throws Exception {
|
||||
this.map = new TestWeakConcurrentCache<Integer, String>(1, 0.75f, 1);
|
||||
this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1);
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
this.map.put(i, String.valueOf(i));
|
||||
}
|
||||
@@ -377,7 +377,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
|
||||
@Test
|
||||
public void shouldPutAll() throws Exception {
|
||||
Map<Integer, String> m = new HashMap<Integer, String>();
|
||||
Map<Integer, String> m = new HashMap<>();
|
||||
m.put(123, "123");
|
||||
m.put(456, null);
|
||||
m.put(null, "789");
|
||||
@@ -405,7 +405,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
this.map.put(123, "123");
|
||||
this.map.put(456, null);
|
||||
this.map.put(null, "789");
|
||||
Set<Integer> expected = new HashSet<Integer>();
|
||||
Set<Integer> expected = new HashSet<>();
|
||||
expected.add(123);
|
||||
expected.add(456);
|
||||
expected.add(null);
|
||||
@@ -417,8 +417,8 @@ public class ConcurrentReferenceHashMapTests {
|
||||
this.map.put(123, "123");
|
||||
this.map.put(456, null);
|
||||
this.map.put(null, "789");
|
||||
List<String> actual = new ArrayList<String>(this.map.values());
|
||||
List<String> expected = new ArrayList<String>();
|
||||
List<String> actual = new ArrayList<>(this.map.values());
|
||||
List<String> expected = new ArrayList<>();
|
||||
expected.add("123");
|
||||
expected.add(null);
|
||||
expected.add("789");
|
||||
@@ -432,7 +432,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
this.map.put(123, "123");
|
||||
this.map.put(456, null);
|
||||
this.map.put(null, "789");
|
||||
HashMap<Integer, String> expected = new HashMap<Integer, String>();
|
||||
HashMap<Integer, String> expected = new HashMap<>();
|
||||
expected.put(123, "123");
|
||||
expected.put(456, null);
|
||||
expected.put(null, "789");
|
||||
@@ -442,11 +442,11 @@ public class ConcurrentReferenceHashMapTests {
|
||||
@Test
|
||||
public void shouldGetEntrySetFollowingNext() throws Exception {
|
||||
// Use loadFactor to disable resize
|
||||
this.map = new TestWeakConcurrentCache<Integer, String>(1, 10.0f, 1);
|
||||
this.map = new TestWeakConcurrentCache<>(1, 10.0f, 1);
|
||||
this.map.put(1, "1");
|
||||
this.map.put(2, "2");
|
||||
this.map.put(3, "3");
|
||||
HashMap<Integer, String> expected = new HashMap<Integer, String>();
|
||||
HashMap<Integer, String> expected = new HashMap<>();
|
||||
expected.put(1, "1");
|
||||
expected.put(2, "2");
|
||||
expected.put(3, "3");
|
||||
@@ -491,7 +491,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
|
||||
@Override
|
||||
public WeakReference<String> newValue(int v) {
|
||||
return new WeakReference<String>(String.valueOf(v));
|
||||
return new WeakReference<>(String.valueOf(v));
|
||||
}
|
||||
});
|
||||
System.out.println(mapTime.prettyPrint());
|
||||
@@ -567,7 +567,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
|
||||
private int supplimentalHash;
|
||||
|
||||
private final LinkedList<MockReference<K, V>> queue = new LinkedList<MockReference<K, V>>();
|
||||
private final LinkedList<MockReference<K, V>> queue = new LinkedList<>();
|
||||
|
||||
private boolean disableTestHooks;
|
||||
|
||||
@@ -610,7 +610,7 @@ public class ConcurrentReferenceHashMapTests {
|
||||
if (TestWeakConcurrentCache.this.disableTestHooks) {
|
||||
return super.createReference(entry, hash, next);
|
||||
}
|
||||
return new MockReference<K, V>(entry, hash, next, TestWeakConcurrentCache.this.queue);
|
||||
return new MockReference<>(entry, hash, next, TestWeakConcurrentCache.this.queue);
|
||||
}
|
||||
@Override
|
||||
public Reference<K, V> pollForPurge() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,14 +28,14 @@ public class InstanceFilterTests {
|
||||
|
||||
@Test
|
||||
public void emptyFilterApplyMatchIfEmpty() {
|
||||
InstanceFilter<String> filter = new InstanceFilter<String>(null, null, true);
|
||||
InstanceFilter<String> filter = new InstanceFilter<>(null, null, true);
|
||||
match(filter, "foo");
|
||||
match(filter, "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includesFilter() {
|
||||
InstanceFilter<String> filter = new InstanceFilter<String>(
|
||||
InstanceFilter<String> filter = new InstanceFilter<>(
|
||||
asList("First", "Second"), null, true);
|
||||
match(filter, "Second");
|
||||
doNotMatch(filter, "foo");
|
||||
@@ -43,7 +43,7 @@ public class InstanceFilterTests {
|
||||
|
||||
@Test
|
||||
public void excludesFilter() {
|
||||
InstanceFilter<String> filter = new InstanceFilter<String>(
|
||||
InstanceFilter<String> filter = new InstanceFilter<>(
|
||||
null, asList("First", "Second"), true);
|
||||
doNotMatch(filter, "Second");
|
||||
match(filter, "foo");
|
||||
@@ -51,7 +51,7 @@ public class InstanceFilterTests {
|
||||
|
||||
@Test
|
||||
public void includesAndExcludesFilters() {
|
||||
InstanceFilter<String> filter = new InstanceFilter<String>(
|
||||
InstanceFilter<String> filter = new InstanceFilter<>(
|
||||
asList("foo", "Bar"), asList("First", "Second"), true);
|
||||
doNotMatch(filter, "Second");
|
||||
match(filter, "foo");
|
||||
@@ -59,7 +59,7 @@ public class InstanceFilterTests {
|
||||
|
||||
@Test
|
||||
public void includesAndExcludesFiltersConflict() {
|
||||
InstanceFilter<String> filter = new InstanceFilter<String>(
|
||||
InstanceFilter<String> filter = new InstanceFilter<>(
|
||||
asList("First"), asList("First"), true);
|
||||
doNotMatch(filter, "First");
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
public class LinkedCaseInsensitiveMapTests {
|
||||
|
||||
private final LinkedCaseInsensitiveMap<String> map = new LinkedCaseInsensitiveMap<String>();
|
||||
private final LinkedCaseInsensitiveMap<String> map = new LinkedCaseInsensitiveMap<>();
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ public class LinkedMultiValueMapTests {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
map = new LinkedMultiValueMap<String, String>();
|
||||
map = new LinkedMultiValueMap<>();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -44,7 +44,7 @@ public class LinkedMultiValueMapTests {
|
||||
map.add("key", "value1");
|
||||
map.add("key", "value2");
|
||||
assertEquals(1, map.size());
|
||||
List<String> expected = new ArrayList<String>(2);
|
||||
List<String> expected = new ArrayList<>(2);
|
||||
expected.add("value1");
|
||||
expected.add("value2");
|
||||
assertEquals(expected, map.get("key"));
|
||||
@@ -52,7 +52,7 @@ public class LinkedMultiValueMapTests {
|
||||
|
||||
@Test
|
||||
public void getFirst() {
|
||||
List<String> values = new ArrayList<String>(2);
|
||||
List<String> values = new ArrayList<>(2);
|
||||
values.add("value1");
|
||||
values.add("value2");
|
||||
map.put("key", values);
|
||||
@@ -72,11 +72,11 @@ public class LinkedMultiValueMapTests {
|
||||
public void equals() {
|
||||
map.set("key1", "value1");
|
||||
assertEquals(map, map);
|
||||
MultiValueMap<String, String> o1 = new LinkedMultiValueMap<String, String>();
|
||||
MultiValueMap<String, String> o1 = new LinkedMultiValueMap<>();
|
||||
o1.set("key1", "value1");
|
||||
assertEquals(map, o1);
|
||||
assertEquals(o1, map);
|
||||
Map<String, List<String>> o2 = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> o2 = new HashMap<>();
|
||||
o2.put("key1", Collections.singletonList("value1"));
|
||||
assertEquals(map, o2);
|
||||
assertEquals(o2, map);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -110,7 +110,7 @@ public class ObjectUtilsTests {
|
||||
assertTrue(isEmpty(Collections.emptyList()));
|
||||
assertTrue(isEmpty(Collections.emptySet()));
|
||||
|
||||
Set<String> set = new HashSet<String>();
|
||||
Set<String> set = new HashSet<>();
|
||||
set.add("foo");
|
||||
assertFalse(isEmpty(set));
|
||||
assertFalse(isEmpty(Arrays.asList("foo")));
|
||||
@@ -120,7 +120,7 @@ public class ObjectUtilsTests {
|
||||
public void isEmptyMap() {
|
||||
assertTrue(isEmpty(Collections.emptyMap()));
|
||||
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("foo", 42L);
|
||||
assertFalse(isEmpty(map));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -362,9 +362,9 @@ public class ReflectionUtilsTests {
|
||||
|
||||
private static class ListSavingMethodCallback implements ReflectionUtils.MethodCallback {
|
||||
|
||||
private List<String> methodNames = new LinkedList<String>();
|
||||
private List<String> methodNames = new LinkedList<>();
|
||||
|
||||
private List<Method> methods = new LinkedList<Method>();
|
||||
private List<Method> methods = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public void doWith(Method m) throws IllegalArgumentException, IllegalAccessException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,7 +38,7 @@ public class ComparableComparatorTests {
|
||||
|
||||
@Test
|
||||
public void testComparableComparator() {
|
||||
Comparator<String> c = new ComparableComparator<String>();
|
||||
Comparator<String> c = new ComparableComparator<>();
|
||||
String s1 = "abc";
|
||||
String s2 = "cde";
|
||||
assertTrue(c.compare(s1, s2) < 0);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ public class CompoundComparatorTests {
|
||||
|
||||
@Test
|
||||
public void shouldNeedAtLeastOneComparator() {
|
||||
Comparator<String> c = new CompoundComparator<String>();
|
||||
Comparator<String> c = new CompoundComparator<>();
|
||||
thrown.expect(IllegalStateException.class);
|
||||
c.compare("foo", "bar");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,7 @@ public class InstanceComparatorTests {
|
||||
|
||||
@Test
|
||||
public void shouldCompareClasses() throws Exception {
|
||||
Comparator<Object> comparator = new InstanceComparator<Object>(C1.class, C2.class);
|
||||
Comparator<Object> comparator = new InstanceComparator<>(C1.class, C2.class);
|
||||
assertThat(comparator.compare(c1, c1), is(0));
|
||||
assertThat(comparator.compare(c1, c2), is(-1));
|
||||
assertThat(comparator.compare(c2, c1), is(1));
|
||||
@@ -51,7 +51,7 @@ public class InstanceComparatorTests {
|
||||
|
||||
@Test
|
||||
public void shouldCompareInterfaces() throws Exception {
|
||||
Comparator<Object> comparator = new InstanceComparator<Object>(I1.class, I2.class);
|
||||
Comparator<Object> comparator = new InstanceComparator<>(I1.class, I2.class);
|
||||
assertThat(comparator.compare(c1, c1), is(0));
|
||||
assertThat(comparator.compare(c1, c2), is(0));
|
||||
assertThat(comparator.compare(c2, c1), is(0));
|
||||
@@ -62,7 +62,7 @@ public class InstanceComparatorTests {
|
||||
|
||||
@Test
|
||||
public void shouldCompareMix() throws Exception {
|
||||
Comparator<Object> comparator = new InstanceComparator<Object>(I1.class, C3.class);
|
||||
Comparator<Object> comparator = new InstanceComparator<>(I1.class, C3.class);
|
||||
assertThat(comparator.compare(c1, c1), is(0));
|
||||
assertThat(comparator.compare(c3, c4), is(-1));
|
||||
assertThat(comparator.compare(c3, null), is(-1));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,22 +33,22 @@ import static org.junit.Assert.*;
|
||||
|
||||
public class InvertibleComparatorTests {
|
||||
|
||||
private Comparator<Integer> comparator = new ComparableComparator<Integer>();
|
||||
private Comparator<Integer> comparator = new ComparableComparator<>();
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void shouldNeedComparator() throws Exception {
|
||||
new InvertibleComparator<Object>(null);
|
||||
new InvertibleComparator<>(null);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void shouldNeedComparatorWithAscending() throws Exception {
|
||||
new InvertibleComparator<Object>(null, true);
|
||||
new InvertibleComparator<>(null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDefaultToAscending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator =
|
||||
new InvertibleComparator<Integer>(comparator);
|
||||
new InvertibleComparator<>(comparator);
|
||||
assertThat(invertibleComparator.isAscending(), is(true));
|
||||
assertThat(invertibleComparator.compare(1, 2), is(-1));
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class InvertibleComparatorTests {
|
||||
@Test
|
||||
public void shouldInvert() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator =
|
||||
new InvertibleComparator<Integer>(comparator);
|
||||
new InvertibleComparator<>(comparator);
|
||||
assertThat(invertibleComparator.isAscending(), is(true));
|
||||
assertThat(invertibleComparator.compare(1, 2), is(-1));
|
||||
invertibleComparator.invertOrder();
|
||||
@@ -67,14 +67,14 @@ public class InvertibleComparatorTests {
|
||||
@Test
|
||||
public void shouldCompareAscending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator =
|
||||
new InvertibleComparator<Integer>(comparator, true);
|
||||
new InvertibleComparator<>(comparator, true);
|
||||
assertThat(invertibleComparator.compare(1, 2), is(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCompareDescending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator =
|
||||
new InvertibleComparator<Integer>(comparator, false);
|
||||
new InvertibleComparator<>(comparator, false);
|
||||
assertThat(invertibleComparator.compare(1, 2), is(1));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,7 @@ public class ListenableFutureTaskTests {
|
||||
return s;
|
||||
}
|
||||
};
|
||||
ListenableFutureTask<String> task = new ListenableFutureTask<String>(callable);
|
||||
ListenableFutureTask<String> task = new ListenableFutureTask<>(callable);
|
||||
task.addCallback(new ListenableFutureCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
@@ -63,7 +63,7 @@ public class ListenableFutureTaskTests {
|
||||
throw new IOException(s);
|
||||
}
|
||||
};
|
||||
ListenableFutureTask<String> task = new ListenableFutureTask<String>(callable);
|
||||
ListenableFutureTask<String> task = new ListenableFutureTask<>(callable);
|
||||
task.addCallback(new ListenableFutureCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
|
||||
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.*;
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class SettableListenableFutureTests {
|
||||
|
||||
private final SettableListenableFuture<String> settableListenableFuture = new SettableListenableFuture<String>();
|
||||
private final SettableListenableFuture<String> settableListenableFuture = new SettableListenableFuture<>();
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -179,7 +179,7 @@ public class SimpleNamespaceContextTests {
|
||||
|
||||
|
||||
private Set<String> getItemSet(Iterator<String> iterator) {
|
||||
Set<String> itemSet = new HashSet<String>();
|
||||
Set<String> itemSet = new HashSet<>();
|
||||
while (iterator.hasNext()) {
|
||||
itemSet.add(iterator.next());
|
||||
}
|
||||
@@ -187,7 +187,7 @@ public class SimpleNamespaceContextTests {
|
||||
}
|
||||
|
||||
private Set<String> makeSet(String... items) {
|
||||
Set<String> itemSet = new HashSet<String>();
|
||||
Set<String> itemSet = new HashSet<>();
|
||||
for (String item : items) {
|
||||
itemSet.add(item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user