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()));
}
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));
}
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()));
}
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()));
}
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;
}
Aggregations