Skip to content

Commit bdd995d

Browse files
committed
Don't print on success in ExceptionMessageParsed tests
1 parent 64604c5 commit bdd995d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/main/java/com/aspose/barcode/cloud/ApiClient.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -938,12 +938,13 @@ public void requestToken() throws ApiException {
938938
.build();
939939

940940
Response response = httpClient.newCall(request).execute();
941+
String responseBody = response.body().string();
941942
if (response.isSuccessful()) {
942943
GetAccessTokenResult result =
943-
json.deserialize(response.body().string(), GetAccessTokenResult.class);
944+
json.deserialize(responseBody, GetAccessTokenResult.class);
944945
setAccessToken(result.access_token);
945946
} else {
946-
throw new ApiException(response.body().string());
947+
throw new ApiException(responseBody);
947948
}
948949
} catch (Exception ex) {
949950
throw new ApiException(ex);

src/test/java/com/aspose/barcode/cloud/test/ExceptionTest.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.aspose.barcode.cloud.test;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertTrue;
5-
63
import com.aspose.barcode.cloud.ApiException;
74
import com.aspose.barcode.cloud.api.GenerateApi;
85
import com.aspose.barcode.cloud.model.EncodeBarcodeType;
@@ -11,6 +8,8 @@
118
import org.junit.BeforeClass;
129
import org.junit.Test;
1310

11+
import static org.junit.Assert.*;
12+
1413
public class ExceptionTest extends TestBase {
1514

1615
private static GenerateApi api;
@@ -24,12 +23,11 @@ public static void oneTimeSetUp() {
2423
public void ExceptionMessageParsed() {
2524
GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "");
2625

27-
boolean thrown = false;
26+
ApiException thrownE = null;
2827
try {
2928
api.generate(request);
3029
} catch (ApiException e) {
31-
thrown = true;
32-
System.err.println(e);
30+
thrownE = e;
3331
assertEquals(400, e.getHttpCode());
3432
assertEquals("com.aspose.barcode.cloud.ApiException: Bad Request", e.toString());
3533
assertEquals(
@@ -38,6 +36,6 @@ public void ExceptionMessageParsed() {
3836
e.getDetails().replace("\r", ""));
3937
}
4038

41-
assertTrue(thrown);
39+
assertNotNull(thrownE);
4240
}
4341
}

0 commit comments

Comments
 (0)