@@ -150,6 +150,46 @@ public void testCreateCallAndGetCallState() throws Exception {
150150 assertEquals ("Call ID not equal" , callId , callStateResponse .getResult ().getCallId ());
151151 }
152152
153+ @ Test
154+ public void testCreateCallWithAmdAndGetCallState () throws Exception {
155+ String accountId = System .getenv ("BW_ACCOUNT_ID" );
156+ String to = System .getenv ("USER_NUMBER" );
157+ String from = System .getenv ("BW_NUMBER" );
158+ String applicationId = System .getenv ("BW_VOICE_APPLICATION_ID" );
159+ String answerUrl = System .getenv ("BASE_CALLBACK_URL" ).concat ("/callbacks/outbound" );
160+ String machineDetectionUrl = System .getenv ("BASE_CALLBACK_URL" ).concat ("/callbacks/machineDetection" );
161+
162+ MachineDetectionRequest machineDetection = new MachineDetectionRequest ();
163+ machineDetection .setMode (ModeEnum .ASYNC );
164+ machineDetection .setCallbackUrl (machineDetectionUrl );
165+ machineDetection .setCallbackMethod (CallbackMethodEnum .POST );
166+ machineDetection .setDetectionTimeout (5.0 );
167+ machineDetection .setSilenceTimeout (5.0 );
168+ machineDetection .setSpeechThreshold (5.0 );
169+ machineDetection .setSpeechEndThreshold (5.0 );
170+ machineDetection .setDelayResult (Boolean .TRUE );
171+
172+ CreateCallRequest body = new CreateCallRequest ();
173+ body .setTo (to );
174+ body .setFrom (from );
175+ body .setApplicationId (applicationId );
176+ body .setAnswerUrl (answerUrl );
177+ body .setMachineDetection (machineDetection );
178+
179+ ApiResponse <CreateCallResponse > createCallResponse = voiceController .createCall (accountId , body );
180+ assertEquals ("Application ID for create call not equal" , applicationId , createCallResponse .getResult ().getApplicationId ());
181+ assertEquals ("To phone number for create call not equal" , to , createCallResponse .getResult ().getTo ());
182+ assertEquals ("From phone number for create call not equal" , from , createCallResponse .getResult ().getFrom ());
183+
184+ //get call state
185+ String callId = createCallResponse .getResult ().getCallId ();
186+ ApiResponse <CallState > callStateResponse = voiceController .getCall (accountId , callId );
187+ assertEquals ("Application ID for call state not equal" , applicationId , callStateResponse .getResult ().getApplicationId ());
188+ assertEquals ("To phone number for call state not equal" , to , callStateResponse .getResult ().getTo ());
189+ assertEquals ("From phone number for call state not equal" , from , callStateResponse .getResult ().getFrom ());
190+ assertEquals ("Call ID not equal" , callId , callStateResponse .getResult ().getCallId ());
191+ }
192+
153193 @ Test (expected = ApiErrorException .class )
154194 public void testCreateCallInvalidPhoneNumber () throws Exception {
155195 String accountId = System .getenv ("BW_ACCOUNT_ID" );
0 commit comments