From ae60bf042e069263be53d7e044d1c4f8c2eec0a3 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 12 Feb 2024 23:45:03 -0500 Subject: [PATCH] SWI-4236 Adding Tests for ContentType --- src/main/java/com/bandwidth/sdk/api/MediaApi.java | 4 ++-- src/test/java/com/bandwidth/sdk/api/MediaApiTest.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/bandwidth/sdk/api/MediaApi.java b/src/main/java/com/bandwidth/sdk/api/MediaApi.java index 77a60cb3..b8eda7e9 100644 --- a/src/main/java/com/bandwidth/sdk/api/MediaApi.java +++ b/src/main/java/com/bandwidth/sdk/api/MediaApi.java @@ -682,14 +682,14 @@ public okhttp3.Call uploadMediaCall(String accountId, String mediaId, File body, if (localVarContentType != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } - } + }; String[] localVarAuthNames = new String[] { "Basic" }; return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call uploadMediaValidateBeforeCall(String accountId, String mediaId, File body, String contentType, String cacheControl, final ApiCallback _callback) throws ApiException { + public okhttp3.Call uploadMediaValidateBeforeCall(String accountId, String mediaId, File body, String contentType, String cacheControl, final ApiCallback _callback) throws ApiException { // verify the required parameter 'accountId' is set if (accountId == null) { throw new ApiException("Missing the required parameter 'accountId' when calling uploadMedia(Async)"); diff --git a/src/test/java/com/bandwidth/sdk/api/MediaApiTest.java b/src/test/java/com/bandwidth/sdk/api/MediaApiTest.java index 8ea77da5..2852fa00 100644 --- a/src/test/java/com/bandwidth/sdk/api/MediaApiTest.java +++ b/src/test/java/com/bandwidth/sdk/api/MediaApiTest.java @@ -20,6 +20,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.containsString; import static com.bandwidth.sdk.utils.TestingEnvironmentVariables.*; @@ -27,7 +28,7 @@ public class MediaApiTest { ApiClient defaultClient = Configuration.getDefaultApiClient(); HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic"); - private final MediaApi api = new MediaApi(defaultClient.setDebugging(true)); + private final MediaApi api = new MediaApi(defaultClient); private static String mediaPath = "src/test/java/com/bandwidth/sdk/fixtures/"; private static String mediaFile = "java_cat.jpeg"; @@ -49,11 +50,15 @@ public void uploadMedia() throws ApiException { Basic.setUsername(BW_USERNAME); Basic.setPassword(BW_PASSWORD); + + + okhttp3.Call call = api.uploadMediaValidateBeforeCall(BW_ACCOUNT_ID, mediaId, media, contentType, cacheControl, null); ApiResponse response = api.uploadMediaWithHttpInfo(BW_ACCOUNT_ID, mediaId, media, contentType, cacheControl); assertThat(response.getStatusCode(), is(204)); + assertThat(call.request().toString(), containsString(contentType)); } @Test