1212 */
1313package com .ibm .watson .developer_cloud .assistant .v1 ;
1414
15- import com .google .gson .JsonObject ;
16- import com .google .gson .JsonParser ;
1715import com .ibm .watson .developer_cloud .WatsonServiceUnitTest ;
1816import com .ibm .watson .developer_cloud .assistant .v1 .model .Context ;
1917import com .ibm .watson .developer_cloud .assistant .v1 .model .CreateCounterexample ;
5452import static org .junit .Assert .assertArrayEquals ;
5553import static org .junit .Assert .assertEquals ;
5654import static org .junit .Assert .assertNotNull ;
57- import static org .junit .Assert .assertTrue ;
5855
5956/**
6057 * Unit tests for the {@link Assistant}.
@@ -131,18 +128,18 @@ public void testAssistantWithEmptyWorkspaceId() {
131128 */
132129 @ Test
133130 public void testSendMessage () throws IOException , InterruptedException {
134- String text = "I'd like to get insurance to for my home " ;
131+ String text = "I would love to hear some jazz music. " ;
135132
136133 MessageResponse mockResponse = loadFixture (FIXTURE , MessageResponse .class );
137134 server .enqueue (jsonResponse (mockResponse ));
138135
139136 InputData input = new InputData .Builder (text ).build ();
140137 RuntimeIntent intent = new RuntimeIntent ();
141- intent .setIntent ("turn_off " );
138+ intent .setIntent ("turn_on " );
142139 intent .setConfidence (0.0 );
143140 RuntimeEntity entity = new RuntimeEntity ();
144- entity .setEntity ("car " );
145- entity .setValue ("ford " );
141+ entity .setEntity ("genre " );
142+ entity .setValue ("jazz " );
146143 MessageOptions options = new MessageOptions .Builder (WORKSPACE_ID )
147144 .input (input )
148145 .addIntent (intent )
@@ -158,18 +155,16 @@ public void testSendMessage() throws IOException, InterruptedException {
158155
159156 String path = StringUtils .join (PATH_MESSAGE , "?" , VERSION , "=2018-02-16" );
160157 assertEquals (path , request .getPath ());
161- assertArrayEquals (new String [] { "Do you want to get a quote? " },
158+ assertArrayEquals (new String [] { "Great choice! Playing some jazz for you " },
162159 serviceResponse .getOutput ().getText ().toArray (new String [0 ]));
163160 assertEquals (request .getMethod (), "POST" );
164161 assertNotNull (request .getHeader (HttpHeaders .AUTHORIZATION ));
165- String expected = "{" + "\" input\" :{\" text\" :\" I'd like to get insurance to for my home\" },"
166- + "\" intents\" :[{\" confidence\" :0.0,\" intent\" :\" turn_off\" }],"
167- + "\" entities\" :[{\" value\" :\" ford\" ,\" entity\" :\" car\" }],"
168- + "\" alternate_intents\" :true" + "}" ;
169- JsonParser parser = new JsonParser ();
170- JsonObject expectedObj = parser .parse (expected ).getAsJsonObject ();
171- JsonObject actualObj = parser .parse (request .getBody ().readUtf8 ()).getAsJsonObject ();
172- assertTrue (expectedObj .equals (actualObj ));
162+ assertNotNull (serviceResponse .getOutput ().getLogMessages ());
163+ assertNotNull (serviceResponse .getOutput ().getNodesVisited ());
164+ assertNotNull (serviceResponse .getOutput ().getNodesVisitedDetails ());
165+ assertNotNull (serviceResponse .getOutput ().getNodesVisitedDetails ().get (0 ).getDialogNode ());
166+ assertNotNull (serviceResponse .getOutput ().getNodesVisitedDetails ().get (0 ).getTitle ());
167+ assertNotNull (serviceResponse .getOutput ().getNodesVisitedDetails ().get (0 ).getConditions ());
173168 assertEquals (serviceResponse , mockResponse );
174169 }
175170
@@ -202,13 +197,10 @@ public void testSendMessageWithAlternateIntents() throws IOException, Interrupte
202197
203198 String path = StringUtils .join (PATH_MESSAGE , "?" , VERSION , "=2018-02-16" );
204199 assertEquals (path , request .getPath ());
205- assertArrayEquals (new String [] { "Do you want to get a quote? " },
200+ assertArrayEquals (new String [] { "Great choice! Playing some jazz for you " },
206201 serviceResponse .getOutput ().getText ().toArray (new String [0 ]));
207202 assertEquals (request .getMethod (), "POST" );
208203 assertNotNull (request .getHeader (HttpHeaders .AUTHORIZATION ));
209- assertEquals (
210- "{\" input\" :{\" text\" :\" My text\" },\" alternate_intents\" :false," + "\" context\" :{\" name\" :\" Myname\" }}" ,
211- request .getBody ().readUtf8 ());
212204 assertEquals (serviceResponse , mockResponse );
213205 }
214206
0 commit comments