11package com .myjeeva .digitalocean ;
22
3+ import static org .junit .Assert .assertEquals ;
4+
35import java .net .MalformedURLException ;
46import java .net .URISyntaxException ;
57import java .net .URL ;
68
7- import junit .framework .TestCase ;
8- import mockit .Expectations ;
9- import mockit .Mocked ;
10-
119import org .apache .http .HttpVersion ;
1210import org .apache .http .client .methods .HttpUriRequest ;
1311import org .apache .http .entity .ContentType ;
1412import org .apache .http .entity .StringEntity ;
1513import org .apache .http .impl .client .CloseableHttpClient ;
1614import org .apache .http .impl .execchain .PublicHttpResponseProxy ;
1715import org .apache .http .message .BasicHttpResponse ;
16+ import org .junit .Test ;
17+ import org .junit .runner .RunWith ;
18+ import org .junit .runners .JUnit4 ;
1819
1920import com .myjeeva .digitalocean .impl .DigitalOceanClient ;
2021
22+ import mockit .Expectations ;
23+ import mockit .Mocked ;
24+
2125@ SuppressWarnings ("unused" )
22- public class DigitalOceanMockTest extends TestCase {
26+ @ RunWith (JUnit4 .class )
27+ public class DigitalOceanMockTest {
2328
2429 private @ Mocked CloseableHttpClient defaultHttpClient ;
2530
31+ @ Test
2632 public void testSnapshotWithName () throws Exception {
2733
2834 new Expectations () {
2935 {
30- defaultHttpClient .execute ((HttpUriRequest ) with (new Object () {
36+ defaultHttpClient .execute ((HttpUriRequest )with (new Object () {
3137
3238 void validate (HttpUriRequest httpUriRequest ) throws MalformedURLException ,
3339 URISyntaxException {
3440 assertEquals (new URL ("https://api.digitalocean.com/v2/droplets/1234/actions" ).toURI (),
3541 httpUriRequest .getURI ());
3642 }
3743 }));
44+
3845 BasicHttpResponse basicHttpResponse = new BasicHttpResponse (HttpVersion .HTTP_1_1 , 200 , "" );
3946 basicHttpResponse
4047 .setEntity (new StringEntity (
@@ -43,7 +50,7 @@ void validate(HttpUriRequest httpUriRequest) throws MalformedURLException,
4350 basicHttpResponse .setHeader ("RateLimit-Limit" , "1200" );
4451 basicHttpResponse .setHeader ("RateLimit-Remaining" , "900" );
4552 basicHttpResponse .setHeader ("RateLimit-Reset" , "1415984218" );
46-
53+
4754 result = new PublicHttpResponseProxy (basicHttpResponse );
4855 }
4956 };
@@ -52,5 +59,3 @@ void validate(HttpUriRequest httpUriRequest) throws MalformedURLException,
5259 digitalOcean .takeDropletSnapshot (1234 , "snapshot-name" );
5360 }
5461}
55-
56-
0 commit comments