Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
rigatti committed Aug 31, 2018
1 parent 05a2a24 commit 8c0407b
Showing 1 changed file with 16 additions and 5 deletions.
Expand Up @@ -5,9 +5,7 @@
import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.*;

import static org.junit.Assert.*;

Expand Down Expand Up @@ -97,7 +95,7 @@ public void testShouldBuildAskResponseWithRichInput_BasicCard() throws Exception

ResponseMetadata metadata = ResponseMetadata.builder().build();

RootResponse rootResponse = ResponseBuilder.askResponseWithRichInput(Collections.singletonList(richInitialPromptItem));
RootResponse rootResponse = ResponseBuilder.askResponseWithRichInput(Collections.singletonList(richInitialPromptItem), metadata);

assertEquals(true, rootResponse.expectUserResponse);
assertNotNull(rootResponse.expectedInputs.get(0).inputPrompt.richInitialPrompt.items.get(0).basicCard.title);
Expand Down Expand Up @@ -139,12 +137,25 @@ public void testShouldBuildAskResponseWithRichInput_TextMessage_and_options() th
}

@Test
public void testShouldBuildTellResponse() throws Exception {
public void testShouldBuildTellResponse() {
String expectedSpeech = "expected_speech";
RootResponse rootResponse = ResponseBuilder.tellResponse(expectedSpeech);
assertEquals(expectedSpeech, rootResponse.finalResponse.speechResponse.textToSpeech);
}

@Test
public void testShouldBuildTellResponse_RichResponse_with_simpleresponse_and_metadata() throws Exception {
String expectedResponse = "expected";

Map<String, Object> specs = new HashMap<>();
specs.put("a key", "a value");
ResponseMetadata metadata = ResponseMetadata.builder().status(Status.builder().message("OK").build()).specs(specs).build();
RichInitialPromptItem richInitialPromptItem = RichInitialPromptItem.builder().simpleResponse(SpeechResponse.builder().displayText(expectedResponse).build()).build();
RootResponse rootResponse = ResponseBuilder.tellResponseWithRichInput(Collections.singletonList(richInitialPromptItem), metadata);

assertEquals(expectedResponse, rootResponse.finalResponse.richResponse.items.get(0).simpleResponse.displayText);
}

@Test
public void testShouldBuildAskResponse() throws Exception {
String expectedPrompt = "expected_prompt";
Expand Down

0 comments on commit 8c0407b

Please sign in to comment.