diff --git a/pom.xml b/pom.xml
index 3a0ef96..a27ee2b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.sadtech.autoresponder
autoresponder
- 1.3.1-RELEASE
+ 1.4.0-SNAPSHOT
jar
diff --git a/src/main/java/org/sadtech/autoresponder/Autoresponder.java b/src/main/java/org/sadtech/autoresponder/Autoresponder.java
index 180567d..c823ded 100644
--- a/src/main/java/org/sadtech/autoresponder/Autoresponder.java
+++ b/src/main/java/org/sadtech/autoresponder/Autoresponder.java
@@ -5,10 +5,11 @@ import org.sadtech.autoresponder.entity.Person;
import org.sadtech.autoresponder.entity.Unit;
import org.sadtech.autoresponder.entity.compare.UnitPriorityComparator;
import org.sadtech.autoresponder.service.PersonService;
-import org.sadtech.autoresponder.service.UnitService;
import org.sadtech.autoresponder.submodule.parser.Parser;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -16,9 +17,17 @@ public class Autoresponder {
public static final Logger log = Logger.getLogger(Autoresponder.class);
- private UnitService unitService;
+ private Set menuUnits;
private PersonService personService;
+ public Autoresponder(PersonService personService) {
+ this.personService = personService;
+ }
+
+ public void setMenuUnits(Set menuUnits) {
+ this.menuUnits = menuUnits;
+ }
+
public PersonService getPersonService() {
return personService;
}
@@ -27,19 +36,14 @@ public class Autoresponder {
this.personService = personService;
}
- public Autoresponder(UnitService unitService, PersonService personService) {
- this.unitService = unitService;
- this.personService = personService;
- }
-
public Unit answer(Integer idPerson, String message) {
Person person = checkAndAddPerson(idPerson);
Unit unit;
if (person.getUnit() == null) {
- unit = nextUnit(unitService.menuUnit(), message);
+ unit = nextUnit(menuUnits, message);
} else {
if (person.getUnit().getNextUnits() == null) {
- unit = nextUnit(unitService.menuUnit(), message);
+ unit = nextUnit(menuUnits, message);
} else {
unit = nextUnit(person.getUnit().getNextUnits(), message);
}
diff --git a/src/main/java/org/sadtech/autoresponder/repository/UnitRepository.java b/src/main/java/org/sadtech/autoresponder/repository/UnitRepository.java
deleted file mode 100644
index 380bd34..0000000
--- a/src/main/java/org/sadtech/autoresponder/repository/UnitRepository.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.sadtech.autoresponder.repository;
-
-import org.sadtech.autoresponder.entity.Unit;
-
-import java.util.List;
-import java.util.Set;
-
-public interface UnitRepository {
-
- void addUnit(Unit unit);
-
- void addUnits(List units);
-
- Set menuUnits();
-
-}
diff --git a/src/main/java/org/sadtech/autoresponder/service/UnitService.java b/src/main/java/org/sadtech/autoresponder/service/UnitService.java
index 903fe99..6d24d62 100644
--- a/src/main/java/org/sadtech/autoresponder/service/UnitService.java
+++ b/src/main/java/org/sadtech/autoresponder/service/UnitService.java
@@ -1,13 +1,13 @@
-package org.sadtech.autoresponder.service;
-
-import org.sadtech.autoresponder.entity.Unit;
-
-import java.util.Set;
-
-public interface UnitService {
-
- Set menuUnit();
-
- void addUnit(Unit unit);
-
-}
+//package org.sadtech.autoresponder.service;
+//
+//import org.sadtech.autoresponder.entity.Unit;
+//
+//import java.util.Set;
+//
+//public interface UnitService {
+//
+// Set menuUnit();
+//
+// void addUnit(Unit unit);
+//
+//}
diff --git a/src/main/java/org/sadtech/autoresponder/service/impl/UnitServiceImpl.java b/src/main/java/org/sadtech/autoresponder/service/impl/UnitServiceImpl.java
deleted file mode 100644
index 499e5db..0000000
--- a/src/main/java/org/sadtech/autoresponder/service/impl/UnitServiceImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.sadtech.autoresponder.service.impl;
-
-import org.apache.log4j.Logger;
-import org.sadtech.autoresponder.entity.Unit;
-import org.sadtech.autoresponder.repository.UnitRepository;
-import org.sadtech.autoresponder.service.UnitService;
-
-import java.util.Set;
-
-public class UnitServiceImpl implements UnitService {
-
- private static final Logger log = Logger.getLogger(UnitServiceImpl.class);
-
- private UnitRepository unitRepository;
-
- public UnitServiceImpl(UnitRepository unitRepository) {
- this.unitRepository = unitRepository;
- }
-
- @Override
- public Set menuUnit() {
- return unitRepository.menuUnits();
- }
-
- @Override
- public void addUnit(Unit unit) {
- unitRepository.addUnit(unit);
- }
-
-}
-
diff --git a/src/test/java/org/sadtech/autoresponder/AutoresponderTest.java b/src/test/java/org/sadtech/autoresponder/AutoresponderTest.java
deleted file mode 100644
index 3c79c18..0000000
--- a/src/test/java/org/sadtech/autoresponder/AutoresponderTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-//package org.sadtech.autoresponder;
-//
-//import org.junit.Assert;
-//import org.junit.Before;
-//import org.junit.Ignore;
-//import org.junit.Test;
-//import org.sadtech.autoresponder.entity.Person;
-//import org.sadtech.autoresponder.entity.Unit;
-//import org.sadtech.autoresponder.repository.UnitRepository;
-//import org.sadtech.autoresponder.repository.impl.PersonRepositoryMap;
-//import org.sadtech.autoresponder.service.impl.PersonServiceImpl;
-//import org.sadtech.autoresponder.service.impl.UnitServiceImpl;
-//
-//import java.util.*;
-//
-//public class AutoresponderTest {
-//
-// private Person person = new Person(1);
-// private TextUnit unit = new TextUnit();
-// private TextUnit unit2 = new TextUnit();
-// private TextUnit unit3 = new TextUnit();
-// private ArrayList units = new ArrayList<>();
-// private TextUnitRepositoryList unitRepository = new TextUnitRepositoryList();
-// private PersonRepositoryMap personRepository = new PersonRepositoryMap();
-//
-// private UnitServiceImpl unitService = new UnitServiceImpl();
-// private PersonServiceImpl personService = new PersonServiceImpl(personRepository);
-// private Autoresponder autoresponder = new Autoresponder(unitService, personService);
-//
-//
-// @Before
-// public void before() {
-// unitService.addUnitRepository(unitRepository);
-//
-// HashSet words = new HashSet<>();
-// HashSet words2 = new HashSet<>();
-// words.add("тест");
-// words2.add("тест");
-// words2.add("привет");
-//
-// unit.setPriority(50);
-// unit.setKeyWords(words);
-// unit.setAnswer("Здравствуйте, вы написали в нашу компанию!");
-// unit.setMatchThreshold(100);
-//
-// units.add(unit2);
-// units.add(unit3);
-//
-// unit.setNextUnits(units);
-//
-// unit2.setAnswer("Ответ с {0} параметрами!");
-// unit2.setPriority(60);
-// unit2.setKeyWords(words);
-// unit2.setMatchThreshold(100);
-//
-// unit3.setAnswer("Второй Ответ с {0} параметрами!");
-// unit3.setPriority(50);
-// unit3.setKeyWords(words2);
-// unit3.setMatchThreshold(100);
-//
-// person.setUnit(unit);
-//
-// unitRepository.addUnit(unit);
-// unitRepository.addUnit(unit2);
-// personRepository.addPerson(person);
-// }
-//
-// @Test
-// @Ignore
-// public void usualAnswer() {
-// Unit unit = autoresponder.answer(person.getId(), "Привет это тест срабатывания");
-// Assert.assertEquals(((TextUnit) unit).getAnswer(), "Ответ с {0} параметрами!");
-// }
-//
-//
-// @Test
-// @Ignore
-// public void NoAnswer() {
-// person.setUnit(null);
-// autoresponder.answer(person.getId(), "Привет это срабатывания");
-// }
-//
-//
-// @Test
-// @Ignore
-// public void answerByPriority() {
-// Assert.assertEquals(autoresponder.answer(person.getId(), "Привет это тест срабатывания"), "Ответ с {0} параметрами!");
-// }
-//
-// @Test
-// @Ignore
-// public void answerNoPerson() {
-// TextUnit textUnit = (TextUnit) autoresponder.answer(100, "Привет это тест срабатывания");
-// Assert.assertEquals(textUnit.getAnswer(), "Здравствуйте, вы написали в нашу компанию!");
-// textUnit = (TextUnit) autoresponder.answer(100, "Привет это тест срабатывания");
-// Assert.assertEquals(textUnit.getAnswer(), "Ответ с {0} параметрами!");
-// }
-//
-//
-// private class TextUnit extends Unit {
-// private String answer;
-//
-// public TextUnit() {
-// super();
-// }
-//
-// public String getAnswer() {
-// return answer;
-// }
-//
-// public void setAnswer(String answer) {
-// this.answer = answer;
-// }
-// }
-//
-// private class TextUnitRepositoryList implements UnitRepository {
-//
-// List textUnits = new ArrayList<>();
-//
-//
-// @Override
-// public void addUnit(TextUnit unit) {
-// textUnits.add(unit);
-// }
-//
-// @Override
-// public void addUnits(List units) {
-// textUnits.addAll(units);
-// }
-//
-// @Override
-// public List menuUnits() {
-// List units = new ArrayList<>();
-// for (TextUnit textUnit : textUnits) {
-// units.add(textUnit);
-// }
-// return units;
-// }
-// }
-//}
\ No newline at end of file
diff --git a/src/test/java/org/sadtech/autoresponder/submodule/insertwords/InsertWordsTest.java b/src/test/java/org/sadtech/autoresponder/submodule/insertwords/InsertWordsTest.java
deleted file mode 100644
index e0a60a7..0000000
--- a/src/test/java/org/sadtech/autoresponder/submodule/insertwords/InsertWordsTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-//package org.sadtech.autoresponder.submodule.insertwords;
-//
-//import org.junit.After;
-//import org.junit.Assert;
-//import org.junit.Test;
-//import org.sadtech.autoresponder.submodule.insertwords.InsertWords;
-//
-//import java.util.ArrayList;
-//
-//public class InsertWordsTest {
-//
-// private ArrayList arrayList = new ArrayList<>();
-// private InsertWords insertWords = new InsertWords();
-//
-// @After
-// public void setUp() {
-//
-// }
-//
-// @Test
-// public void insert() {
-// insertWords.setInText("Проверка {0} теста");
-// arrayList.add("первого");
-// insertWords.insert(arrayList);
-// Assert.assertEquals(insertWords.getOutText(),"Проверка первого теста");
-// }
-//
-// @Test
-// public void insert2() {
-// insertWords.setInText("Проверка {0} теста и {1} {теста}");
-// arrayList.add("первого");
-// arrayList.add("второго");
-// insertWords.insert(arrayList);
-// Assert.assertEquals(insertWords.getOutText(),"Проверка первого теста и второго {теста}");
-// }
-//
-// @Test
-// public void insert3() {
-// insertWords.setInText("Проверка {1} теста и {0} {теста}");
-// arrayList.add("первого");
-// arrayList.add("второго");
-// insertWords.insert(arrayList);
-// Assert.assertEquals(insertWords.getOutText(),"Проверка второго теста и первого {теста}");
-// }
-//}
\ No newline at end of file
diff --git a/src/test/java/org/sadtech/autoresponder/submodule/parser/ParserTest.java b/src/test/java/org/sadtech/autoresponder/submodule/parser/ParserTest.java
deleted file mode 100644
index 402a24a..0000000
--- a/src/test/java/org/sadtech/autoresponder/submodule/parser/ParserTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.sadtech.autoresponder.submodule.parser;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.junit.Assert.*;
-
-public class ParserTest {
-
- private Parser parser = new Parser();
- private Set words = new HashSet<>();
-
- @Test
- public void parse() {
- parser.setText("Проверка парсера на правильность");
- parser.parse();
- words.add("проверка");
- words.add("парсера");
- words.add("на");
- words.add("правильность");
- Assert.assertEquals(parser.getWords(), words);
- }
-}
\ No newline at end of file