Skip to content

Commit a9d689d

Browse files
committed
Add voice machine detection configuration constructor and serialization test
1 parent 6bfd61a commit a9d689d

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.bandwidth;
2+
3+
import com.bandwidth.voice.models.CallbackMethodEnum;
4+
import com.bandwidth.voice.models.FallbackMethodEnum;
5+
import com.bandwidth.voice.models.MachineDetectionConfiguration;
6+
import com.bandwidth.voice.models.ModeEnum;
7+
import com.fasterxml.jackson.core.JsonProcessingException;
8+
import org.junit.*;
9+
10+
import static org.junit.Assert.assertEquals;
11+
import static org.junit.Assert.assertFalse;
12+
13+
public class VoiceMachineDetectionConfigurationTest {
14+
15+
@Test
16+
public void testMachineDetectionConfigurationConstructor() {
17+
MachineDetectionConfiguration machineDetectionConfiguration = new MachineDetectionConfiguration(ModeEnum.ASYNC,
18+
3.2, 5.6, 1.2, 7.6, false,
19+
"https://www.example.com/", CallbackMethodEnum.GET,
20+
"https://www.example-fallback.com/", FallbackMethodEnum.GET,
21+
"neato-username", "neato-password",
22+
"neato-username-fallback", "neato-password-fallback");
23+
24+
assertEquals(ModeEnum.ASYNC, machineDetectionConfiguration.getMode());
25+
assertEquals(Double.valueOf(3.2), machineDetectionConfiguration.getDetectionTimeout());
26+
assertEquals(Double.valueOf(5.6), machineDetectionConfiguration.getSilenceTimeout());
27+
assertEquals(Double.valueOf(1.2), machineDetectionConfiguration.getSpeechThreshold());
28+
assertEquals(Double.valueOf(7.6), machineDetectionConfiguration.getSpeechEndThreshold());
29+
assertFalse(machineDetectionConfiguration.getDelayResult());
30+
assertEquals("https://www.example.com/", machineDetectionConfiguration.getCallbackUrl());
31+
assertEquals(CallbackMethodEnum.GET, machineDetectionConfiguration.getCallbackMethod());
32+
assertEquals("https://www.example-fallback.com/", machineDetectionConfiguration.getFallbackUrl());
33+
assertEquals(FallbackMethodEnum.GET, machineDetectionConfiguration.getFallbackMethod());
34+
assertEquals("neato-username", machineDetectionConfiguration.getUsername());
35+
assertEquals("neato-password", machineDetectionConfiguration.getPassword());
36+
assertEquals("neato-username-fallback", machineDetectionConfiguration.getFallbackUsername());
37+
assertEquals("neato-password-fallback", machineDetectionConfiguration.getFallbackPassword());
38+
}
39+
40+
@Test
41+
public void testMachineDetectionConfigurationSerialize() throws JsonProcessingException {
42+
MachineDetectionConfiguration machineDetectionConfiguration = new MachineDetectionConfiguration(ModeEnum.ASYNC,
43+
3.2, 5.6, 1.2, 7.6, false,
44+
"https://www.example.com/", CallbackMethodEnum.GET,
45+
"https://www.example-fallback.com/", FallbackMethodEnum.GET,
46+
"neato-username", "neato-password",
47+
"neato-username-fallback", "neato-password-fallback");
48+
49+
String json = ApiHelper.serialize(machineDetectionConfiguration);
50+
assertEquals("{\"mode\":\"async\",\"detectionTimeout\":3.2,\"silenceTimeout\":5.6,\"speechThreshold\":1.2,\"speechEndThreshold\":7.6,\"delayResult\":false,\"callbackUrl\":\"https://www.example.com/\",\"callbackMethod\":\"GET\",\"fallbackUrl\":\"https://www.example-fallback.com/\",\"fallbackMethod\":\"GET\",\"username\":\"neato-username\",\"password\":\"neato-password\",\"fallbackUsername\":\"neato-username-fallback\",\"fallbackPassword\":\"neato-password-fallback\"}", json);
51+
}
52+
}

0 commit comments

Comments
 (0)