use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testGetNonSourceCaseCountForDashboard.
@Test
public void testGetNonSourceCaseCountForDashboard() {
ContactFacade cut = getBean(ContactFacadeEjbLocal.class);
RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto person = creator.createPerson("Case", "Person");
Disease disease = Disease.OTHER;
// 1. A case not resulted of a contact: 0
CaseDataDto caseWithoutContact = creator.createCase(user.toReference(), person.toReference(), disease, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
assertThat(cut.getNonSourceCaseCountForDashboard(Collections.singletonList(caseWithoutContact.getUuid())), equalTo(0));
// 2. Another case, but created from a contact: 1
ContactDto contact = creator.createContact(user.toReference(), person.toReference(), disease);
CaseDataDto caseWithContact = creator.createCase(user.toReference(), person.toReference(), disease, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
contact.setResultingCase(caseWithContact.toReference());
contact = getContactFacade().save(contact);
assertThat(cut.getNonSourceCaseCountForDashboard(Arrays.asList(caseWithoutContact.getUuid(), caseWithContact.getUuid())), equalTo(1));
// 3. Some more cases
{
CaseDataDto caseWithoutContact2 = creator.createCase(user.toReference(), person.toReference(), disease, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
ContactDto contact2 = creator.createContact(user.toReference(), person.toReference(), disease);
CaseDataDto caseWithContact2 = creator.createCase(user.toReference(), person.toReference(), disease, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
contact2.setResultingCase(caseWithContact2.toReference());
contact2 = getContactFacade().save(contact2);
ContactDto contact3 = creator.createContact(user.toReference(), person.toReference(), disease);
CaseDataDto caseWithContact3 = creator.createCase(user.toReference(), person.toReference(), disease, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
contact3.setResultingCase(caseWithContact3.toReference());
contact3 = getContactFacade().save(contact3);
assertThat(cut.getNonSourceCaseCountForDashboard(Arrays.asList(caseWithoutContact.getUuid(), caseWithContact.getUuid(), caseWithoutContact2.getUuid(), caseWithContact2.getUuid(), caseWithContact3.getUuid())), equalTo(3));
}
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testGetIndexList.
@Test
public void testGetIndexList() {
RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
creator.createEvent(EventStatus.SIGNAL, EventInvestigationStatus.PENDING, "TitleEv1", "DescriptionEv1", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 1), new Date(), user.toReference(), user.toReference(), Disease.EVD, rdcf.district);
creator.createEvent(EventStatus.EVENT, EventInvestigationStatus.PENDING, "TitleEv2", "DescriptionEv2", "First", "Name", "12345", TypeOfPlace.FACILITY, DateHelper.subtractDays(new Date(), 1), new Date(), user.toReference(), user.toReference(), Disease.EVD, rdcf.district);
EventCriteria eventCriteria = new EventCriteria();
List<EventIndexDto> results = getEventFacade().getIndexList(eventCriteria, 0, 100, null);
assertEquals(2, results.size());
eventCriteria.eventStatus(EventStatus.SIGNAL);
results = getEventFacade().getIndexList(eventCriteria, 0, 100, null);
assertEquals(1, results.size());
assertEquals("TitleEv1", results.get(0).getEventTitle());
eventCriteria.eventStatus(null);
eventCriteria.setTypeOfPlace(TypeOfPlace.FACILITY);
results = getEventFacade().getIndexList(eventCriteria, 0, 100, null);
assertEquals(1, results.size());
assertEquals("TitleEv2", results.get(0).getEventTitle());
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testEventCriteriaChangedSinceLastShareWithReportingTool.
@Test
public void testEventCriteriaChangedSinceLastShareWithReportingTool() {
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, UserRole.NATIONAL_USER);
EventDto sharedEvent = creator.createEvent(user.toReference());
ExternalShareInfo shareInfo = new ExternalShareInfo();
shareInfo.setCreationDate(Timestamp.valueOf(LocalDateTime.of(2021, Month.APRIL, 20, 12, 31)));
shareInfo.setEvent(getEventService().getByUuid(sharedEvent.getUuid()));
shareInfo.setSender(getUserService().getByUuid(user.getUuid()));
shareInfo.setStatus(ExternalShareStatus.DELETED);
getExternalShareInfoService().ensurePersisted(shareInfo);
sharedEvent.setEventDesc("Dummy description");
getEventFacade().save(sharedEvent);
creator.createEvent(user.toReference());
creator.createEvent(user.toReference());
EventCriteria eventCriteriaForShared = new EventCriteria();
eventCriteriaForShared.setOnlyEntitiesChangedSinceLastSharedWithExternalSurvTool(true);
List<EventIndexDto> indexList = getEventFacade().getIndexList(eventCriteriaForShared, 0, 100, null);
MatcherAssert.assertThat(indexList, hasSize(1));
MatcherAssert.assertThat(indexList.get(0).getUuid(), is(sharedEvent.getUuid()));
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testEventDeletion.
@Test
public void testEventDeletion() throws ExternalSurveillanceToolException {
Date since = new Date();
RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
UserDto admin = getUserFacade().getByUserName("admin");
EventDto event = creator.createEvent(EventStatus.SIGNAL, EventInvestigationStatus.PENDING, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 1), new Date(), user.toReference(), user.toReference(), Disease.EVD, rdcf.district);
PersonDto eventPerson = creator.createPerson("Event", "Person");
EventParticipantDto eventParticipant = creator.createEventParticipant(event.toReference(), eventPerson, "Description", user.toReference());
ActionDto action = creator.createAction(event.toReference());
// Database should contain the created event and event participant
assertNotNull(getEventFacade().getEventByUuid(event.getUuid(), false));
assertNotNull(getEventParticipantFacade().getEventParticipantByUuid(eventParticipant.getUuid()));
assertNotNull(getActionFacade().getByUuid(action.getUuid()));
getEventFacade().deleteEvent(event.getUuid());
// Event should be marked as deleted; Event participant should be deleted
assertTrue(getEventFacade().getDeletedUuidsSince(since).contains(event.getUuid()));
assertTrue(getEventParticipantFacade().getDeletedUuidsSince(since).contains(eventParticipant.getUuid()));
assertNull(getActionFacade().getByUuid(action.getUuid()));
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testEventUpdate.
@Test
public void testEventUpdate() {
RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
UserDto admin = getUserFacade().getByUserName("admin");
EventDto event = creator.createEvent(EventStatus.SIGNAL, EventInvestigationStatus.PENDING, "Title", null, "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, null, new Date(), user.toReference(), user.toReference(), Disease.EVD, rdcf.district);
final String testDescription = "testDescription";
final Date startDate = DateHelper.subtractDays(new Date(), 1);
event.setEventDesc(testDescription);
event.setStartDate(startDate);
final EventDto updatedEvent = getEventFacade().save(event);
Assert.assertEquals(testDescription, updatedEvent.getEventDesc());
Assert.assertEquals(startDate, updatedEvent.getStartDate());
}
Aggregations