3434import static org .hamcrest .core .Is .is ;
3535import static org .junit .Assert .*;
3636
37+ /**
38+ * Tests for {@link StreamConverter}.
39+ *
40+ * @author Stephane Nicoll
41+ * @since 4.2
42+ */
3743public class StreamConverterTests {
3844
3945 @ Rule
4046 public final ExpectedException thrown = ExpectedException .none ();
4147
42- private GenericConversionService conversionService ;
48+ private final GenericConversionService conversionService = new GenericConversionService () ;
4349
44- private StreamConverter streamConverter ;
50+ private final StreamConverter streamConverter = new StreamConverter ( this . conversionService ) ;
4551
4652 @ Before
4753 public void setup () {
48- this .conversionService = new GenericConversionService ();
49- this .streamConverter = new StreamConverter (this .conversionService );
50-
5154 this .conversionService .addConverter (new CollectionToCollectionConverter (this .conversionService ));
5255 this .conversionService .addConverter (new ArrayToCollectionConverter (this .conversionService ));
5356 this .conversionService .addConverter (new CollectionToArrayConverter (this .conversionService ));
@@ -111,6 +114,7 @@ public void convertFromStreamToArrayNoConverter() throws NoSuchFieldException {
111114 }
112115
113116 @ Test
117+ @ SuppressWarnings ("resource" )
114118 public void convertFromListToStream () throws NoSuchFieldException {
115119 this .conversionService .addConverterFactory (new StringToNumberConverterFactory ());
116120 List <String > stream = Arrays .asList ("1" , "2" , "3" );
@@ -124,6 +128,7 @@ public void convertFromListToStream() throws NoSuchFieldException {
124128 }
125129
126130 @ Test
131+ @ SuppressWarnings ("resource" )
127132 public void convertFromArrayToStream () throws NoSuchFieldException {
128133 Integer [] stream = new Integer [] {1 , 0 , 1 };
129134 this .conversionService .addConverter (new Converter <Integer , Boolean >() {
@@ -142,6 +147,7 @@ public Boolean convert(Integer source) {
142147 }
143148
144149 @ Test
150+ @ SuppressWarnings ("resource" )
145151 public void convertFromListToRawStream () throws NoSuchFieldException {
146152 List <String > stream = Arrays .asList ("1" , "2" , "3" );
147153 TypeDescriptor streamOfInteger = new TypeDescriptor (Types .class .getField ("rawStream" )); ;
@@ -169,7 +175,7 @@ public void shouldFailToConvertIfNoStream() throws NoSuchFieldException {
169175 new TypeDescriptor (Types .class .getField ("arrayOfLongs" )));
170176 }
171177
172- @ SuppressWarnings ("unused" )
178+ @ SuppressWarnings ({ "rawtypes" } )
173179 static class Types {
174180
175181 public List <String > listOfStrings ;
0 commit comments