|
3 | 3 | import com.github.freeclimbapi.enums.*; |
4 | 4 | import com.github.freeclimbapi.models.*; |
5 | 5 | import java.util.*; |
| 6 | +import org.json.JSONArray; |
| 7 | +import org.json.JSONObject; |
6 | 8 | import org.junit.Assert; |
7 | 9 | import org.junit.Test; |
8 | 10 |
|
9 | 11 | public class PerclScriptBuildTest { |
10 | 12 |
|
11 | 13 | private final PerclScript instance = new PerclScript(); |
12 | 14 |
|
13 | | - public String expectedPerclJson = |
14 | | - "[{\"Pause\":{}},{\"SendDigits\":{}},{\"Pause\":{}},{\"GetDigits\":{\"prompts\":[{\"Play\":" |
15 | | - + "{\"file\":\"https://123.com/press_any_key.wav\"}},{\"Pause\":{}},{\"Play\":{\"file\":\"https://123.com/press_any_key.wav\"}}" |
16 | | - + ",{\"Pause\":{}},{\"Play\":{\"file\":\"https://123.com/press_any_key.wav\"}},{\"Pause\":{}}]}}]"; |
| 15 | + JSONObject getPerclCommand(String command, JSONObject value) { |
| 16 | + JSONObject perclCommand = new JSONObject(); |
| 17 | + perclCommand.put(command, value); |
| 18 | + return perclCommand; |
| 19 | + } |
| 20 | + |
| 21 | + JSONArray createExpectedPercl() { |
| 22 | + JSONArray result = new JSONArray(); |
| 23 | + result.put(getPerclCommand("Pause", new JSONObject())); |
| 24 | + result.put(getPerclCommand("SendDigits", new JSONObject())); |
| 25 | + result.put(getPerclCommand("Pause", new JSONObject())); |
| 26 | + JSONObject getDigits = new JSONObject(); |
| 27 | + JSONArray getDigitPrompts = new JSONArray(); |
| 28 | + JSONObject playValue = new JSONObject(); |
| 29 | + playValue.put("file", "https://123.com/press_any_key.wav"); |
| 30 | + getDigitPrompts.put(getPerclCommand("Play", playValue)); |
| 31 | + getDigitPrompts.put(getPerclCommand("Pause", new JSONObject())); |
| 32 | + getDigitPrompts.put(getPerclCommand("Play", playValue)); |
| 33 | + getDigitPrompts.put(getPerclCommand("Pause", new JSONObject())); |
| 34 | + getDigitPrompts.put(getPerclCommand("Play", playValue)); |
| 35 | + getDigitPrompts.put(getPerclCommand("Pause", new JSONObject())); |
| 36 | + getDigits.put("prompts", getDigitPrompts); |
| 37 | + result.put(getPerclCommand("GetDigits", getDigits)); |
| 38 | + return result; |
| 39 | + } |
| 40 | + |
| 41 | + public JSONArray expectedPerclJsonArray = createExpectedPercl(); |
| 42 | + |
| 43 | + public String expectedPerclJson = expectedPerclJsonArray.toString(); |
17 | 44 |
|
18 | 45 | @Test |
19 | 46 | public void buildArrayListToJsonTest() throws Exception { |
20 | | - JSON jsonWriter = new JSON(); |
21 | 47 | Pause pause = new Pause(); |
22 | 48 | SendDigits sendDigits = new SendDigits(); |
23 | 49 | GetDigits digits = new GetDigits(); |
@@ -45,7 +71,6 @@ public void buildArrayListToJsonTest() throws Exception { |
45 | 71 |
|
46 | 72 | @Test |
47 | 73 | public void buildLinkedListToJsonTest() throws Exception { |
48 | | - JSON jsonWriter = new JSON(); |
49 | 74 | Pause pause = new Pause(); |
50 | 75 | SendDigits sendDigits = new SendDigits(); |
51 | 76 | GetDigits digits = new GetDigits(); |
|
0 commit comments