From e2f710ce460249eaac6c271269e7c20aee643438 Mon Sep 17 00:00:00 2001 From: Chris Liao Date: Wed, 7 Nov 2018 22:36:36 -0800 Subject: [PATCH] Add Card in ResponseBuilder --- .../amazon/ask/response/ResponseBuilder.java | 11 +++++++++++ .../ask/response/ResponseBuilderTest.java | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/ask-sdk-core/src/com/amazon/ask/response/ResponseBuilder.java b/ask-sdk-core/src/com/amazon/ask/response/ResponseBuilder.java index f88e0ae1..c1b300dc 100644 --- a/ask-sdk-core/src/com/amazon/ask/response/ResponseBuilder.java +++ b/ask-sdk-core/src/com/amazon/ask/response/ResponseBuilder.java @@ -85,6 +85,17 @@ public ResponseBuilder withSpeech(String speechText) { return this; } + /** + * Sets a {@link Card} object on the response. + * + * @param card card object + * @return response builder + */ + public ResponseBuilder withCard(Card card) { + this.card = card; + return this; + } + /** * Sets a simple {@link Card} on the response with the specified title and content. * diff --git a/ask-sdk-core/tst/com/amazon/ask/response/ResponseBuilderTest.java b/ask-sdk-core/tst/com/amazon/ask/response/ResponseBuilderTest.java index 20c4fb0a..f250459a 100644 --- a/ask-sdk-core/tst/com/amazon/ask/response/ResponseBuilderTest.java +++ b/ask-sdk-core/tst/com/amazon/ask/response/ResponseBuilderTest.java @@ -495,6 +495,23 @@ public void build_response_with_setters_standard_card() { assertEquals(responseWithBuilder.get(), response); } + @Test + public void build_response_with_card() { + SimpleCard simpleCard = SimpleCard.builder() + .withTitle("fooTitle") + .withContent("fooContent") + .build(); + + Response response = Response.builder() + .withCard(simpleCard) + .build(); + + Optional responseWithBuilder = builder + .withCard(simpleCard) + .build(); + assertEquals(responseWithBuilder.get(), response); + } + @Test public void build_response_with_link_account_card() { Response response = Response.builder()