Search in sources :

Example 26 with UserDto

use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testGetIndexDetailedList.

@Test
public void testGetIndexDetailedList() {
    ContactCriteria contactCriteria = new ContactCriteria();
    contactCriteria.setIncludeContactsFromOtherJurisdictions(true);
    List<SortProperty> sortProperties = Collections.emptyList();
    List<ContactIndexDetailedDto> result;
    // 0. No data: empty list
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, is(empty()));
    // Create needed structural data
    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);
    UserReferenceDto reportingUser = new UserReferenceDto(user.getUuid());
    EventDto event1 = creator.createEvent(reportingUser, DateHelper.subtractDays(new Date(), 1));
    EventDto event2 = creator.createEvent(reportingUser, new Date());
    PersonDto contactPerson = creator.createPerson("Contact", "Person");
    ContactDto contact1 = creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
    // 1a. one Contact without Event
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, hasSize(1));
    {
        ContactIndexDetailedDto dto = result.get(0);
        assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
        assertThat(dto.getEventCount(), equalTo(0L));
        assertNull(dto.getLatestEventId());
        assertNull(dto.getLatestEventTitle());
        assertThat(dto.getVisitCount(), equalTo(0));
    }
    // 1b. one Contact with one Event
    creator.createEventParticipant(new EventReferenceDto(event1.getUuid()), contactPerson, reportingUser);
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, hasSize(1));
    {
        ContactIndexDetailedDto dto = result.get(0);
        assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
        assertThat(dto.getEventCount(), equalTo(1L));
        assertThat(dto.getLatestEventId(), equalTo(event1.getUuid()));
        assertThat(dto.getLatestEventTitle(), equalTo(event1.getEventTitle()));
        assertThat(dto.getVisitCount(), equalTo(0));
    }
    // 1c. one Contact with two Events, second is leading
    creator.createEventParticipant(new EventReferenceDto(event2.getUuid()), contactPerson, reportingUser);
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, hasSize(1));
    {
        ContactIndexDetailedDto dto = result.get(0);
        assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
        assertThat(dto.getEventCount(), equalTo(2L));
        assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
        assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
        assertThat(dto.getVisitCount(), equalTo(0));
    }
    // 1d. one Contact with two Events and one visit
    creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, hasSize(1));
    {
        ContactIndexDetailedDto dto = result.get(0);
        assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
        assertThat(dto.getEventCount(), equalTo(2L));
        assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
        assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
        assertThat(dto.getVisitCount(), equalTo(1));
    }
    // 1e. one Contact with two Events and three visits
    creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
    creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, hasSize(1));
    {
        ContactIndexDetailedDto dto = result.get(0);
        assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
        assertThat(dto.getEventCount(), equalTo(2L));
        assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
        assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
        assertThat(dto.getVisitCount(), equalTo(3));
    }
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) EventDto(de.symeda.sormas.api.event.EventDto) ContactIndexDetailedDto(de.symeda.sormas.api.contact.ContactIndexDetailedDto) Date(java.util.Date) LocalDate(java.time.LocalDate) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) SortProperty(de.symeda.sormas.api.utils.SortProperty) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 27 with UserDto

use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testGetIndexList.

@Test
public void testGetIndexList() {
    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);
    PersonDto contactPerson = creator.createPerson("Contact", "Person");
    creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
    // Database should contain one contact, associated visit and task
    assertEquals(1, getContactFacade().getIndexList(null, 0, 100, null).size());
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 28 with UserDto

use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testMapContactListCreation.

@Test
public void testMapContactListCreation() {
    TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
    UserDto user = useSurveillanceOfficerLogin(rdcf);
    PersonDto cazePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    PersonDto contactPerson = creator.createPerson("Contact", "Person", p -> {
        p.getAddress().setLatitude(0.0);
        p.getAddress().setLongitude(0.0);
    });
    creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), caze.getDisease(), rdcf);
    Long count = getContactFacade().countContactsForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1));
    List<MapContactDto> mapContactDtos = getContactFacade().getContactsForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1));
    // List should have one entry
    assertEquals((long) count, mapContactDtos.size());
    assertEquals((long) 1, mapContactDtos.size());
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 29 with UserDto

use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testCountMaximumFollowUpDays.

@Test
public void testCountMaximumFollowUpDays() {
    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);
    PersonDto contactPerson = creator.createPerson("Contact", "Person");
    creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
    VisitDto visit = creator.createVisit(caze.getDisease(), contactPerson.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
    visit.getSymptoms().setAbdominalPain(SymptomState.YES);
    getVisitFacade().saveVisit(visit);
    PersonDto contactPerson2 = creator.createPerson("Contact2", "Person2");
    creator.createContact(user.toReference(), user.toReference(), contactPerson2.toReference(), caze, new Date(), new Date(), null);
    VisitDto visit21 = creator.createVisit(caze.getDisease(), contactPerson2.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
    visit21.getSymptoms().setAbdominalPain(SymptomState.YES);
    getVisitFacade().saveVisit(visit21);
    VisitDto visit22 = creator.createVisit(caze.getDisease(), contactPerson2.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
    visit22.getSymptoms().setAgitation(SymptomState.YES);
    getVisitFacade().saveVisit(visit22);
    PersonDto contactPerson3 = creator.createPerson("Contact3", "Person3");
    creator.createContact(user.toReference(), user.toReference(), contactPerson3.toReference(), caze, new Date(), new Date(), null);
    for (int i = 0; i < 10; i++) {
        creator.createVisit(caze.getDisease(), contactPerson3.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
    }
    assertEquals(10, getContactFacade().countMaximumFollowUpDays(null));
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) VisitDto(de.symeda.sormas.api.visit.VisitDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 30 with UserDto

use of de.symeda.sormas.api.user.UserDto in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testGetAllActiveCasesIncludeExtendedChangeDateFiltersSample.

@Test
public void testGetAllActiveCasesIncludeExtendedChangeDateFiltersSample() 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);
    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);
    sample.setComment("one comment");
    getSampleFacade().saveSample(sample);
    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) 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)

Aggregations

UserDto (de.symeda.sormas.api.user.UserDto)274 Test (org.junit.Test)210 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)160 PersonDto (de.symeda.sormas.api.person.PersonDto)142 Date (java.util.Date)138 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)121 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)64 ContactDto (de.symeda.sormas.api.contact.ContactDto)57 LocalDate (java.time.LocalDate)57 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)56 EventDto (de.symeda.sormas.api.event.EventDto)52 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)47 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)43 AbstractBeanTest (de.symeda.sormas.ui.AbstractBeanTest)43 SampleDto (de.symeda.sormas.api.sample.SampleDto)41 File (java.io.File)41 TestDataCreator (de.symeda.sormas.ui.TestDataCreator)31 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)30 CasePersonDto (de.symeda.sormas.api.caze.CasePersonDto)27 ImportResultStatus (de.symeda.sormas.ui.importer.ImportResultStatus)27