Skip to content

Commit

Permalink
SWI-4236 Adding Tests for ContentType
Browse files Browse the repository at this point in the history
  • Loading branch information
brianluisgomez committed Feb 13, 2024
1 parent 6378d09 commit ae60bf0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/bandwidth/sdk/api/MediaApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
Expand Down
7 changes: 6 additions & 1 deletion src/test/java/com/bandwidth/sdk/api/MediaApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

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.*;

@TestMethodOrder(OrderAnnotation.class)
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";
Expand All @@ -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<Void> response = api.uploadMediaWithHttpInfo(BW_ACCOUNT_ID, mediaId, media,
contentType,
cacheControl);

assertThat(response.getStatusCode(), is(204));
assertThat(call.request().toString(), containsString(contentType));
}

@Test
Expand Down

0 comments on commit ae60bf0

Please sign in to comment.