Search in sources :

Example 1 with ImportResultStatus

use of de.symeda.sormas.ui.importer.ImportResultStatus in project SORMAS-Project by hzi-braunschweig.

the class ContactImporterTest method testImportCaseContactsDifferentAddressTypes.

@Test
public void testImportCaseContactsDifferentAddressTypes() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
    ContactFacadeEjb contactFacade = getBean(ContactFacadeEjbLocal.class);
    RDCF rdcf = creator.createRDCF("Abia", "Umuahia North", "Urban Ward 2", "Anelechi Hospital");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    PersonDto casePerson = creator.createPerson("John", "Smith");
    CaseDataDto caze = creator.createCase(user.toReference(), casePerson.toReference(), Disease.CORONAVIRUS, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
    // import of 3 contacts with different address types
    File csvFile = new File(getClass().getClassLoader().getResource("sormas_case_contact_import_test_address_types.csv").toURI());
    ContactImporter contactImporter = new ContactImporterExtension(csvFile, user, caze);
    ImportResultStatus importResult = contactImporter.runImport();
    List<ContactDto> contacts = getContactFacade().getAllAfter(null);
    assertEquals(3, contacts.size());
    boolean foundOtto = false;
    boolean foundOskar = false;
    boolean foundOona = false;
    for (ContactDto contact : contacts) {
        PersonDto person = getPersonFacade().getPersonByUuid(contact.getPerson().getUuid());
        if ("Otto".equals(person.getFirstName())) {
            foundOtto = true;
            assertTrue(CollectionUtils.isEmpty(person.getAddresses()));
            assertEquals("131", person.getAddress().getHouseNumber());
        }
        if ("Oskar".equals(person.getFirstName())) {
            foundOskar = true;
            assertTrue(CollectionUtils.isEmpty(person.getAddresses()));
            assertEquals("132", person.getAddress().getHouseNumber());
        }
        if ("Oona".equals(person.getFirstName())) {
            foundOona = true;
            assertTrue(person.getAddress().checkIsEmptyLocation());
            assertEquals(1, person.getAddresses().size());
            assertEquals("133", person.getAddresses().get(0).getHouseNumber());
        }
    }
    assertTrue("Not all contacts found.", foundOtto && foundOskar && foundOona);
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) SimilarPersonDto(de.symeda.sormas.api.person.SimilarPersonDto) UserDto(de.symeda.sormas.api.user.UserDto) ContactFacadeEjb(de.symeda.sormas.backend.contact.ContactFacadeEjb) Date(java.util.Date) RDCF(de.symeda.sormas.ui.TestDataCreator.RDCF) ContactDto(de.symeda.sormas.api.contact.ContactDto) ImportResultStatus(de.symeda.sormas.ui.importer.ImportResultStatus) File(java.io.File) AbstractBeanTest(de.symeda.sormas.ui.AbstractBeanTest) Test(org.junit.Test)

Example 2 with ImportResultStatus

use of de.symeda.sormas.ui.importer.ImportResultStatus in project SORMAS-Project by hzi-braunschweig.

the class ContactImporterTest method testImportContactsWithVaccinations.

@Test
@Ignore("Remove ignore once we have replaced H2, and feature properties can be changed by code")
public void testImportContactsWithVaccinations() throws IOException, InterruptedException, CsvValidationException, InvalidColumnException, URISyntaxException {
    RDCF rdcf = creator.createRDCF("Abia", "Umuahia North", "Urban Ward 2", "Anelechi Hospital");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    File csvFile = new File(getClass().getClassLoader().getResource("sormas_contact_import_test_vaccinations.csv").toURI());
    ContactImporterExtension contactImporter = new ContactImporterExtension(csvFile, user, null);
    ImportResultStatus importResult = contactImporter.runImport();
    assertEquals(contactImporter.stringBuilder.toString(), ImportResultStatus.COMPLETED, importResult);
    List<ContactDto> contacts = getContactFacade().getAllAfter(null);
    assertEquals(3, contacts.size());
    ContactDto contact1 = contacts.stream().filter(c -> c.getCaseIdExternalSystem().equals("case1")).findFirst().get();
    ContactDto contact2 = contacts.stream().filter(c -> c.getCaseIdExternalSystem().equals("case2")).findFirst().get();
    ContactDto contact3 = contacts.stream().filter(c -> c.getCaseIdExternalSystem().equals("case3")).findFirst().get();
    List<VaccinationDto> case1Vaccinations = FacadeProvider.getVaccinationFacade().getAllVaccinations(contact1.getPerson().getUuid(), Disease.CORONAVIRUS);
    assertEquals(0, case1Vaccinations.size());
    List<VaccinationDto> case2Vaccinations = FacadeProvider.getVaccinationFacade().getAllVaccinations(contact2.getPerson().getUuid(), Disease.CORONAVIRUS);
    assertEquals(1, case2Vaccinations.size());
    assertEquals(Vaccine.COMIRNATY, case2Vaccinations.get(0).getVaccineName());
    assertNull(case2Vaccinations.get(0).getHealthConditions().getChronicPulmonaryDisease());
    List<VaccinationDto> case3Vaccinations = FacadeProvider.getVaccinationFacade().getAllVaccinations(contact3.getPerson().getUuid(), Disease.CORONAVIRUS);
    assertEquals(2, case3Vaccinations.size());
    assertEquals(Vaccine.MRNA_1273, case3Vaccinations.get(0).getVaccineName());
    assertEquals(YesNoUnknown.YES, case3Vaccinations.get(0).getHealthConditions().getChronicPulmonaryDisease());
    assertEquals(Vaccine.MRNA_1273, case3Vaccinations.get(1).getVaccineName());
    assertNull(case3Vaccinations.get(1).getHealthConditions().getChronicPulmonaryDisease());
}
Also used : RDCF(de.symeda.sormas.ui.TestDataCreator.RDCF) UserDto(de.symeda.sormas.api.user.UserDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) ImportResultStatus(de.symeda.sormas.ui.importer.ImportResultStatus) File(java.io.File) Ignore(org.junit.Ignore) AbstractBeanTest(de.symeda.sormas.ui.AbstractBeanTest) Test(org.junit.Test)

Example 3 with ImportResultStatus

use of de.symeda.sormas.ui.importer.ImportResultStatus in project SORMAS-Project by hzi-braunschweig.

the class ContactImporterTest method testImportCaseContacts.

@Test
public void testImportCaseContacts() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
    ContactFacadeEjb contactFacade = getBean(ContactFacadeEjbLocal.class);
    RDCF rdcf = creator.createRDCF("Abia", "Umuahia North", "Urban Ward 2", "Anelechi Hospital");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    PersonDto casePerson = creator.createPerson("John", "Smith");
    CaseDataDto caze = creator.createCase(user.toReference(), casePerson.toReference(), Disease.CORONAVIRUS, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
    // Successful import of 5 case contacts
    File csvFile = new File(getClass().getClassLoader().getResource("sormas_case_contact_import_test_success.csv").toURI());
    ContactImporter contactImporter = new ContactImporterExtension(csvFile, user, caze);
    ImportResultStatus importResult = contactImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED, importResult);
    assertEquals(5, contactFacade.count(null));
    // Person Similarity: pick
    List<SimilarPersonDto> persons = FacadeProvider.getPersonFacade().getSimilarPersonDtos(new PersonSimilarityCriteria());
    csvFile = new File(getClass().getClassLoader().getResource("sormas_case_contact_import_test_similarities.csv").toURI());
    contactImporter = new ContactImporterExtension(csvFile, user, caze) {

        @Override
        protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
            List<SimilarPersonDto> entries = new ArrayList<>();
            for (SimilarPersonDto person : persons) {
                if (PersonHelper.areNamesSimilar(newPerson.getFirstName(), newPerson.getLastName(), person.getFirstName(), person.getLastName(), null)) {
                    entries.add(person);
                }
            }
            resultConsumer.accept((T) new ContactImportSimilarityResult(entries.get(0), null, ImportSimilarityResultOption.PICK));
        }
    };
    importResult = contactImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED, importResult);
    assertEquals(6, contactFacade.count(null));
    assertEquals(6, getPersonFacade().getAllUuids().size());
    // Person Similarity: skip
    csvFile = new File(getClass().getClassLoader().getResource("sormas_case_contact_import_test_similarities.csv").toURI());
    contactImporter = new ContactImporterExtension(csvFile, user, caze) {

        @Override
        protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
            resultConsumer.accept((T) new ContactImportSimilarityResult(null, null, ImportSimilarityResultOption.SKIP));
        }
    };
    importResult = contactImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED, importResult);
    assertEquals(6, contactFacade.count(null));
    assertEquals(6, getPersonFacade().getAllUuids().size());
    // Person Similarity: create
    csvFile = new File(getClass().getClassLoader().getResource("sormas_case_contact_import_test_similarities.csv").toURI());
    contactImporter = new ContactImporterExtension(csvFile, user, caze);
    importResult = contactImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED, importResult);
    assertEquals(7, contactFacade.count(null));
    assertEquals(7, getPersonFacade().getAllUuids().size());
    // Test import contacts from a commented CSV file
    // Successful import of 5 case contacts
    csvFile = new File(getClass().getClassLoader().getResource("sormas_case_contact_import_test_comment_success.csv").toURI());
    contactImporter = new ContactImporterExtension(csvFile, user, caze);
    importResult = contactImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED, importResult);
    assertEquals(12, contactFacade.count(null));
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) SimilarPersonDto(de.symeda.sormas.api.person.SimilarPersonDto) UserDto(de.symeda.sormas.api.user.UserDto) ContactFacadeEjb(de.symeda.sormas.backend.contact.ContactFacadeEjb) Date(java.util.Date) PersonSimilarityCriteria(de.symeda.sormas.api.person.PersonSimilarityCriteria) SimilarPersonDto(de.symeda.sormas.api.person.SimilarPersonDto) RDCF(de.symeda.sormas.ui.TestDataCreator.RDCF) UI(com.vaadin.ui.UI) ContactImportSimilarityResult(de.symeda.sormas.ui.importer.ContactImportSimilarityResult) ImportSimilarityResultOption(de.symeda.sormas.ui.importer.ImportSimilarityResultOption) ImportResultStatus(de.symeda.sormas.ui.importer.ImportResultStatus) List(java.util.List) ArrayList(java.util.ArrayList) File(java.io.File) AbstractBeanTest(de.symeda.sormas.ui.AbstractBeanTest) Test(org.junit.Test)

Example 4 with ImportResultStatus

use of de.symeda.sormas.ui.importer.ImportResultStatus in project SORMAS-Project by hzi-braunschweig.

the class CaseImporterTest method testImportWithVaccinations.

@Test
@Ignore("Remove ignore once we have replaced H2, and feature properties can be changed by code")
public void testImportWithVaccinations() throws IOException, InterruptedException, CsvValidationException, InvalidColumnException, URISyntaxException {
    TestDataCreator creator = new TestDataCreator();
    TestDataCreator.RDCF rdcf = creator.createRDCF();
    creator.createFacility("Lab", FacilityType.LABORATORY, rdcf.region.toReference(), rdcf.district.toReference(), rdcf.community.toReference());
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    // import of 3 cases with different number of vaccinations
    File csvFile = new File(getClass().getClassLoader().getResource("sormas_case_import_test_vaccinations.csv").toURI());
    CaseImporterExtension caseImporter = new CaseImporterExtension(csvFile, true, user);
    ImportResultStatus importResult = caseImporter.runImport();
    assertEquals(caseImporter.stringBuilder.toString(), ImportResultStatus.COMPLETED, importResult);
    CaseDataDto case1 = getCaseFacade().getByExternalId("case1").get(0);
    CaseDataDto case2 = getCaseFacade().getByExternalId("case2").get(0);
    CaseDataDto case3 = getCaseFacade().getByExternalId("case3").get(0);
    List<VaccinationDto> case1Vaccinations = FacadeProvider.getVaccinationFacade().getAllVaccinations(case1.getPerson().getUuid(), Disease.CORONAVIRUS);
    assertEquals(0, case1Vaccinations.size());
    List<VaccinationDto> case2Vaccinations = FacadeProvider.getVaccinationFacade().getAllVaccinations(case2.getPerson().getUuid(), Disease.CORONAVIRUS);
    assertEquals(1, case2Vaccinations.size());
    assertEquals(Vaccine.COMIRNATY, case2Vaccinations.get(0).getVaccineName());
    assertNull(case2Vaccinations.get(0).getHealthConditions().getChronicPulmonaryDisease());
    List<VaccinationDto> case3Vaccinations = FacadeProvider.getVaccinationFacade().getAllVaccinations(case3.getPerson().getUuid(), Disease.CORONAVIRUS);
    assertEquals(2, case3Vaccinations.size());
    assertEquals(Vaccine.MRNA_1273, case3Vaccinations.get(0).getVaccineName());
    assertEquals(YesNoUnknown.YES, case3Vaccinations.get(0).getHealthConditions().getChronicPulmonaryDisease());
    assertEquals(Vaccine.MRNA_1273, case3Vaccinations.get(1).getVaccineName());
    assertNull(case3Vaccinations.get(1).getHealthConditions().getChronicPulmonaryDisease());
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) UserDto(de.symeda.sormas.api.user.UserDto) TestDataCreator(de.symeda.sormas.ui.TestDataCreator) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) ImportResultStatus(de.symeda.sormas.ui.importer.ImportResultStatus) File(java.io.File) Ignore(org.junit.Ignore) AbstractBeanTest(de.symeda.sormas.ui.AbstractBeanTest) Test(org.junit.Test)

Example 5 with ImportResultStatus

use of de.symeda.sormas.ui.importer.ImportResultStatus in project SORMAS-Project by hzi-braunschweig.

the class CaseImporterTest method testImportAllCases.

@Test
public void testImportAllCases() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
    TestDataCreator creator = new TestDataCreator();
    TestDataCreator.RDCF rdcf = creator.createRDCF("Abia", "Umuahia North", "Urban Ward 2", "Anelechi Hospital");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    // Successful import of 5 cases
    File csvFile = new File(getClass().getClassLoader().getResource("sormas_import_test_success.csv").toURI());
    CaseImporterExtension caseImporter = new CaseImporterExtension(csvFile, true, user);
    ImportResultStatus importResult = caseImporter.runImport();
    assertEquals(caseImporter.stringBuilder.toString(), ImportResultStatus.COMPLETED, importResult);
    assertEquals(5, getCaseFacade().count(null));
    // Failed import of 5 cases because of errors
    csvFile = new File(getClass().getClassLoader().getResource("sormas_import_test_errors.csv").toURI());
    caseImporter = new CaseImporterExtension(csvFile, true, user);
    importResult = caseImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED_WITH_ERRORS, importResult);
    assertEquals(5, getCaseFacade().count(null));
    // Similarity: skip
    csvFile = new File(getClass().getClassLoader().getResource("sormas_import_test_similarities.csv").toURI());
    caseImporter = new CaseImporterExtension(csvFile, true, user) {

        @Override
        protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
            resultConsumer.accept((T) new CaseImportSimilarityResult(null, null, ImportSimilarityResultOption.SKIP));
        }
    };
    importResult = caseImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED, importResult);
    assertEquals(5, getCaseFacade().count(null));
    assertEquals("ABC-DEF-GHI-19-5", getCaseFacade().getAllActiveCasesAfter(null).get(4).getEpidNumber());
    // Similarity: pick
    List<SimilarPersonDto> persons = FacadeProvider.getPersonFacade().getSimilarPersonDtos(new PersonSimilarityCriteria());
    csvFile = new File(getClass().getClassLoader().getResource("sormas_import_test_similarities.csv").toURI());
    caseImporter = new CaseImporterExtension(csvFile, true, user) {

        @Override
        protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
            List<SimilarPersonDto> entries = new ArrayList<>();
            for (SimilarPersonDto person : persons) {
                if (PersonHelper.areNamesSimilar(newPerson.getFirstName(), newPerson.getLastName(), person.getFirstName(), person.getLastName(), null)) {
                    entries.add(person);
                }
            }
            resultConsumer.accept((T) new CaseImportSimilarityResult(entries.get(0), null, ImportSimilarityResultOption.PICK));
        }

        @Override
        protected void handleCaseSimilarity(CaseImportSimilarityInput input, Consumer<CaseImportSimilarityResult> resultConsumer) {
            resultConsumer.accept(new CaseImportSimilarityResult(null, input.getSimilarCases().get(0), ImportSimilarityResultOption.PICK));
        }
    };
    importResult = caseImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED, importResult);
    assertEquals(5, getCaseFacade().count(null));
    assertEquals("ABC-DEF-GHI-19-5", getCaseFacade().getAllActiveCasesAfter(null).get(4).getEpidNumber());
    // Similarity: cancel
    csvFile = new File(getClass().getClassLoader().getResource("sormas_import_test_similarities.csv").toURI());
    caseImporter = new CaseImporterExtension(csvFile, true, user) {

        @Override
        protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
            resultConsumer.accept((T) new CaseImportSimilarityResult(null, null, ImportSimilarityResultOption.CANCEL));
        }
    };
    importResult = caseImporter.runImport();
    assertEquals(ImportResultStatus.CANCELED, importResult);
    assertEquals(5, getCaseFacade().count(null));
    assertEquals("ABC-DEF-GHI-19-5", getCaseFacade().getAllActiveCasesAfter(null).get(4).getEpidNumber());
    // Similarity: override
    csvFile = new File(getClass().getClassLoader().getResource("sormas_import_test_similarities.csv").toURI());
    caseImporter = new CaseImporterExtension(csvFile, true, user) {

        @Override
        protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
            List<SimilarPersonDto> entries = new ArrayList<>();
            for (SimilarPersonDto person : persons) {
                if (PersonHelper.areNamesSimilar(newPerson.getFirstName(), newPerson.getLastName(), person.getFirstName(), person.getLastName(), null)) {
                    entries.add(person);
                }
            }
            resultConsumer.accept((T) new CaseImportSimilarityResult(entries.get(0), null, ImportSimilarityResultOption.PICK));
        }

        @Override
        protected void handleCaseSimilarity(CaseImportSimilarityInput input, Consumer<CaseImportSimilarityResult> resultConsumer) {
            resultConsumer.accept(new CaseImportSimilarityResult(null, input.getSimilarCases().get(0), ImportSimilarityResultOption.OVERRIDE));
        }
    };
    importResult = caseImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED, importResult);
    assertEquals(5, getCaseFacade().count(null));
    assertEquals("ABC-DEF-GHI-19-10", getCaseFacade().getAllActiveCasesAfter(null).get(4).getEpidNumber());
    // Similarity: create -> fail because of duplicate epid number
    csvFile = new File(getClass().getClassLoader().getResource("sormas_import_test_similarities.csv").toURI());
    caseImporter = new CaseImporterExtension(csvFile, true, user) {

        @Override
        protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
            List<SimilarPersonDto> entries = new ArrayList<>();
            for (SimilarPersonDto person : persons) {
                if (PersonHelper.areNamesSimilar(newPerson.getFirstName(), newPerson.getLastName(), person.getFirstName(), person.getLastName(), null)) {
                    entries.add(person);
                }
            }
            resultConsumer.accept((T) new CaseImportSimilarityResult(entries.get(0), null, ImportSimilarityResultOption.PICK));
        }

        @Override
        protected void handleCaseSimilarity(CaseImportSimilarityInput input, Consumer<CaseImportSimilarityResult> resultConsumer) {
            resultConsumer.accept(new CaseImportSimilarityResult(null, null, ImportSimilarityResultOption.CREATE));
        }
    };
    importResult = caseImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED_WITH_ERRORS, importResult);
    assertEquals(5, getCaseFacade().count(null));
    assertEquals("ABC-DEF-GHI-19-10", getCaseFacade().getAllActiveCasesAfter(null).get(4).getEpidNumber());
    // Change epid number of the case in database to pass creation test
    CaseDataDto caze = getCaseFacade().getAllActiveCasesAfter(null).get(4);
    caze.setEpidNumber("ABC-DEF-GHI-19-99");
    getCaseFacade().save(caze);
    assertEquals("ABC-DEF-GHI-19-99", getCaseFacade().getAllActiveCasesAfter(null).get(4).getEpidNumber());
    // Similarity: create -> pass
    csvFile = new File(getClass().getClassLoader().getResource("sormas_import_test_similarities.csv").toURI());
    caseImporter = new CaseImporterExtension(csvFile, true, user);
    importResult = caseImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED, importResult);
    assertEquals(6, getCaseFacade().count(null));
    assertEquals("ABC-DEF-GHI-19-10", getCaseFacade().getAllActiveCasesAfter(null).get(5).getEpidNumber());
    // Successful import of a case with different infrastructure combinations
    creator.createRDCF("R1", "D1", "C1", "F1");
    creator.createRDCF("R2", "D2", "C2", "F2");
    creator.createRDCF("R3", "D3", "C3", "F3");
    csvFile = new File(getClass().getClassLoader().getResource("sormas_case_import_test_different_infrastructure.csv").toURI());
    caseImporter = new CaseImporterExtension(csvFile, true, user);
    importResult = caseImporter.runImport();
    assertEquals(ImportResultStatus.COMPLETED, importResult);
    assertEquals(7, getCaseFacade().count(null));
    // Successful import of 5 cases from a commented CSV file
    csvFile = new File(getClass().getClassLoader().getResource("sormas_import_test_comment_success.csv").toURI());
    caseImporter = new CaseImporterExtension(csvFile, true, user);
    importResult = caseImporter.runImport();
    assertEquals(caseImporter.stringBuilder.toString(), ImportResultStatus.COMPLETED, importResult);
    assertEquals(12, getCaseFacade().count(null));
}
Also used : CaseImportSimilarityResult(de.symeda.sormas.ui.importer.CaseImportSimilarityResult) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) SimilarPersonDto(de.symeda.sormas.api.person.SimilarPersonDto) UserDto(de.symeda.sormas.api.user.UserDto) PersonSimilarityCriteria(de.symeda.sormas.api.person.PersonSimilarityCriteria) SimilarPersonDto(de.symeda.sormas.api.person.SimilarPersonDto) CaseImportSimilarityInput(de.symeda.sormas.ui.importer.CaseImportSimilarityInput) UI(com.vaadin.ui.UI) TestDataCreator(de.symeda.sormas.ui.TestDataCreator) ImportSimilarityResultOption(de.symeda.sormas.ui.importer.ImportSimilarityResultOption) ImportResultStatus(de.symeda.sormas.ui.importer.ImportResultStatus) List(java.util.List) ArrayList(java.util.ArrayList) File(java.io.File) AbstractBeanTest(de.symeda.sormas.ui.AbstractBeanTest) Test(org.junit.Test)

Aggregations

ImportResultStatus (de.symeda.sormas.ui.importer.ImportResultStatus)28 UserDto (de.symeda.sormas.api.user.UserDto)27 AbstractBeanTest (de.symeda.sormas.ui.AbstractBeanTest)27 File (java.io.File)27 Test (org.junit.Test)27 TestDataCreator (de.symeda.sormas.ui.TestDataCreator)15 Date (java.util.Date)13 RDCF (de.symeda.sormas.ui.TestDataCreator.RDCF)12 PersonDto (de.symeda.sormas.api.person.PersonDto)11 SimilarPersonDto (de.symeda.sormas.api.person.SimilarPersonDto)11 EventDto (de.symeda.sormas.api.event.EventDto)9 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)7 EventReferenceDto (de.symeda.sormas.api.event.EventReferenceDto)7 EventParticipantFacadeEjbLocal (de.symeda.sormas.backend.event.EventParticipantFacadeEjb.EventParticipantFacadeEjbLocal)7 EventParticipantCriteria (de.symeda.sormas.api.event.EventParticipantCriteria)6 UI (com.vaadin.ui.UI)5 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)5 PersonSimilarityCriteria (de.symeda.sormas.api.person.PersonSimilarityCriteria)5 PersonImportSimilarityResult (de.symeda.sormas.ui.importer.PersonImportSimilarityResult)4 ArrayList (java.util.ArrayList)4