44import static com .google .common .base .Charsets .UTF_8 ;
55import static com .google .common .net .HttpHeaders .CONTENT_TYPE ;
66import static com .google .common .net .MediaType .JSON_UTF_8 ;
7+ import static java .net .HttpURLConnection .HTTP_BAD_REQUEST ;
8+ import static java .net .HttpURLConnection .HTTP_INTERNAL_ERROR ;
9+ import static java .net .HttpURLConnection .HTTP_NO_CONTENT ;
10+ import static java .net .HttpURLConnection .HTTP_OK ;
711import static org .hamcrest .Matchers .is ;
812import static org .junit .Assert .assertEquals ;
913import static org .junit .Assert .assertNull ;
@@ -35,7 +39,7 @@ public void convertsResponses_success() throws JSONException {
3539 response .setValue (ImmutableMap .of ("color" , "red" ));
3640
3741 HttpResponse converted = codec .encode (response );
38- assertThat (converted .getStatus (), is (HttpStatusCodes . OK ));
42+ assertThat (converted .getStatus (), is (HTTP_OK ));
3943 assertThat (converted .getHeader (CONTENT_TYPE ), is (JSON_UTF_8 .toString ()));
4044
4145 Response rebuilt = new JsonToBeanConverter ().convert (
@@ -54,7 +58,7 @@ public void convertsResponses_failure() throws JSONException {
5458 response .setValue (ImmutableMap .of ("color" , "red" ));
5559
5660 HttpResponse converted = codec .encode (response );
57- assertThat (converted .getStatus (), is (HttpStatusCodes . INTERNAL_SERVER_ERROR ));
61+ assertThat (converted .getStatus (), is (HTTP_INTERNAL_ERROR ));
5862 assertThat (converted .getHeader (CONTENT_TYPE ), is (JSON_UTF_8 .toString ()));
5963
6064 Response rebuilt = new JsonToBeanConverter ().convert (
@@ -83,7 +87,7 @@ public void roundTrip() throws JSONException {
8387 @ Test
8488 public void decodeNonJsonResponse_200 () throws JSONException {
8589 HttpResponse response = new HttpResponse ();
86- response .setStatus (HttpStatusCodes . OK );
90+ response .setStatus (HTTP_OK );
8791 response .setContent ("foobar" .getBytes (UTF_8 ));
8892
8993 Response decoded = codec .decode (response );
@@ -94,7 +98,7 @@ public void decodeNonJsonResponse_200() throws JSONException {
9498 @ Test
9599 public void decodeNonJsonResponse_204 () throws JSONException {
96100 HttpResponse response = new HttpResponse ();
97- response .setStatus (HttpStatusCodes . NO_CONTENT );
101+ response .setStatus (HTTP_NO_CONTENT );
98102
99103 Response decoded = codec .decode (response );
100104 assertEquals (ErrorCodes .SUCCESS , decoded .getStatus ());
@@ -104,7 +108,7 @@ public void decodeNonJsonResponse_204() throws JSONException {
104108 @ Test
105109 public void decodeNonJsonResponse_4xx () throws JSONException {
106110 HttpResponse response = new HttpResponse ();
107- response .setStatus (HttpStatusCodes . BAD_REQUEST );
111+ response .setStatus (HTTP_BAD_REQUEST );
108112 response .setContent ("foobar" .getBytes (UTF_8 ));
109113
110114 Response decoded = codec .decode (response );
@@ -115,7 +119,7 @@ public void decodeNonJsonResponse_4xx() throws JSONException {
115119 @ Test
116120 public void decodeNonJsonResponse_5xx () throws JSONException {
117121 HttpResponse response = new HttpResponse ();
118- response .setStatus (HttpStatusCodes . INTERNAL_SERVER_ERROR );
122+ response .setStatus (HTTP_INTERNAL_ERROR );
119123 response .setContent ("foobar" .getBytes (UTF_8 ));
120124
121125 Response decoded = codec .decode (response );
@@ -130,7 +134,7 @@ public void decodeJsonResponseMissingContentType() throws JSONException {
130134 response .setValue (ImmutableMap .of ("color" , "red" ));
131135
132136 HttpResponse httpResponse = new HttpResponse ();
133- httpResponse .setStatus (HttpStatusCodes . OK );
137+ httpResponse .setStatus (HTTP_OK );
134138 httpResponse .setContent (
135139 new BeanToJsonConverter ().convert (response ).getBytes (UTF_8 ));
136140
0 commit comments