Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
brianluisgomez committed May 20, 2024
1 parent 7abf739 commit 8cdcd55
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 66 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.bandwidth.sdk</groupId>
<artifactId>bandwidth-sdk</artifactId>
<version>9.1.4</version>
<version>9.1.5</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -56,7 +56,7 @@ Add this dependency to your project's build file:
}
dependencies {
implementation "com.bandwidth.sdk:bandwidth-sdk:9.1.4"
implementation "com.bandwidth.sdk:bandwidth-sdk:9.1.5"
}
```

Expand All @@ -70,7 +70,7 @@ mvn clean package

Then manually install the following JARs:

* `target/bandwidth-sdk-9.1.4.jar`
* `target/bandwidth-sdk-9.1.5.jar`
* `target/lib/*.jar`

## Getting Started
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'java'
apply plugin: 'com.diffplug.spotless'

group = 'com.bandwidth.sdk'
version = '9.1.4'
version = '9.1.5'

buildscript {
repositories {
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lazy val root = (project in file(".")).
settings(
organization := "com.bandwidth.sdk",
name := "bandwidth-sdk",
version := "9.1.4",
version := "9.1.5",
scalaVersion := "2.11.4",
scalacOptions ++= Seq("-feature"),
javacOptions in compile ++= Seq("-Xlint:deprecation"),
Expand Down
2 changes: 1 addition & 1 deletion openapi-config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
artifactId: bandwidth-sdk
artifactVersion: 9.1.4
artifactVersion: 9.1.5
artifactDescription: The official client SDK for Bandwidth's Voice, Messaging, MFA, and WebRTC APIs
artifactUrl: https://github.com/Bandwidth/java-sdk
developerEmail: [email protected]
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>bandwidth-sdk</artifactId>
<packaging>jar</packaging>
<name>bandwidth-sdk</name>
<version>9.1.4</version>
<version>9.1.5</version>
<url>https://github.com/Bandwidth/java-sdk</url>
<description>The official client SDK for Bandwidth's Voice, Messaging, MFA, and WebRTC APIs</description>
<scm>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/bandwidth/sdk/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void init() {
json = new JSON();

// Set default User-Agent.
setUserAgent("OpenAPI-Generator/9.1.4/java");
setUserAgent("OpenAPI-Generator/9.1.5/java");

authentications = new HashMap<String, Authentication>();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/bandwidth/sdk/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class Configuration {
public static final String VERSION = "9.1.4";
public static final String VERSION = "9.1.5";

private static ApiClient defaultApiClient = new ApiClient();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/bandwidth/sdk/api/MediaApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ public okhttp3.Call uploadMediaCall(String accountId, String mediaId, File body,
}

@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
16 changes: 8 additions & 8 deletions src/test/java/com/bandwidth/sdk/api/RecordingsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.bandwidth.sdk.model.CreateCallResponse;
import com.bandwidth.sdk.model.RecordingStateEnum;
import com.bandwidth.sdk.model.TranscribeRecording;
import com.bandwidth.sdk.model.TranscriptionList;
import com.bandwidth.sdk.model.RecordingTranscriptions;
import com.bandwidth.sdk.model.UpdateCall;
import com.bandwidth.sdk.model.UpdateCallRecording;
import com.bandwidth.sdk.utils.MantecaStatusResponse;
Expand Down Expand Up @@ -205,12 +205,12 @@ public void testCallRecordingAndTranscription() throws Exception {
assertThat(transcriptionStatus, is(true));

// Validate the transcription metadata endpoint
ApiResponse<TranscriptionList> listTranscriptionsResponse = recordingsApi
.getCallTranscriptionWithHttpInfo(BW_ACCOUNT_ID, callId, recordingId);
ApiResponse<RecordingTranscriptions> listTranscriptionsResponse = recordingsApi
.getRecordingTranscriptionWithHttpInfo(BW_ACCOUNT_ID, callId, recordingId);
assertThat(listTranscriptionsResponse.getStatusCode(), is(200));

// Delete transcription
ApiResponse<Void> deleteTranscriptionResponse = recordingsApi.deleteCallTranscriptionWithHttpInfo(BW_ACCOUNT_ID,
ApiResponse<Void> deleteTranscriptionResponse = recordingsApi.deleteRecordingTranscriptionWithHttpInfo(BW_ACCOUNT_ID,
callId, recordingId);
assertThat(deleteTranscriptionResponse.getStatusCode(), is(204));

Expand Down Expand Up @@ -368,7 +368,7 @@ public void testUnauthorizedGetTranscription() {
Basic.setPassword("bad_password");

ApiException exception = Assertions.assertThrows(ApiException.class,
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId,
() -> recordingsApi.deleteRecordingTranscription(BW_ACCOUNT_ID, callId,
recordingId));

assertThat(exception.getCode(), is(401));
Expand All @@ -380,7 +380,7 @@ public void testForbiddenGetTranscription() {
Basic.setPassword(FORBIDDEN_PASSWORD);

ApiException exception = Assertions.assertThrows(ApiException.class,
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId,
() -> recordingsApi.deleteRecordingTranscription(BW_ACCOUNT_ID, callId,
recordingId));

assertThat(exception.getCode(), is(403));
Expand Down Expand Up @@ -416,7 +416,7 @@ public void testUnauthorizedDeleteTranscription() throws ApiException {
Basic.setPassword("bad_password");

ApiException exception = Assertions.assertThrows(ApiException.class,
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId,
() -> recordingsApi.deleteRecordingTranscription(BW_ACCOUNT_ID, callId,
recordingId));

assertThat(exception.getCode(), is(401));
Expand All @@ -428,7 +428,7 @@ public void testForbiddenDeleteTranscription() {
Basic.setPassword(FORBIDDEN_PASSWORD);

ApiException exception = Assertions.assertThrows(ApiException.class,
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId,
() -> recordingsApi.deleteRecordingTranscription(BW_ACCOUNT_ID, callId,
recordingId));

assertThat(exception.getCode(), is(403));
Expand Down
139 changes: 91 additions & 48 deletions src/test/java/com/bandwidth/sdk/api/TranscriptionsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,74 +10,117 @@
* Do not edit the class manually.
*/


package com.bandwidth.sdk.api;

import com.bandwidth.sdk.ApiResponse;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.auth.HttpBasicAuth;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.model.CallbackMethodEnum;
import com.bandwidth.sdk.model.CreateCall;
import com.bandwidth.sdk.model.CreateCallResponse;
import com.bandwidth.sdk.model.CallDirectionEnum;
import com.bandwidth.sdk.model.CallState;
import com.bandwidth.sdk.model.CallStateEnum;
import com.bandwidth.sdk.model.UpdateCall;
import com.bandwidth.sdk.model.CallTranscriptionMetadata;
import com.bandwidth.sdk.model.CallTranscriptionResponse;
import com.bandwidth.sdk.model.VoiceApiError;
import org.junit.jupiter.api.Disabled;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.Assertions;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.time.OffsetDateTime;
import java.util.concurrent.TimeUnit;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.beans.HasPropertyWithValue.hasProperty;

import static com.bandwidth.sdk.utils.TestingEnvironmentVariables.*;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)


/**
* API tests for TranscriptionsApi
*/
@Disabled
public class TranscriptionsApiTest {

private final TranscriptionsApi api = new TranscriptionsApi();
ApiClient defaultClient = Configuration.getDefaultApiClient();
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
private final CallsApi callsApi = new CallsApi(defaultClient);
private final TranscriptionsApi transcriptionsApi = new TranscriptionsApi(defaultClient);

/**
* Delete a specific transcription
*
* Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a &#x60;204&#x60; is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
*
* @throws ApiException if the Api call fails
*/
@Test
public void deleteRealTimeTranscriptionTest() throws ApiException {
String accountId = null;
String callId = null;
String transcriptionId = null;
api.deleteRealTimeTranscription(accountId, callId, transcriptionId);
// TODO: test validations
}

/**
* Retrieve a specific transcription
*
* Retrieve the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription).
*
* @throws ApiException if the Api call fails
*/
@Test
public void getRealTimeTranscriptionTest() throws ApiException {
String accountId = null;
String callId = null;
String transcriptionId = null;
CallTranscriptionResponse response = api.getRealTimeTranscription(accountId, callId, transcriptionId);
// TODO: test validations
}
private static CreateCall createMantecaCallBody = new CreateCall();
private static UpdateCall completeMantecaCallBody = new UpdateCall();
private static URI mantecaAnswerUrl;
private static String bxmlBody = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Bxml><SpeakSentence locale=\"en_US\" gender=\"female\" voice=\"susan\">This is a bxml start transcription test.</SpeakSentence><StartTranscription tracks=\"both\"></StartTranscription><SpeakSentence voice=\"bridget\">Ideally this part is being transcribed.</SpeakSentence><Pause duration=\"3\"/></Response></Bxml>";
private static int TEST_SLEEP = 6;


/**
* Enumerate transcriptions made with StartTranscription
*
* Enumerates the transcriptions created on this call via [startTranscription](/docs/voice/bxml/startTranscription).
*
* @throws ApiException if the Api call fails
*/
@Test
public void listRealTimeTranscriptionsTest() throws ApiException {
String accountId = null;
String callId = null;
List<CallTranscriptionMetadata> response = api.listRealTimeTranscriptions(accountId, callId);
// TODO: test validations
}
public void getAndDeleteRealTimeTranscriptionsTest() throws ApiException, InterruptedException, URISyntaxException {
Basic.setUsername(BW_USERNAME);
Basic.setPassword(BW_PASSWORD);
mantecaAnswerUrl = new URI(MANTECA_BASE_URL + "/bxml/pause");

createMantecaCallBody.setFrom(MANTECA_ACTIVE_NUMBER);
createMantecaCallBody.setTo(MANTECA_IDLE_NUMBER);
createMantecaCallBody.setApplicationId(MANTECA_APPLICATION_ID);
createMantecaCallBody.setAnswerUrl(mantecaAnswerUrl);
completeMantecaCallBody.setState(CallStateEnum.COMPLETED);


// Create call
TimeUnit.SECONDS.sleep(TEST_SLEEP);
ApiResponse<CreateCallResponse> createCallResponse = callsApi.createCallWithHttpInfo(BW_ACCOUNT_ID,
createMantecaCallBody);

assertThat(createCallResponse.getStatusCode(), is(201));

// Redirect call to different url
TimeUnit.SECONDS.sleep(TEST_SLEEP);
ApiResponse<Void> updateCallResponse = callsApi.updateCallBxmlWithHttpInfo(BW_ACCOUNT_ID,
createCallResponse.getData().getCallId(), bxmlBody);

assertThat(updateCallResponse.getStatusCode(), is(204));

// Complete call
TimeUnit.SECONDS.sleep(TEST_SLEEP);
ApiResponse<Void> completeCallResponse = callsApi.updateCallWithHttpInfo(BW_ACCOUNT_ID,
createCallResponse.getData().getCallId(), completeMantecaCallBody);

assertThat(completeCallResponse.getStatusCode(), is(200));


ApiResponse<List<CallTranscriptionMetadata>> listRealTimeTranscriptionResponse = transcriptionsApi.listRealTimeTranscriptionsWithHttpInfo(BW_ACCOUNT_ID, createCallResponse.getData().getCallId());

String transcriptionId = listRealTimeTranscriptionResponse.getData().get(0).getTranscriptionId();
TimeUnit.SECONDS.sleep(TEST_SLEEP);

ApiResponse<CallTranscriptionResponse> getRealTimeTranscriptionResponse = transcriptionsApi.getRealTimeTranscriptionWithHttpInfo(BW_ACCOUNT_ID, createCallResponse.getData().getCallId(), transcriptionId);

assertThat(getRealTimeTranscriptionResponse.getStatusCode(), is(200));


ApiResponse<Void> deleteRealTimeTranscriptionResponse = transcriptionsApi.deleteRealTimeTranscriptionWithHttpInfo(BW_ACCOUNT_ID, createCallResponse.getData().getCallId(), transcriptionId);

assertThat(deleteRealTimeTranscriptionResponse.getStatusCode(), is(204));

}
}


0 comments on commit 8cdcd55

Please sign in to comment.