use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testGetSubordinateEventUuids.
@Test
public void testGetSubordinateEventUuids() {
RDCF rdcf = creator.createRDCF();
UserDto reportingUser = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER);
EventDto event1 = creator.createEvent(reportingUser.toReference());
EventDto event2 = creator.createEvent(reportingUser.toReference());
EventDto subordinateEvent_1_1 = creator.createEvent(EventStatus.CLUSTER, EventInvestigationStatus.ONGOING, "Sub event 1.1", null, reportingUser.toReference(), (e) -> {
e.setSuperordinateEvent(event1.toReference());
});
EventDto subordinateEvent_1_2 = creator.createEvent(EventStatus.CLUSTER, EventInvestigationStatus.ONGOING, "Sub event 1.2", null, reportingUser.toReference(), (e) -> {
e.setSuperordinateEvent(event1.toReference());
});
EventDto subordinateEvent_2_1 = creator.createEvent(EventStatus.CLUSTER, EventInvestigationStatus.ONGOING, "Sub event 2.1", null, reportingUser.toReference(), (e) -> {
e.setSuperordinateEvent(event2.toReference());
});
List<String> subordinateEventUuids = getEventFacade().getSubordinateEventUuids(Arrays.asList(event1.getUuid()));
MatcherAssert.assertThat(subordinateEventUuids.toArray(new String[] {}), Matchers.arrayContainingInAnyOrder(subordinateEvent_1_1.getUuid(), subordinateEvent_1_2.getUuid()));
subordinateEventUuids = getEventFacade().getSubordinateEventUuids(Arrays.asList(event1.getUuid(), event2.getUuid()));
MatcherAssert.assertThat(subordinateEventUuids.toArray(new String[] {}), Matchers.arrayContainingInAnyOrder(subordinateEvent_1_1.getUuid(), subordinateEvent_1_2.getUuid(), subordinateEvent_2_1.getUuid()));
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testArchiveOrDearchiveEvent.
@Test
public void testArchiveOrDearchiveEvent() {
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);
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");
creator.createEventParticipant(event.toReference(), eventPerson, "Description", user.toReference());
Date testStartDate = new Date();
// getAllActiveEvents/getAllActiveEventParticipants and getAllUuids should return length 1
assertEquals(1, getEventFacade().getAllAfter(null).size());
assertEquals(1, getEventFacade().getAllActiveUuids().size());
assertEquals(1, getEventParticipantFacade().getAllActiveEventParticipantsAfter(null).size());
assertEquals(1, getEventParticipantFacade().getAllActiveUuids().size());
getEventFacade().archive(event.getUuid(), null);
// getAllActiveEvents/getAllActiveEventParticipants and getAllUuids should return length 0
assertEquals(0, getEventFacade().getAllAfter(null).size());
assertEquals(0, getEventFacade().getAllActiveUuids().size());
assertEquals(0, getEventParticipantFacade().getAllActiveEventParticipantsAfter(null).size());
assertEquals(0, getEventParticipantFacade().getAllActiveUuids().size());
// getArchivedUuidsSince should return length 1
assertEquals(1, getEventFacade().getArchivedUuidsSince(testStartDate).size());
getEventFacade().dearchive(Collections.singletonList(event.getUuid()), null);
// getAllActiveEvents/getAllActiveEventParticipants and getAllUuids should return length 1
assertEquals(1, getEventFacade().getAllAfter(null).size());
assertEquals(1, getEventFacade().getAllActiveUuids().size());
assertEquals(1, getEventParticipantFacade().getAllActiveEventParticipantsAfter(null).size());
assertEquals(1, getEventParticipantFacade().getAllActiveUuids().size());
// getArchivedUuidsSince should return length 0
assertEquals(0, getEventFacade().getArchivedUuidsSince(testStartDate).size());
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testGetExportList.
@Test
public void testGetExportList() {
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, UserRole.SURVEILLANCE_SUPERVISOR);
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);
EventCriteria eventCriteria = new EventCriteria();
eventCriteria.setDisease(Disease.EVD);
List<EventExportDto> results = getEventFacade().getExportList(eventCriteria, Collections.emptySet(), 0, 100);
// List should have one entry
assertThat(results, Matchers.hasSize(1));
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testEventCriteriaSharedWithReportingTool.
@Test
public void testEventCriteriaSharedWithReportingTool() {
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, UserRole.NATIONAL_USER);
EventDto sharedEvent = creator.createEvent(user.toReference());
ExternalShareInfo shareInfo = new ExternalShareInfo();
shareInfo.setEvent(getEventService().getByUuid(sharedEvent.getUuid()));
shareInfo.setSender(getUserService().getByUuid(user.getUuid()));
shareInfo.setStatus(ExternalShareStatus.SHARED);
getExternalShareInfoService().ensurePersisted(shareInfo);
EventDto notSharedEvent = creator.createEvent(user.toReference());
;
EventCriteria eventCriteriaForShared = new EventCriteria();
eventCriteriaForShared.setOnlyEntitiesSharedWithExternalSurvTool(true);
List<EventIndexDto> indexList = getEventFacade().getIndexList(eventCriteriaForShared, 0, 100, null);
MatcherAssert.assertThat(indexList, hasSize(1));
MatcherAssert.assertThat(indexList.get(0).getUuid(), is(sharedEvent.getUuid()));
EventCriteria eventCriteriaForNotShared = new EventCriteria();
eventCriteriaForNotShared.setOnlyEntitiesNotSharedWithExternalSurvTool(true);
indexList = getEventFacade().getIndexList(eventCriteriaForNotShared, 0, 100, null);
MatcherAssert.assertThat(indexList, hasSize(1));
MatcherAssert.assertThat(indexList.get(0).getUuid(), is(notSharedEvent.getUuid()));
}
use of de.symeda.sormas.backend.TestDataCreator.RDCF in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testEventCriteriaLastShareWithReportingToolBetweenDates.
@Test
public void testEventCriteriaLastShareWithReportingToolBetweenDates() {
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, UserRole.NATIONAL_USER);
EventDto sharedEvent = creator.createEvent(user.toReference());
ExternalShareInfo shareInfoMarch = new ExternalShareInfo();
shareInfoMarch.setCreationDate(Timestamp.valueOf(LocalDateTime.of(2021, Month.MARCH, 20, 12, 31)));
shareInfoMarch.setEvent(getEventService().getByUuid(sharedEvent.getUuid()));
shareInfoMarch.setSender(getUserService().getByUuid(user.getUuid()));
shareInfoMarch.setStatus(ExternalShareStatus.SHARED);
getExternalShareInfoService().ensurePersisted(shareInfoMarch);
ExternalShareInfo shareInfoApril = new ExternalShareInfo();
shareInfoApril.setCreationDate(Timestamp.valueOf(LocalDateTime.of(2021, Month.APRIL, 20, 12, 31)));
shareInfoApril.setEvent(getEventService().getByUuid(sharedEvent.getUuid()));
shareInfoApril.setSender(getUserService().getByUuid(user.getUuid()));
shareInfoApril.setStatus(ExternalShareStatus.DELETED);
getExternalShareInfoService().ensurePersisted(shareInfoApril);
creator.createEvent(user.toReference());
creator.createEvent(user.toReference());
EventCriteria eventCriteria = new EventCriteria();
eventCriteria.setEventDateType(ExternalShareDateType.LAST_EXTERNAL_SURVEILLANCE_TOOL_SHARE);
eventCriteria.eventDateBetween(Date.from(LocalDateTime.of(2021, Month.APRIL, 18, 12, 31).atZone(ZoneId.systemDefault()).toInstant()), Date.from(LocalDateTime.of(2021, Month.APRIL, 21, 12, 31).atZone(ZoneId.systemDefault()).toInstant()), ExternalShareDateType.LAST_EXTERNAL_SURVEILLANCE_TOOL_SHARE, DateFilterOption.DATE);
List<EventIndexDto> indexList = getEventFacade().getIndexList(eventCriteria, 0, 100, null);
MatcherAssert.assertThat(indexList, hasSize(1));
MatcherAssert.assertThat(indexList.get(0).getUuid(), is(sharedEvent.getUuid()));
// range before last share
eventCriteria.eventDateBetween(Date.from(LocalDateTime.of(2021, Month.MARCH, 10, 12, 31).atZone(ZoneId.systemDefault()).toInstant()), Date.from(LocalDateTime.of(2021, Month.APRIL, 19, 10, 31).atZone(ZoneId.systemDefault()).toInstant()), ExternalShareDateType.LAST_EXTERNAL_SURVEILLANCE_TOOL_SHARE, DateFilterOption.DATE);
indexList = getEventFacade().getIndexList(eventCriteria, 0, 100, null);
MatcherAssert.assertThat(indexList, hasSize(0));
// range after last share
eventCriteria.eventDateBetween(Date.from(LocalDateTime.of(2021, Month.APRIL, 21, 12, 31).atZone(ZoneId.systemDefault()).toInstant()), Date.from(LocalDateTime.of(2021, Month.APRIL, 25, 10, 31).atZone(ZoneId.systemDefault()).toInstant()), ExternalShareDateType.LAST_EXTERNAL_SURVEILLANCE_TOOL_SHARE, DateFilterOption.DATE);
indexList = getEventFacade().getIndexList(eventCriteria, 0, 100, null);
MatcherAssert.assertThat(indexList, hasSize(0));
}
Aggregations