2323import static org .hamcrest .Matchers .not ;
2424import static org .junit .Assert .assertEquals ;
2525import static org .junit .Assert .assertFalse ;
26+ import static org .junit .Assert .assertNotEquals ;
2627import static org .junit .Assert .assertThat ;
2728import static org .junit .Assert .assertTrue ;
2829import static org .junit .Assert .fail ;
29- import static org .openqa .selenium .json .Json .MAP_TYPE ;
3030
3131import com .google .common .collect .ImmutableMap ;
3232import com .google .common .collect .ImmutableSortedSet ;
3838import com .google .gson .JsonSyntaxException ;
3939
4040import org .junit .Test ;
41- import org .junit .runner .RunWith ;
42- import org .junit .runners .JUnit4 ;
4341import org .openqa .selenium .Capabilities ;
4442import org .openqa .selenium .Cookie ;
4543import org .openqa .selenium .ImmutableCapabilities ;
5957import org .openqa .selenium .remote .SessionId ;
6058
6159import java .awt .*;
62- import java .beans .FeatureDescriptor ;
63- import java .beans .IntrospectionException ;
64- import java .beans .Introspector ;
65- import java .beans .PropertyDescriptor ;
6660import java .io .StringReader ;
6761import java .net .MalformedURLException ;
6862import java .net .URL ;
7771import java .util .stream .Stream ;
7872
7973
80- @ RunWith (JUnit4 .class )
8174public class BeanToJsonConverterTest {
8275
8376 @ Test
84- public void testShouldBeAbleToConvertASimpleString () throws Exception {
77+ public void testShouldBeAbleToConvertASimpleString () {
8578 String json = new BeanToJsonConverter ().convert ("cheese" );
8679
8780 assertThat (json , is ("\" cheese\" " ));
8881 }
8982
9083 @ Test
91- public void testShouldConvertAMapIntoAJsonObject () throws Exception {
84+ public void testShouldConvertAMapIntoAJsonObject () {
9285 Map <String , String > toConvert = new HashMap <>();
9386 toConvert .put ("cheese" , "cheddar" );
9487 toConvert .put ("fish" , "nice bit of haddock" );
@@ -100,7 +93,7 @@ public void testShouldConvertAMapIntoAJsonObject() throws Exception {
10093 }
10194
10295 @ Test
103- public void testShouldConvertASimpleJavaBean () throws Exception {
96+ public void testShouldConvertASimpleJavaBean () {
10497 String json = new BeanToJsonConverter ().convert (new SimpleBean ());
10598
10699 JsonObject converted = new JsonParser ().parse (json ).getAsJsonObject ();
@@ -110,7 +103,7 @@ public void testShouldConvertASimpleJavaBean() throws Exception {
110103 }
111104
112105 @ Test
113- public void testShouldConvertArrays () throws Exception {
106+ public void testShouldConvertArrays () {
114107 String json = new BeanToJsonConverter ().convert (new BeanWithArray ());
115108
116109 JsonObject converted = new JsonParser ().parse (json ).getAsJsonObject ();
@@ -119,7 +112,7 @@ public void testShouldConvertArrays() throws Exception {
119112 }
120113
121114 @ Test
122- public void testShouldConvertCollections () throws Exception {
115+ public void testShouldConvertCollections () {
123116 String json = new BeanToJsonConverter ().convert (new BeanWithCollection ());
124117
125118 JsonObject converted = new JsonParser ().parse (json ).getAsJsonObject ();
@@ -128,7 +121,7 @@ public void testShouldConvertCollections() throws Exception {
128121 }
129122
130123 @ Test
131- public void testShouldConvertNumbersAsLongs () throws Exception {
124+ public void testShouldConvertNumbersAsLongs () {
132125 String json = new BeanToJsonConverter ().convert (new Exception ());
133126 Map <?,?> map = new JsonToBeanConverter ().convert (Map .class , json );
134127
@@ -140,7 +133,7 @@ public void testShouldConvertNumbersAsLongs() throws Exception {
140133 }
141134
142135 @ Test
143- public void testShouldNotChokeWhenCollectionIsNull () throws Exception {
136+ public void testShouldNotChokeWhenCollectionIsNull () {
144137 try {
145138 new BeanToJsonConverter ().convert (new BeanWithNullCollection ());
146139 } catch (Exception e ) {
@@ -150,30 +143,30 @@ public void testShouldNotChokeWhenCollectionIsNull() throws Exception {
150143 }
151144
152145 @ Test
153- public void testShouldConvertEnumsToStrings () throws Exception {
146+ public void testShouldConvertEnumsToStrings () {
154147 // If this doesn't hang indefinitely, we're all good
155148 new BeanToJsonConverter ().convert (State .INDIFFERENT );
156149 }
157150
158151 @ Test
159- public void testShouldConvertEnumsWithMethods () throws Exception {
152+ public void testShouldConvertEnumsWithMethods () {
160153 // If this doesn't hang indefinitely, we're all good
161154 new BeanToJsonConverter ().convert (WithMethods .CHEESE );
162155 }
163156
164157 @ Test
165- public void testNullAndAnEmptyStringAreEncodedDifferently () throws Exception {
158+ public void testNullAndAnEmptyStringAreEncodedDifferently () {
166159 BeanToJsonConverter
167160 converter = new BeanToJsonConverter ();
168161
169162 String nullValue = converter .convert (null );
170163 String emptyString = converter .convert ("" );
171164
172- assertFalse (emptyString . equals ( nullValue ) );
165+ assertNotEquals (emptyString , nullValue );
173166 }
174167
175168 @ Test
176- public void testShouldBeAbleToConvertAPoint () throws Exception {
169+ public void testShouldBeAbleToConvertAPoint () {
177170 Point point = new Point (65 , 75 );
178171
179172 try {
@@ -184,7 +177,7 @@ public void testShouldBeAbleToConvertAPoint() throws Exception {
184177 }
185178
186179 @ Test
187- public void testShouldEncodeClassNameAsClassProperty () throws Exception {
180+ public void testShouldEncodeClassNameAsClassProperty () {
188181 String json = new BeanToJsonConverter ().convert (new SimpleBean ());
189182
190183 JsonObject converted = new JsonParser ().parse (json ).getAsJsonObject ();
@@ -540,16 +533,14 @@ public void shouldConvertAUrlToAString() throws MalformedURLException {
540533 }
541534
542535 @ Test
543- public void shouldNotIncludePropertiesFromJavaLangObjectOtherThanClass ()
544- throws IntrospectionException {
536+ public void shouldNotIncludePropertiesFromJavaLangObjectOtherThanClass () {
545537 String json = new BeanToJsonConverter ().convert (new SimpleBean ());
546538
547539 JsonObject converted = new JsonParser ().parse (json ).getAsJsonObject ();
548540
549541 Stream .of (SimplePropertyDescriptor .getPropertyDescriptors (Object .class ))
550542 .filter (pd -> !"class" .equals (pd .getName ()))
551543 .map (SimplePropertyDescriptor ::getName )
552- .peek (System .out ::println )
553544 .forEach (name -> assertFalse (name , converted .keySet ().contains (name )));
554545 }
555546
@@ -595,14 +586,14 @@ public List<?> getList() {
595586 }
596587 }
597588
598- public static enum State {
589+ public enum State {
599590
600591 GOOD ,
601592 BAD ,
602593 INDIFFERENT
603594 }
604595
605- public static enum WithMethods {
596+ public enum WithMethods {
606597
607598 CHEESE () {
608599 @ Override
0 commit comments