use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitFacadeEjbTest method testGetAllActiveUuids.
@Test
public void testGetAllActiveUuids() throws ExternalSurveillanceToolException {
TestDataCreator.RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto person = creator.createPerson();
PersonDto person2 = creator.createPerson();
PersonDto person3 = creator.createPerson();
PersonDto person4 = creator.createPerson();
PersonDto person5 = creator.createPerson();
// contacts
creator.createContact(user.toReference(), person.toReference());
creator.createContact(user.toReference(), person5.toReference());
ContactDto deletedContact = creator.createContact(user.toReference(), person2.toReference());
getContactFacade().deleteContact(deletedContact.getUuid());
// cases
creator.createCase(user.toReference(), person.toReference(), rdcf);
creator.createCase(user.toReference(), person3.toReference(), rdcf);
CaseDataDto deletedCase = creator.createCase(user.toReference(), person4.toReference(), rdcf);
getCaseFacade().deleteCase(deletedCase.getUuid());
// Attached to case and contact
creator.createVisit(person.toReference());
// Attached to contact only
creator.createVisit(person5.toReference());
// Attached to case only
creator.createVisit(person3.toReference());
VisitDto visitOfDeletedContact = creator.createVisit(person2.toReference());
VisitDto visitOfDeletedCase = creator.createVisit(person4.toReference());
List<String> visitUuids = getVisitFacade().getAllActiveUuids();
assertThat(visitUuids, hasSize(3));
assertThat(visitUuids, not(contains(visitOfDeletedContact.getUuid())));
assertThat(visitUuids, not(contains(visitOfDeletedCase.getUuid())));
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitFacadeEjbTest method testGetLastVisitByCase.
@Test
public void testGetLastVisitByCase() {
UserDto user = creator.createUser(creator.createRDCF(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto person = creator.createPerson();
CaseDataDto caze = creator.createCase(user.toReference(), person.toReference(), creator.createRDCF());
VisitDto visit = creator.createVisit(Disease.EVD, person.toReference(), new Date());
creator.createVisit(Disease.EVD, person.toReference(), DateHelper.subtractDays(new Date(), 1));
assertThat(getVisitFacade().getLastVisitByCase(caze.toReference()), is(visit));
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitFacadeEjbTest method testGetAllActiveVisitsAfter.
@Test
public void testGetAllActiveVisitsAfter() throws InterruptedException, ExternalSurveillanceToolException {
TestDataCreator.RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
Date date = new Date();
PersonDto person = creator.createPerson();
PersonDto person2 = creator.createPerson();
PersonDto person3 = creator.createPerson();
PersonDto person4 = creator.createPerson();
PersonDto person5 = creator.createPerson();
creator.createContact(user.toReference(), person.toReference());
creator.createContact(user.toReference(), person3.toReference());
ContactDto deletedContact = creator.createContact(user.toReference(), person2.toReference());
getContactFacade().deleteContact(deletedContact.getUuid());
creator.createCase(user.toReference(), person3.toReference(), rdcf);
creator.createCase(user.toReference(), person4.toReference(), rdcf);
CaseDataDto deletedCaseDto = creator.createCase(user.toReference(), person5.toReference(), rdcf);
getCaseFacade().deleteCase(deletedCaseDto.getUuid());
creator.createVisit(person.toReference());
creator.createVisit(person3.toReference());
VisitDto visitOfPureCase = creator.createVisit(person4.toReference());
VisitDto visitWithChanges = creator.createVisit(person.toReference());
VisitDto visitOfDeletedContact = creator.createVisit(person2.toReference());
VisitDto visitOfDeletedCase = creator.createVisit(person5.toReference());
List<VisitDto> visits = getVisitFacade().getAllActiveVisitsAfter(date);
assertThat(visits, hasSize(3));
// TODO change once visits are synchronized to app
assertThat(visits, not(contains(visitOfPureCase)));
assertThat(visits, not(contains(visitOfDeletedContact)));
assertThat(visits, not(contains(visitOfDeletedCase)));
List<VisitDto> visitsBatched = getVisitFacade().getAllActiveVisitsAfter(date, 2, null);
assertThat(visitsBatched, hasSize(2));
assertTrue(visitsBatched.get(0).getChangeDate().getTime() <= visitsBatched.get(1).getChangeDate().getTime());
date = new Date();
TimeUnit.MILLISECONDS.sleep(1);
visitWithChanges.getSymptoms().setAbdominalPain(SymptomState.YES);
visitWithChanges = getVisitFacade().saveVisit(visitWithChanges);
visits = getVisitFacade().getAllActiveVisitsAfter(date);
assertThat(visits, hasSize(1));
assertThat(visits, contains(visitWithChanges));
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitFacadeEjbTest method testGetIndexList.
@Test
public void testGetIndexList() {
UserDto user = creator.createUser(creator.createRDCF(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto person = creator.createPerson();
PersonDto person2 = creator.createPerson();
PersonDto person3 = creator.createPerson();
PersonDto person4 = creator.createPerson();
PersonDto person5 = creator.createPerson();
ContactDto contact = creator.createContact(user.toReference(), person.toReference());
creator.createContact(user.toReference(), person2.toReference());
ContactDto contact2 = creator.createContact(user.toReference(), person3.toReference());
CaseDataDto caze = creator.createCase(user.toReference(), person5.toReference(), creator.createRDCF());
creator.createCase(user.toReference(), person4.toReference(), creator.createRDCF());
CaseDataDto caze2 = creator.createCase(user.toReference(), person3.toReference(), creator.createRDCF());
creator.createVisit(person.toReference());
creator.createVisit(person.toReference());
creator.createVisit(person3.toReference());
creator.createVisit(person3.toReference());
creator.createVisit(person3.toReference());
creator.createVisit(person5.toReference());
VisitDto otherVisit = creator.createVisit(person2.toReference());
VisitDto otherVisit2 = creator.createVisit(person4.toReference());
List<VisitIndexDto> indexVisits = getVisitFacade().getIndexList(new VisitCriteria().contact(contact.toReference()), null, null, null);
assertThat(indexVisits, hasSize(2));
assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit.getUuid())));
assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit2.getUuid())));
indexVisits = getVisitFacade().getIndexList(new VisitCriteria().caze(caze.toReference()), null, null, null);
assertThat(indexVisits, hasSize(1));
assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit.getUuid())));
assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit2.getUuid())));
indexVisits = getVisitFacade().getIndexList(new VisitCriteria().contact(contact2.toReference()), null, null, null);
assertThat(indexVisits, hasSize(3));
assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit.getUuid())));
assertThat(indexVisits.stream().map(v -> v.getUuid()).collect(Collectors.toList()), not(contains(otherVisit2.getUuid())));
List<VisitIndexDto> indexVisits2 = getVisitFacade().getIndexList(new VisitCriteria().caze(caze2.toReference()), null, null, null);
assertEquals(indexVisits.size(), indexVisits2.size());
for (int i = 0; i < indexVisits.size(); ++i) {
assertEquals(indexVisits.get(i).getUuid(), indexVisits2.get(i).getUuid());
}
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitFacadeEjbPseudonymizationTest method testGetVisitInJurisdiction.
@Test
public void testGetVisitInJurisdiction() {
VisitDto visit = createVisit(user2, person).visit;
assertNotPseudonymized(getVisitFacade().getVisitByUuid(visit.getUuid()));
}
Aggregations