Search in sources :

Example 31 with RDCF

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()));
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 32 with RDCF

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());
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 33 with RDCF

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));
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) UserDto(de.symeda.sormas.api.user.UserDto) EventCriteria(de.symeda.sormas.api.event.EventCriteria) EventExportDto(de.symeda.sormas.api.event.EventExportDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 34 with RDCF

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()));
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) ExternalShareInfo(de.symeda.sormas.backend.share.ExternalShareInfo) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) EventCriteria(de.symeda.sormas.api.event.EventCriteria) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 35 with RDCF

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));
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) ExternalShareInfo(de.symeda.sormas.backend.share.ExternalShareInfo) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) EventCriteria(de.symeda.sormas.api.event.EventCriteria) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)75 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)74 Test (org.junit.Test)74 UserDto (de.symeda.sormas.api.user.UserDto)53 Date (java.util.Date)43 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)42 PersonDto (de.symeda.sormas.api.person.PersonDto)33 LocalDate (java.time.LocalDate)33 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)19 EventDto (de.symeda.sormas.api.event.EventDto)18 ContactDto (de.symeda.sormas.api.contact.ContactDto)17 CasePersonDto (de.symeda.sormas.api.caze.CasePersonDto)13 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)12 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)11 CaseCriteria (de.symeda.sormas.api.caze.CaseCriteria)10 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)10 TaskDto (de.symeda.sormas.api.task.TaskDto)9 CaseIndexDto (de.symeda.sormas.api.caze.CaseIndexDto)8 MapContactDto (de.symeda.sormas.api.contact.MapContactDto)8 SimilarContactDto (de.symeda.sormas.api.contact.SimilarContactDto)8