Search in sources :

Example 1 with ExternalShareInfo

use of de.symeda.sormas.backend.share.ExternalShareInfo 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 2 with ExternalShareInfo

use of de.symeda.sormas.backend.share.ExternalShareInfo 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)

Example 3 with ExternalShareInfo

use of de.symeda.sormas.backend.share.ExternalShareInfo 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()));
}
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 4 with ExternalShareInfo

use of de.symeda.sormas.backend.share.ExternalShareInfo in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testCaseCriteriaSharedWithReportingTool.

@Test
public void testCaseCriteriaSharedWithReportingTool() {
    RDCF rdcf = creator.createRDCF();
    UserDto user = creator.createUser(rdcf, UserRole.NATIONAL_USER);
    CaseDataDto sharedCase = creator.createCase(user.toReference(), creator.createPerson().toReference(), rdcf);
    ExternalShareInfo shareInfo = new ExternalShareInfo();
    shareInfo.setCaze(getCaseService().getByUuid(sharedCase.getUuid()));
    shareInfo.setSender(getUserService().getByUuid(user.getUuid()));
    shareInfo.setStatus(ExternalShareStatus.SHARED);
    getExternalShareInfoService().ensurePersisted(shareInfo);
    CaseDataDto notSharedCase = creator.createCase(user.toReference(), creator.createPerson().toReference(), rdcf);
    CaseCriteria caseCriteriaForShared = new CaseCriteria();
    caseCriteriaForShared.setOnlyEntitiesSharedWithExternalSurvTool(true);
    List<CaseIndexDto> indexList = getCaseFacade().getIndexList(caseCriteriaForShared, 0, 100, null);
    MatcherAssert.assertThat(indexList, hasSize(1));
    MatcherAssert.assertThat(indexList.get(0).getUuid(), is(sharedCase.getUuid()));
    CaseCriteria caseCriteriaForNotShared = new CaseCriteria();
    caseCriteriaForNotShared.setOnlyEntitiesNotSharedWithExternalSurvTool(true);
    indexList = getCaseFacade().getIndexList(caseCriteriaForNotShared, 0, 100, null);
    MatcherAssert.assertThat(indexList, hasSize(1));
    MatcherAssert.assertThat(indexList.get(0).getUuid(), is(notSharedCase.getUuid()));
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) UserDto(de.symeda.sormas.api.user.UserDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) ExternalShareInfo(de.symeda.sormas.backend.share.ExternalShareInfo) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 5 with ExternalShareInfo

use of de.symeda.sormas.backend.share.ExternalShareInfo in project SORMAS-Project by hzi-braunschweig.

the class TestDataCreator method createExternalShareInfo.

public ExternalShareInfo createExternalShareInfo(EventReferenceDto event, UserReferenceDto sender, ExternalShareStatus status) {
    ExternalShareInfo shareInfo = new ExternalShareInfo();
    shareInfo.setUuid(DataHelper.createUuid());
    shareInfo.setEvent(beanTest.getEventService().getByUuid(event.getUuid()));
    shareInfo.setSender(beanTest.getUserService().getByUuid(sender.getUuid()));
    shareInfo.setStatus(status);
    beanTest.getExternalShareInfoService().ensurePersisted(shareInfo);
    return shareInfo;
}
Also used : ExternalShareInfo(de.symeda.sormas.backend.share.ExternalShareInfo)

Aggregations

ExternalShareInfo (de.symeda.sormas.backend.share.ExternalShareInfo)8 UserDto (de.symeda.sormas.api.user.UserDto)6 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)6 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)6 Test (org.junit.Test)6 CaseCriteria (de.symeda.sormas.api.caze.CaseCriteria)3 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)3 CaseIndexDto (de.symeda.sormas.api.caze.CaseIndexDto)3 EventCriteria (de.symeda.sormas.api.event.EventCriteria)3 EventDto (de.symeda.sormas.api.event.EventDto)3 EventIndexDto (de.symeda.sormas.api.event.EventIndexDto)3