19
19
20
20
import com .google .common .collect .ImmutableMap ;
21
21
import com .google .common .reflect .TypeToken ;
22
+
22
23
import org .junit .Test ;
23
24
import org .junit .experimental .categories .Category ;
24
25
import org .openqa .selenium .Capabilities ;
@@ -129,14 +130,6 @@ public void shouldUseBeanSettersToPopulateFields() {
129
130
assertThat (seen .theName ).isEqualTo ("fishy" );
130
131
}
131
132
132
- public static class BeanWithSetter {
133
- String theName ;
134
-
135
- public void setName (String name ) {
136
- theName = name ;
137
- }
138
- }
139
-
140
133
@ Test
141
134
public void shouldAllowUserToPopulateFieldsDirectly () {
142
135
Map <String , String > map = ImmutableMap .of ("theName" , "fishy" );
@@ -159,14 +152,6 @@ public void settingFinalFieldsShouldWork() {
159
152
assertThat (seen .theName ).isEqualTo ("fishy" );
160
153
}
161
154
162
- public static class BeanWithFinalField {
163
- private final String theName ;
164
-
165
- public BeanWithFinalField () {
166
- this .theName = "magic" ;
167
- }
168
- }
169
-
170
155
@ Test
171
156
public void canConstructASimpleString () {
172
157
String text = new Json ().toType ("\" cheese\" " , String .class );
@@ -257,14 +242,16 @@ public void shouldPopulateFieldsOnNestedBeans() {
257
242
258
243
@ Test
259
244
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 );
263
248
String text = new Json ().toJson (capabilities );
264
249
265
250
Capabilities readCapabilities = new Json ().toType (text , DesiredCapabilities .class );
266
251
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 ());
268
255
}
269
256
270
257
@ Test
@@ -536,14 +523,33 @@ public void canCoerceSimpleValuesToStrings() {
536
523
Json json = new Json ();
537
524
String raw = json .toJson (value );
538
525
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 ());
541
529
542
530
assertThat (roundTripped .get ("boolean" )).isEqualTo ("true" );
543
531
assertThat (roundTripped .get ("integer" )).isEqualTo ("42" );
544
532
assertThat (roundTripped .get ("float" )).isEqualTo ("3.14" );
545
533
}
546
534
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
+
547
553
public static class SimpleBean {
548
554
549
555
private String value ;
0 commit comments