Search in sources :

Example 1 with RDCFEntities

use of de.symeda.sormas.backend.TestDataCreator.RDCFEntities in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testGetAllActiveCasesIncludeExtendedChangeDateFiltersPathogenTest.

@Test
public void testGetAllActiveCasesIncludeExtendedChangeDateFiltersPathogenTest() throws InterruptedException {
    RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    PersonDto cazePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    SampleDto sample = creator.createSample(caze.toReference(), user.toReference(), rdcf.facility);
    PathogenTestDto pathogenTestDto = creator.createPathogenTest(sample.toReference(), caze);
    Date date = new Date();
    // the delay is needed in order to ensure the time difference between the date and the case dependent objects update
    Thread.sleep(10L);
    pathogenTestDto.setTestResultText("test result changed");
    getPathogenTestFacade().savePathogenTest(pathogenTestDto);
    assertEquals(0, getCaseFacade().getAllActiveCasesAfter(date).size());
    assertEquals(1, getCaseFacade().getAllActiveCasesAfter(date, true).size());
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 2 with RDCFEntities

use of de.symeda.sormas.backend.TestDataCreator.RDCFEntities in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testDoesEpidNumberExist.

@Test
public void testDoesEpidNumberExist() {
    RDCFEntities rdcf = creator.createRDCFEntities();
    UserReferenceDto user = creator.createUser(rdcf).toReference();
    PersonReferenceDto cazePerson = creator.createPerson("Horst", "Meyer").toReference();
    CaseDataDto caze = creator.createCase(user, cazePerson, Disease.CHOLERA, CaseClassification.NOT_CLASSIFIED, InvestigationStatus.PENDING, new Date(), rdcf);
    // 1. Same case
    assertFalse(getCaseFacade().doesEpidNumberExist(caze.getEpidNumber(), caze.getUuid(), caze.getDisease()));
    // 2. Same disease and epid number
    assertTrue(getCaseFacade().doesEpidNumberExist(caze.getEpidNumber(), "abc", caze.getDisease()));
    // 3. Same disease, different epid number
    assertFalse(getCaseFacade().doesEpidNumberExist("123", "abc", caze.getDisease()));
    // 4. Different disease and same epid number
    assertFalse(getCaseFacade().doesEpidNumberExist(caze.getEpidNumber(), "abc", Disease.ANTHRAX));
    // 5. Different disease and different epid number
    assertFalse(getCaseFacade().doesEpidNumberExist("def", "abc", Disease.ANTHRAX));
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 3 with RDCFEntities

use of de.symeda.sormas.backend.TestDataCreator.RDCFEntities in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testGetDuplicateCasesOfSameSexAndDifferentBirthDateIsEmpty.

@Test
public void testGetDuplicateCasesOfSameSexAndDifferentBirthDateIsEmpty() {
    final Date today = new Date();
    RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    PersonDto cazePerson = creator.createPerson("Case", "Person", Sex.MALE, 1980, 1, 1);
    creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, today, rdcf);
    PersonDto cazePerson2 = creator.createPerson("Case", "Person", Sex.MALE, 1980, 1, 2);
    creator.createCase(user.toReference(), cazePerson2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, DateUtils.addMinutes(today, -3), rdcf);
    Assert.assertEquals(0, getCaseFacade().getCasesForDuplicateMerging(new CaseCriteria().creationDateFrom(today).creationDateTo(today), true).size());
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 4 with RDCFEntities

use of de.symeda.sormas.backend.TestDataCreator.RDCFEntities in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testGenerateEpidNumber.

@Test
public void testGenerateEpidNumber() throws ExternalSurveillanceToolException {
    RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR, UserRole.ADMIN);
    PersonDto cazePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), rdcf);
    Calendar calendar = Calendar.getInstance();
    String year = String.valueOf(calendar.get(Calendar.YEAR)).substring(2);
    assertEquals("COU-REG-DIS-" + year + "-001", caze.getEpidNumber());
    CaseDataDto secondCaze = creator.createCase(user.toReference(), cazePerson.toReference(), rdcf);
    assertEquals("COU-REG-DIS-" + year + "-002", secondCaze.getEpidNumber());
    secondCaze.setEpidNumber("COU-REG-DIS-" + year + "-0004");
    getCaseFacade().save(secondCaze);
    CaseDataDto thirdCaze = creator.createCase(user.toReference(), cazePerson.toReference(), rdcf);
    assertEquals("COU-REG-DIS-" + year + "-005", thirdCaze.getEpidNumber());
    thirdCaze.setEpidNumber("COU-REG-DIS-" + year + "-3");
    getCaseFacade().save(thirdCaze);
    CaseDataDto fourthCaze = creator.createCase(user.toReference(), cazePerson.toReference(), rdcf);
    assertEquals("COU-REG-DIS-" + year + "-005", fourthCaze.getEpidNumber());
    fourthCaze.setEpidNumber("COU-REG-DIS-" + year + "-AAA");
    getCaseFacade().save(fourthCaze);
    fourthCaze = getCaseFacade().getCaseDataByUuid(fourthCaze.getUuid());
    assertEquals("COU-REG-DIS-" + year + "-005", fourthCaze.getEpidNumber());
    // Make sure that deleted cases are ignored when searching for the highest existing epid nummber
    getCaseFacade().deleteCase(fourthCaze.getUuid());
    CaseDataDto fifthCaze = creator.createCase(user.toReference(), cazePerson.toReference(), rdcf);
    assertEquals("COU-REG-DIS-" + year + "-005", fifthCaze.getEpidNumber());
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) Calendar(java.util.Calendar) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 5 with RDCFEntities

use of de.symeda.sormas.backend.TestDataCreator.RDCFEntities in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testGetDuplicateCasesOfSexUnknownAndSameBirthDateMatches.

@Test
public void testGetDuplicateCasesOfSexUnknownAndSameBirthDateMatches() {
    final Date today = new Date();
    RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    PersonDto cazePerson = creator.createPerson("Case", "Person", Sex.MALE, 1980, 1, 1);
    creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, today, rdcf);
    PersonDto cazePerson2 = creator.createPerson("Case", "Person", Sex.UNKNOWN, 1980, 1, 1);
    creator.createCase(user.toReference(), cazePerson2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, DateUtils.addMinutes(today, -3), rdcf);
    Assert.assertEquals(1, getCaseFacade().getCasesForDuplicateMerging(new CaseCriteria().creationDateFrom(today).creationDateTo(today), true).size());
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)71 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)70 Test (org.junit.Test)70 PersonDto (de.symeda.sormas.api.person.PersonDto)63 UserDto (de.symeda.sormas.api.user.UserDto)63 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)59 Date (java.util.Date)53 LocalDate (java.time.LocalDate)34 ContactDto (de.symeda.sormas.api.contact.ContactDto)23 CasePersonDto (de.symeda.sormas.api.caze.CasePersonDto)19 SampleDto (de.symeda.sormas.api.sample.SampleDto)18 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)12 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)11 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)11 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)11 MapContactDto (de.symeda.sormas.api.contact.MapContactDto)10 SimilarContactDto (de.symeda.sormas.api.contact.SimilarContactDto)10 PathogenTestDto (de.symeda.sormas.api.sample.PathogenTestDto)10 EventDto (de.symeda.sormas.api.event.EventDto)9 JournalPersonDto (de.symeda.sormas.api.person.JournalPersonDto)9