From 687954f799527d0f8986e7769928706c0e787630 Mon Sep 17 00:00:00 2001 From: Mark Struchkov Date: Mon, 14 Jan 2019 15:27:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=BA=D0=BE=D1=81=D0=BC=D0=B5=D1=82=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D1=81=D0=BA=D0=B8=D0=B5=20=D1=83=D0=BB=D1=83=D1=87=D1=88?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Немного изменил логику работы метода, который вставляет параметры в текст ответа --- .../java/org/sadtech/autoresponder/Autoresponder.java | 9 ++++----- .../org/sadtech/autoresponder/AutoresponderTest.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/sadtech/autoresponder/Autoresponder.java b/src/main/java/org/sadtech/autoresponder/Autoresponder.java index d895efe..d30ea01 100644 --- a/src/main/java/org/sadtech/autoresponder/Autoresponder.java +++ b/src/main/java/org/sadtech/autoresponder/Autoresponder.java @@ -17,7 +17,7 @@ public class Autoresponder { private PersonService personService; public String answer(@NotNull Integer idPerson, @NotNull String message) { - Person person = addPerson(idPerson); + Person person = CheckAndAddPerson(idPerson); Unit unit; if (person.getUnit() == null) { unit = unitService.nextUnit(unitService.menuUnit(), message); @@ -29,15 +29,14 @@ public class Autoresponder { } public String answer(@NotNull Integer idPerson, @NotNull String message, @NotNull List words) { - Person person = addPerson(idPerson); - Unit unit = unitService.nextUnit(person.getUnit(), message); + String answer = answer(idPerson, message); InsertWords insertWords = new InsertWords(); - insertWords.setInText(unit.getAnswer()); + insertWords.setInText(answer); insertWords.insert(words); return insertWords.getOutText(); } - private Person addPerson(Integer idPerson) { + private Person CheckAndAddPerson(Integer idPerson) { Person person; if (personService.checkPerson(idPerson)) { person = personService.getPersonById(idPerson); diff --git a/src/test/java/org/sadtech/autoresponder/AutoresponderTest.java b/src/test/java/org/sadtech/autoresponder/AutoresponderTest.java index 63c2ad4..81ec996 100644 --- a/src/test/java/org/sadtech/autoresponder/AutoresponderTest.java +++ b/src/test/java/org/sadtech/autoresponder/AutoresponderTest.java @@ -85,6 +85,7 @@ public class AutoresponderTest { @Test public void NoAnswer() { + person.setUnit(null); String test = autoresponder.answer(person.getId(), "Привет это срабатывания"); Assert.assertNull(test); } @@ -125,6 +126,5 @@ public class AutoresponderTest { public void answerNoPerson() { Assert.assertEquals(autoresponder.answer(100, "Привет это тест срабатывания"), "Здравствуйте, вы написали в нашу компанию!"); Assert.assertEquals(autoresponder.answer(100, "Привет это тест срабатывания"), "Ответ с {0} параметрами!"); - } } \ No newline at end of file