From 4821b2ffed4b506f6f6ea53a05ddb3878853c8b3 Mon Sep 17 00:00:00 2001 From: Martin Lopez Date: Mon, 13 Nov 2023 17:24:27 -0300 Subject: [PATCH] fix(demo): use builder instead of constructor Closes #5 --- .../chatassistant/ChatAssistantDemo.java | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/src/test/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistantDemo.java b/src/test/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistantDemo.java index 9107955..712ef39 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistantDemo.java +++ b/src/test/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistantDemo.java @@ -19,9 +19,6 @@ */ package com.flowingcode.vaadin.addons.chatassistant; -import com.flowingcode.vaadin.addons.chatassistant.ChatAssistant; -import com.flowingcode.vaadin.addons.chatassistant.Message; -import com.flowingcode.vaadin.addons.chatassistant.Sender; import com.flowingcode.vaadin.addons.demo.DemoSource; import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.dependency.CssImport; @@ -45,27 +42,15 @@ public ChatAssistantDemo() { message.setSizeFull(); Button chat = new Button("Chat"); - chat.addClickListener( - ev -> { - Message m = - new Message( - message.getValue(), - false, - false, - 0, - false, - new Sender("Assistant", "1", "chatbot.png")); - chatAssistant.sendMessage(m); - message.clear(); - }); - chatAssistant.sendMessage( - new Message( - "Hello, I am here to assist you", - false, - false, - 0, - false, - new Sender("Assistant", "1", "chatbot.png"))); + chat.addClickListener(ev -> { + Message m = Message.builder().content(message.getValue()) + .sender(Sender.builder().name("Assistant").id("1").avatar("chatbot.png").build()).build(); + + chatAssistant.sendMessage(m); + message.clear(); + }); + chatAssistant.sendMessage(Message.builder().content("Hello, I am here to assist you") + .sender(Sender.builder().name("Assistant").id("1").avatar("chatbot.png").build()).build()); chatAssistant.toggle(); chatAssistant.addChatSentListener( ev -> {