File tree 2 files changed +8
-9
lines changed
main/java/com/aspose/barcode/cloud
test/java/com/aspose/barcode/cloud/test
2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -938,12 +938,13 @@ public void requestToken() throws ApiException {
938
938
.build ();
939
939
940
940
Response response = httpClient .newCall (request ).execute ();
941
+ String responseBody = response .body ().string ();
941
942
if (response .isSuccessful ()) {
942
943
GetAccessTokenResult result =
943
- json .deserialize (response . body (). string () , GetAccessTokenResult .class );
944
+ json .deserialize (responseBody , GetAccessTokenResult .class );
944
945
setAccessToken (result .access_token );
945
946
} else {
946
- throw new ApiException (response . body (). string () );
947
+ throw new ApiException (responseBody );
947
948
}
948
949
} catch (Exception ex ) {
949
950
throw new ApiException (ex );
Original file line number Diff line number Diff line change 1
1
package com .aspose .barcode .cloud .test ;
2
2
3
- import static org .junit .Assert .assertEquals ;
4
- import static org .junit .Assert .assertTrue ;
5
-
6
3
import com .aspose .barcode .cloud .ApiException ;
7
4
import com .aspose .barcode .cloud .api .GenerateApi ;
8
5
import com .aspose .barcode .cloud .model .EncodeBarcodeType ;
11
8
import org .junit .BeforeClass ;
12
9
import org .junit .Test ;
13
10
11
+ import static org .junit .Assert .*;
12
+
14
13
public class ExceptionTest extends TestBase {
15
14
16
15
private static GenerateApi api ;
@@ -24,12 +23,11 @@ public static void oneTimeSetUp() {
24
23
public void ExceptionMessageParsed () {
25
24
GenerateRequestWrapper request = new GenerateRequestWrapper (EncodeBarcodeType .QR , "" );
26
25
27
- boolean thrown = false ;
26
+ ApiException thrownE = null ;
28
27
try {
29
28
api .generate (request );
30
29
} catch (ApiException e ) {
31
- thrown = true ;
32
- System .err .println (e );
30
+ thrownE = e ;
33
31
assertEquals (400 , e .getHttpCode ());
34
32
assertEquals ("com.aspose.barcode.cloud.ApiException: Bad Request" , e .toString ());
35
33
assertEquals (
@@ -38,6 +36,6 @@ public void ExceptionMessageParsed() {
38
36
e .getDetails ().replace ("\r " , "" ));
39
37
}
40
38
41
- assertTrue ( thrown );
39
+ assertNotNull ( thrownE );
42
40
}
43
41
}
You can’t perform that action at this time.
0 commit comments