1919
2020import com .google .common .collect .ImmutableMap ;
2121import com .google .common .reflect .TypeToken ;
22+
2223import org .junit .Test ;
2324import org .junit .experimental .categories .Category ;
2425import org .openqa .selenium .Capabilities ;
@@ -129,14 +130,6 @@ public void shouldUseBeanSettersToPopulateFields() {
129130 assertThat (seen .theName ).isEqualTo ("fishy" );
130131 }
131132
132- public static class BeanWithSetter {
133- String theName ;
134-
135- public void setName (String name ) {
136- theName = name ;
137- }
138- }
139-
140133 @ Test
141134 public void shouldAllowUserToPopulateFieldsDirectly () {
142135 Map <String , String > map = ImmutableMap .of ("theName" , "fishy" );
@@ -159,14 +152,6 @@ public void settingFinalFieldsShouldWork() {
159152 assertThat (seen .theName ).isEqualTo ("fishy" );
160153 }
161154
162- public static class BeanWithFinalField {
163- private final String theName ;
164-
165- public BeanWithFinalField () {
166- this .theName = "magic" ;
167- }
168- }
169-
170155 @ Test
171156 public void canConstructASimpleString () {
172157 String text = new Json ().toType ("\" cheese\" " , String .class );
@@ -257,14 +242,16 @@ public void shouldPopulateFieldsOnNestedBeans() {
257242
258243 @ Test
259244 public void shouldProperlyFillInACapabilitiesObject () {
260- DesiredCapabilities capabilities =
261- new DesiredCapabilities ( "browser" , CapabilityType .VERSION , Platform . ANY );
262- capabilities . setJavascriptEnabled ( true );
245+ DesiredCapabilities capabilities = new DesiredCapabilities ( CapabilityType . BROWSER_NAME ,
246+ CapabilityType .BROWSER_VERSION ,
247+ Platform . ANY );
263248 String text = new Json ().toJson (capabilities );
264249
265250 Capabilities readCapabilities = new Json ().toType (text , DesiredCapabilities .class );
266251
267- assertThat (readCapabilities ).isEqualTo (capabilities );
252+ assertThat (readCapabilities .getBrowserName ()).isEqualTo (capabilities .getBrowserName ());
253+ assertThat (readCapabilities .getBrowserVersion ()).isEqualTo (capabilities .getBrowserVersion ());
254+ assertThat (readCapabilities .getPlatformName ()).isEqualTo (capabilities .getPlatformName ());
268255 }
269256
270257 @ Test
@@ -536,14 +523,33 @@ public void canCoerceSimpleValuesToStrings() {
536523 Json json = new Json ();
537524 String raw = json .toJson (value );
538525 Map <String , String > roundTripped = json .toType (
539- raw ,
540- new TypeToken <Map <String , String >>(){}.getType ());
526+ raw ,
527+ new TypeToken <Map <String , String >>() {
528+ }.getType ());
541529
542530 assertThat (roundTripped .get ("boolean" )).isEqualTo ("true" );
543531 assertThat (roundTripped .get ("integer" )).isEqualTo ("42" );
544532 assertThat (roundTripped .get ("float" )).isEqualTo ("3.14" );
545533 }
546534
535+ public static class BeanWithSetter {
536+
537+ String theName ;
538+
539+ public void setName (String name ) {
540+ theName = name ;
541+ }
542+ }
543+
544+ public static class BeanWithFinalField {
545+
546+ private final String theName ;
547+
548+ public BeanWithFinalField () {
549+ this .theName = "magic" ;
550+ }
551+ }
552+
547553 public static class SimpleBean {
548554
549555 private String value ;
0 commit comments