@@ -64,6 +64,18 @@ public class HTTPClientTest {
6464 verify (client , times (1 )).request ("GET" , "/foo" , params , null );
6565 }
6666
67+ @ Test public void testDeleteWithoutParams () throws ResponseException {
68+ when (client .delete (anyString ())).thenCallRealMethod ();
69+ client .delete ("/foo" );
70+ verify (client , times (1 )).request ("DELETE" , "/foo" , null , null );
71+ }
72+
73+ @ Test public void testDeletetWithParams () throws ResponseException {
74+ when (client .delete (anyString (), any (Params .class ))).thenCallRealMethod ();
75+ client .delete ("/foo" , params );
76+ verify (client , times (1 )).request ("DELETE" , "/foo" , params , null );
77+ }
78+
6779 @ Test public void testPostWithoutParamsWithoutBody () throws ResponseException {
6880 when (client .post (anyString ())).thenCallRealMethod ();
6981 client .post ("/foo" );
@@ -111,6 +123,26 @@ public class HTTPClientTest {
111123 assertEquals (((JsonArray ) response .getData ()).size (), 1 );
112124 }
113125
126+ @ Test public void testUnauthenticatedDeleteRequest () throws ResponseException , IOException {
127+ when (request .getVerb ()).thenReturn ("DELETE" );
128+ when (request .getParams ()).thenReturn (params );
129+ when (request .getConnection ()).thenReturn (connection );
130+
131+ when (connection .getResponseCode ()).thenReturn (200 );
132+ when (connection .getHeaderField ("Content-Type" )).thenReturn (
133+ "application/json" );
134+ when (connection .getInputStream ()).thenReturn (
135+ new ByteArrayInputStream ("{ \" data\" : [{}]}" .getBytes ()));
136+
137+ when (client .buildRequest ("DELETE" , "/foo" , params , null ,null )).thenReturn (request );
138+ when (client .unauthenticatedRequest ("DELETE" , "/foo" , params , null ,null )).thenCallRealMethod ();
139+
140+ Response response = client .unauthenticatedRequest ("DELETE" , "/foo" , params , null , null );
141+
142+ assertTrue (response .isParsed ());
143+ assertEquals (((JsonArray ) response .getData ()).size (), 1 );
144+ }
145+
114146 @ Test public void testUnauthenticatedPostRequest () throws ResponseException , IOException {
115147 when (request .getVerb ()).thenReturn ("POST" );
116148 when (request .getParams ()).thenReturn (params );
0 commit comments