Skip to content

Commit a29afe9

Browse files
committed
test(Speech to Text): Update tests
1 parent a162667 commit a29afe9

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package com.ibm.watson.speech_to_text.v1;
1414

1515
import com.ibm.cloud.sdk.core.http.HttpMediaType;
16+
import com.ibm.cloud.sdk.core.security.BasicAuthenticator;
1617
import com.ibm.cloud.sdk.core.service.exception.NotFoundException;
1718
import com.ibm.watson.common.RetryRunner;
1819
import com.ibm.watson.common.WatsonServiceTest;
@@ -130,8 +131,8 @@ public void setUp() throws Exception {
130131

131132
Assume.assumeFalse("config.properties doesn't have valid credentials.", username == null);
132133

133-
service = new SpeechToText();
134-
service.setUsernameAndPassword(username, password);
134+
BasicAuthenticator authenticator = new BasicAuthenticator(username, password);
135+
service = new SpeechToText(authenticator);
135136
service.setEndPoint(getProperty("speech_to_text.url"));
136137
service.setDefaultHeaders(getDefaultHeaders());
137138
}
@@ -319,7 +320,7 @@ public void onError(Exception e) {
319320
@Override
320321
public void onTranscription(SpeechRecognitionResults speechResults) {
321322
if (speechResults != null) {
322-
if (speechResults.getResults() != null && speechResults.getResults().get(0).isFinalResults()) {
323+
if (speechResults.getResults() != null && speechResults.getResults().get(0).isXfinal()) {
323324
asyncTranscriptionResults = speechResults;
324325
}
325326
if (speechResults.getAudioMetrics() != null) {

speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import com.google.gson.JsonObject;
1717
import com.google.gson.JsonParser;
1818
import com.ibm.cloud.sdk.core.http.HttpMediaType;
19-
import com.ibm.cloud.sdk.core.security.basicauth.BasicAuthConfig;
19+
import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator;
2020
import com.ibm.cloud.sdk.core.util.GsonSingleton;
2121
import com.ibm.cloud.sdk.core.util.RequestUtils;
2222
import com.ibm.watson.common.TestUtils;
@@ -169,11 +169,7 @@ public class SpeechToTextTest extends WatsonServiceUnitTest {
169169
public void setUp() throws Exception {
170170
super.setUp();
171171

172-
BasicAuthConfig authConfig = new BasicAuthConfig.Builder()
173-
.username("")
174-
.password("")
175-
.build();
176-
service = new SpeechToText(authConfig);
172+
service = new SpeechToText(new NoAuthAuthenticator());
177173
service.setEndPoint(getMockWebServerUrl());
178174

179175
speechModel = loadFixture("src/test/resources/speech_to_text/speech-model.json", SpeechModel.class);
@@ -1119,10 +1115,11 @@ public void testAddWords() throws InterruptedException, FileNotFoundException {
11191115
wordsAsMap.put("words", new Word[] { newWord });
11201116
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}"));
11211117

1122-
CustomWord word = new CustomWord();
1123-
word.setWord(newWord.getWord());
1124-
word.setDisplayAs(newWord.getDisplayAs());
1125-
word.setSoundsLike(newWord.getSoundsLike());
1118+
CustomWord word = new CustomWord.Builder()
1119+
.word(newWord.getWord())
1120+
.displayAs(newWord.getDisplayAs())
1121+
.soundsLike(newWord.getSoundsLike())
1122+
.build();
11261123

11271124
AddWordsOptions addOptions = new AddWordsOptions.Builder()
11281125
.customizationId(id)
@@ -1489,8 +1486,8 @@ public void testClosingInputStreamClosesWebSocket() throws Exception {
14891486
outputStream.write(ByteString.encodeUtf8("test").toByteArray());
14901487
outputStream.close();
14911488

1492-
webSocketRecorder.assertTextMessage("{\"customization_weight\":0.1,"
1493-
+ "\"content-type\":\"audio/l16; rate=44000\",\"action\":\"start\"}");
1489+
webSocketRecorder.assertTextMessage("{\"content-type\":\"audio/l16; rate=44000\"," +
1490+
"\"customization_weight\":0.1,\"action\":\"start\"}");
14941491
webSocketRecorder.assertBinaryMessage(ByteString.encodeUtf8("test"));
14951492
webSocketRecorder.assertTextMessage("{\"action\":\"stop\"}");
14961493
webSocketRecorder.assertExhausted();

0 commit comments

Comments
 (0)