2424import java .nio .file .Paths ;
2525import java .util .List ;
2626import java .util .Map ;
27- import junit .framework .TestCase ;
2827import okhttp3 .mockwebserver .MockResponse ;
2928import okhttp3 .mockwebserver .MockWebServer ;
3029import okhttp3 .mockwebserver .RecordedRequest ;
3332import org .apache .http .impl .client .HttpClients ;
3433import org .apache .http .impl .conn .DefaultProxyRoutePlanner ;
3534import org .hamcrest .collection .IsMapContaining ;
35+ import org .junit .After ;
3636import org .junit .Assert ;
37+ import org .junit .Before ;
3738import org .junit .jupiter .api .Assertions ;
3839import org .junit .jupiter .api .Test ;
3940
40- public class MindeeHttpApiTest extends TestCase {
41+ public class MindeeHttpApiTest {
4142
4243 MockWebServer mockWebServer = new MockWebServer ();
4344 private static ObjectMapper objectMapper = new ObjectMapper ();
4445
45- public void setUp () throws Exception {
46- super . setUp ();
46+ @ Before
47+ public void startWebServer () throws Exception {
4748 mockWebServer .start ();
4849 }
4950
50- public void tearDown () throws Exception {
51+ @ After
52+ public void stopWebServer () throws Exception {
5153 mockWebServer .shutdown ();
5254 }
5355
@@ -360,9 +362,9 @@ void givenError401_noToken_mustThrowMindeeHttpException()
360362 new Endpoint (InvoiceV4 .class ),
361363 parseParameter )
362364 );
363- assertEquals (401 , httpError .getStatusCode ());
364- assertEquals ("Authorization required" , httpError .getMessage ());
365- assertEquals ("No token provided" , httpError .getDetails ());
365+ Assertions . assertEquals (401 , httpError .getStatusCode ());
366+ Assertions . assertEquals ("Authorization required" , httpError .getMessage ());
367+ Assertions . assertEquals ("No token provided" , httpError .getDetails ());
366368 }
367369
368370 @ Test
@@ -386,10 +388,10 @@ void givenError429_mustThrowMindeeHttpException()
386388 new Endpoint (InvoiceV4 .class ),
387389 parseParameter )
388390 );
389- assertEquals (429 , httpError .getStatusCode ());
390- assertEquals ("Too many requests" , httpError .getMessage ());
391- assertEquals ("Too Many Requests." , httpError .getDetails ());
392- assertEquals ("TooManyRequests" , httpError .getCode ());
391+ Assertions . assertEquals (429 , httpError .getStatusCode ());
392+ Assertions . assertEquals ("Too many requests" , httpError .getMessage ());
393+ Assertions . assertEquals ("Too Many Requests." , httpError .getDetails ());
394+ Assertions . assertEquals ("TooManyRequests" , httpError .getCode ());
393395 }
394396
395397 @ Test
@@ -413,10 +415,10 @@ void givenError_inHtml_mustThrowMindeeHttpException()
413415 new Endpoint (InvoiceV4 .class ),
414416 parseParameter )
415417 );
416- assertEquals (413 , httpError .getStatusCode ());
417- assertEquals ("HTTP Status 413 - Unhandled server response, check details." , httpError .getMessage ());
418- assertTrue (httpError .getDetails ().contains ("<h1>An error occurred.</h1>" ));
419- assertEquals ("" , httpError .getCode ());
418+ Assertions . assertEquals (413 , httpError .getStatusCode ());
419+ Assertions . assertEquals ("HTTP Status 413 - Unhandled server response, check details." , httpError .getMessage ());
420+ Assertions . assertTrue (httpError .getDetails ().contains ("<h1>An error occurred.</h1>" ));
421+ Assertions . assertEquals ("" , httpError .getCode ());
420422 }
421423
422424 @ Test
@@ -440,9 +442,9 @@ void givenError400_noDetails_mustThrowMindeeHttpException()
440442 new Endpoint (InvoiceV4 .class ),
441443 parseParameter )
442444 );
443- assertEquals (400 , httpError .getStatusCode ());
444- assertEquals ("Some scary message here" , httpError .getMessage ());
445- assertEquals ("" , httpError .getDetails ());
446- assertEquals ("SomeCode" , httpError .getCode ());
445+ Assertions . assertEquals (400 , httpError .getStatusCode ());
446+ Assertions . assertEquals ("Some scary message here" , httpError .getMessage ());
447+ Assertions . assertEquals ("" , httpError .getDetails ());
448+ Assertions . assertEquals ("SomeCode" , httpError .getCode ());
447449 }
448450}
0 commit comments