Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tech.ivoice.client.solutions.medsi.integration;
- import com.google.common.collect.ImmutableList;
- import org.junit.jupiter.api.BeforeEach;
- import org.junit.jupiter.api.Test;
- import tech.ivoice.client.solutions.medsi.commons.CommonPlays;
- import tech.ivoice.client.solutions.medsi.commons.dto.Dto;
- import tech.ivoice.client.solutions.medsi.components.clinic.ClinicSelection;
- import tech.ivoice.client.solutions.medsi.components.clinic.ClinicSelectionPlays;
- import tech.ivoice.client.solutions.medsi.components.clinic.utils.ClinicFilter;
- import tech.ivoice.client.solutions.medsi.components.clinic.utils.data.Clinic;
- import tech.ivoice.client.solutions.medsi.components.makeapp.AppDate;
- import tech.ivoice.client.solutions.medsi.components.makeapp.AppNearest;
- import tech.ivoice.client.solutions.medsi.components.makeapp.AppTime;
- import tech.ivoice.client.solutions.medsi.components.makeapp.MakeAppointment;
- import tech.ivoice.client.solutions.medsi.components.makeapp.plays.AppDatePlays;
- import tech.ivoice.client.solutions.medsi.components.makeapp.plays.AppNearestPlays;
- import tech.ivoice.client.solutions.medsi.components.makeapp.plays.AppPlays;
- import tech.ivoice.client.solutions.medsi.components.makeapp.plays.AppTimePlays;
- import tech.ivoice.client.solutions.medsi.components.patient.PatientComponent;
- import tech.ivoice.client.solutions.medsi.components.patient.PatientPlays;
- import tech.ivoice.client.solutions.medsi.components.specialty.SpecialtyPlays;
- import tech.ivoice.client.solutions.medsi.components.specialty.SpecialtySelection;
- import tech.ivoice.client.solutions.medsi.components.specialty.utils.SpecListCreator;
- import tech.ivoice.client.solutions.medsi.components.specialty.utils.SpecSearcher;
- import tech.ivoice.client.solutions.medsi.components.specialty.utils.Specialty;
- import tech.ivoice.platform.fsm.test.StateLoggedFsm;
- import tech.ivoice.platform.sdk.messages.Log;
- import tech.ivoice.platform.sdk.messages.Result;
- import tech.ivoice.platform.sdk.messages.SolutionMessage;
- import tech.ivoice.platform.sdk.messages.session.PlayCollectSpeech;
- import java.util.ArrayDeque;
- import java.util.List;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import static tech.ivoice.platform.extension.sdk.fsm_support.Tools.link;
- import static tech.ivoice.platform.sdk.messages.session.PlayCollectSpeech.Result.fullSpeech;
- public class Integration_1_Test {
- private PatientComponent patientComponent;
- private SpecialtySelection specialtyComponent;
- private ClinicSelection clinicComponent;
- private AppNearest appNearest;
- private AppDate appDate;
- private AppTime appTime;
- private MakeAppointment makeAppointment;
- private CommonPlays commonPlays;
- private PatientPlays patientPlays;
- private SpecialtyPlays specialtyPlays;
- private ClinicSelectionPlays clinicPlays;
- private AppNearestPlays appNearestPlays;
- private AppDatePlays appDatePlays;
- private AppTimePlays appTimePlays;
- private AppPlays makeAppPlays;
- private StateLoggedFsm fsm;
- private ArrayDeque<SolutionMessage> platform;
- private void platform(SolutionMessage message) {
- if (message instanceof Log)
- return;
- platform.addLast(message);
- }
- @BeforeEach
- void setUp() {
- this.fsm = new StateLoggedFsm();
- this.platform = new ArrayDeque<>();
- this.patientComponent = new PatientComponent(this::platform);
- this.specialtyComponent = new SpecialtySelection(this::platform);
- this.clinicComponent = new ClinicSelection(this::platform);
- this.appNearest = new AppNearest(this::platform);
- this.appDate = new AppDate(this::platform);
- this.appTime = new AppTime(this::platform);
- this.makeAppointment = new MakeAppointment(this::platform);
- this.commonPlays = new CommonPlays();
- this.patientPlays = new PatientPlays();
- this.specialtyPlays = new SpecialtyPlays();
- this.clinicPlays = new ClinicSelectionPlays();
- this.appNearestPlays = new AppNearestPlays();
- this.appDatePlays = new AppDatePlays();
- this.appTimePlays = new AppTimePlays();
- this.makeAppPlays = new AppPlays();
- link(patientComponent.bridgeSpecialtyComponent, specialtyComponent.entry);
- link(specialtyComponent.toClinicSelection, clinicComponent.entry);
- link(clinicComponent.bridgeAppNearest, appNearest.entry);
- link(appNearest.bridgeMakeApp, makeAppointment.entry);
- link(appNearest.bridgeAppDate, appDate.entry);
- link(appDate.bridgeMakeApp, makeAppointment.entry);
- link(appDate.bridgeAppTime, appTime.entry);
- link(appTime.bridgeMakeApp, makeAppointment.entry);
- Dto dto = new Dto();
- dto.setPhone("79133841262");
- fsm.start(patientComponent.entry, dto);
- }
- /**
- * 1. "Запись"
- * 2. "Взрослый"
- * 3. Пациент - любой из списка выше или любой реальный
- * 4. "Невролог"
- * 5. "Красногорск"
- * 6. Ближайшее время для записи 24.12.2019 в...
- * 7. Подтверждение времени и даты записи- "НЕТ - 25.12.2019"
- * 8. Есть окно в ..., удобно - "ДА"
- * Запись в МИС, резюмирование
- */
- @Test
- // @SuppressWarnings("ConstantConditions")
- void test_sc1() {
- PlayCollectSpeech askAgeGrp = pollPCS();
- assertEquals(patientPlays.askAgeGroup().getPlaySource(), askAgeGrp.getPlaySource());
- answer(askAgeGrp, "взрослый");
- PlayCollectSpeech askName = pollPCS();
- assertEquals(patientPlays.askFullName().getPlaySource(), askName.getPlaySource());
- Result resultAgeGrp = pollResult();
- assertEquals("взрослый", resultAgeGrp.getValue());
- answer(askName, "Иванов Иван Иванович");
- PlayCollectSpeech askBd = pollPCS();
- assertEquals(patientPlays.askBirthDate().getPlaySource(), askBd.getPlaySource());
- Result name = pollResult();
- assertEquals("Иванов Иван Иванович", name.getValue());
- answer(askBd, "12 июля 2001");
- System.out.println(platform.toString());
- }
- @Test
- void spec() {
- List<Specialty> allSpecialties =SpecListCreator.getSpecialtiesBasedOnAgeGroup("1");
- List<Specialty> foundSpecialties = SpecSearcher.findSpecialty("хирург", allSpecialties);
- List<Clinic> clinics = ClinicFilter.filterClinicsBySelectedSpecialty(foundSpecialties);
- System.out.println();
- }
- @Test
- void test_sc2() {
- PlayCollectSpeech askAgeGrp = pollPCS();
- assertEquals(patientPlays.askAgeGroup().getPlaySource(), askAgeGrp.getPlaySource());
- answer(askAgeGrp, "взрослый");
- PlayCollectSpeech askName = pollPCS();
- processQuestion(patientPlays.askFullName(), askName,
- "взрослый", "Ростовский Денис Андреевич");
- PlayCollectSpeech askBd = pollPCS();
- processQuestion(patientPlays.askBirthDate(), askBd,
- "Ростовский Денис Андреевич", "20 апреля 1987");
- PlayCollectSpeech askSpecialty = pollPCS();
- processQuestion(specialtyPlays.askSpecialty(), askSpecialty,
- "20 апреля 1987", "Хирург");
- PlayCollectSpeech askClinic = pollPCS();
- processQuestion(clinicPlays.askClinic(), askClinic,
- "Хирург", "Солянка");
- System.out.println(platform.size());
- System.out.println(platform.toString());
- }
- private void processQuestion(PlayCollectSpeech expectedAsk, PlayCollectSpeech actualAsk,
- String expectedResultOnPreviousQuestion, String answerOnActualAsk) {
- assertEquals(expectedAsk.getPlaySource(), actualAsk.getPlaySource());
- Result result = pollResult();
- assertEquals(expectedResultOnPreviousQuestion, result.getValue());
- answer(actualAsk, answerOnActualAsk);
- }
- private void answer(PlayCollectSpeech ask, String answer) {
- this.fsm.process(fullSpeech(ask.getSession(), ImmutableList.of(new PlayCollectSpeech.Speech.Entry(answer, 1))));
- this.fsm.process(ask.getSession().stop());
- }
- private PlayCollectSpeech pollPCS() {
- return (PlayCollectSpeech) platform.pollLast();
- }
- private Result pollResult() {
- return (Result) platform.pollLast();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement