39
39
import org .junit .runners .JUnit4 ;
40
40
import org .openqa .selenium .ScriptTimeoutException ;
41
41
import org .openqa .selenium .WebDriverException ;
42
- import org .openqa .selenium .remote . BeanToJsonConverter ;
42
+ import org .openqa .selenium .json . Json ;
43
43
import org .openqa .selenium .remote .Dialect ;
44
44
import org .openqa .selenium .remote .ErrorCodes ;
45
- import org .openqa .selenium .remote .JsonToBeanConverter ;
46
45
import org .openqa .selenium .remote .RemoteWebElement ;
47
46
import org .openqa .selenium .remote .Response ;
48
47
@@ -61,8 +60,7 @@ public void convertsResponses_success() {
61
60
assertThat (converted .getStatus (), is (HTTP_OK ));
62
61
assertThat (converted .getHeader (CONTENT_TYPE ), is (JSON_UTF_8 .toString ()));
63
62
64
- Response rebuilt = new JsonToBeanConverter ().convert (
65
- Response .class , new String (converted .getContent (), UTF_8 ));
63
+ Response rebuilt = new Json ().toType (new String (converted .getContent (), UTF_8 ), Response .class );
66
64
67
65
assertEquals (response .getStatus (), rebuilt .getStatus ());
68
66
assertEquals (new ErrorCodes ().toState (response .getStatus ()), rebuilt .getState ());
@@ -80,8 +78,7 @@ public void convertsResponses_failure() {
80
78
assertThat (converted .getStatus (), is (HTTP_INTERNAL_ERROR ));
81
79
assertThat (converted .getHeader (CONTENT_TYPE ), is (JSON_UTF_8 .toString ()));
82
80
83
- Response rebuilt = new JsonToBeanConverter ().convert (
84
- Response .class , new String (converted .getContent (), UTF_8 ));
81
+ Response rebuilt = new Json ().toType (new String (converted .getContent (), UTF_8 ), Response .class );
85
82
86
83
assertEquals (response .getStatus (), rebuilt .getStatus ());
87
84
assertEquals (new ErrorCodes ().toState (response .getStatus ()), rebuilt .getState ());
@@ -154,8 +151,7 @@ public void decodeJsonResponseMissingContentType() {
154
151
155
152
HttpResponse httpResponse = new HttpResponse ();
156
153
httpResponse .setStatus (HTTP_OK );
157
- httpResponse .setContent (
158
- new BeanToJsonConverter ().convert (response ).getBytes (UTF_8 ));
154
+ httpResponse .setContent (new Json ().toJson (response ).getBytes (UTF_8 ));
159
155
160
156
Response decoded = codec .decode (httpResponse );
161
157
assertEquals (response .getStatus (), decoded .getStatus ());
@@ -189,7 +185,7 @@ public void decodeJsonResponseWithTrailingNullBytes() {
189
185
public void shouldConvertElementReferenceToRemoteWebElement () {
190
186
HttpResponse response = new HttpResponse ();
191
187
response .setStatus (HTTP_OK );
192
- response .setContent (new BeanToJsonConverter ().convert (ImmutableMap .of (
188
+ response .setContent (new Json ().toJson (ImmutableMap .of (
193
189
"status" , 0 ,
194
190
"value" , ImmutableMap .of (Dialect .OSS .getEncodedElementKey (), "345678" ))).getBytes (UTF_8 ));
195
191
@@ -206,8 +202,7 @@ public void shouldAttemptToConvertAnExceptionIntoAnActualExceptionInstance() {
206
202
207
203
HttpResponse httpResponse = new HttpResponse ();
208
204
httpResponse .setStatus (HTTP_CLIENT_TIMEOUT );
209
- httpResponse .setContent (
210
- new BeanToJsonConverter ().convert (response ).getBytes (UTF_8 ));
205
+ httpResponse .setContent (new Json ().toJson (response ).getBytes (UTF_8 ));
211
206
212
207
Response decoded = codec .decode (httpResponse );
213
208
assertEquals (ErrorCodes .ASYNC_SCRIPT_TIMEOUT , decoded .getStatus ().intValue ());
0 commit comments