Search in sources :

Example 11 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasEventFacadeEjbTest method testSaveSharedEventsWithSamples.

@Test
public void testSaveSharedEventsWithSamples() throws SormasToSormasException, SormasToSormasValidationException {
    FacilityDto remoteLab = FacilityDto.build();
    remoteLab.setName("Test Lab");
    FacilityDto localLab = creator.createFacility("Test Lab", rdcf.region, rdcf.district, null, FacilityType.LABORATORY);
    EventDto event = createEventDto(rdcf);
    UserDto sampleUser = UserDto.build();
    EventParticipantDto eventParticipant = createEventParticipantDto(event.toReference(), sampleUser.toReference(), rdcf);
    SampleDto sample = createSample(eventParticipant.toReference(), sampleUser.toReference(), remoteLab.toReference());
    sample.setLabSampleID("Test lab sample id");
    PathogenTestDto pathogenTest = PathogenTestDto.build(sample, sampleUser);
    pathogenTest.setTestDateTime(new Date());
    pathogenTest.setLab(remoteLab.toReference());
    pathogenTest.setTestType(PathogenTestType.RAPID_TEST);
    pathogenTest.setTestResult(PathogenTestResultType.PENDING);
    AdditionalTestDto additionalTest = AdditionalTestDto.build(sample.toReference());
    additionalTest.setTestDateTime(new Date());
    additionalTest.setHaemoglobin(0.2F);
    additionalTest.setConjBilirubin(0.3F);
    SormasToSormasDto shareData = new SormasToSormasDto();
    shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, false));
    shareData.setEvents(Collections.singletonList(new SormasToSormasEventDto(event)));
    shareData.setEventParticipants(Collections.singletonList(new SormasToSormasEventParticipantDto(eventParticipant)));
    shareData.setSamples(Collections.singletonList(new SormasToSormasSampleDto(sample, Collections.singletonList(pathogenTest), Collections.singletonList(additionalTest))));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
    getSormasToSormasEventFacade().saveSharedEntities(encryptedData);
    SampleDto savedSample = getSampleFacade().getSampleByUuid(sample.getUuid());
    assertThat(savedSample, is(notNullValue()));
    assertThat(savedSample.getAssociatedEventParticipant(), is(eventParticipant.toReference()));
    assertThat(savedSample.getSampleMaterial(), is(SampleMaterial.BLOOD));
    assertThat(savedSample.getLab(), is(localLab.toReference()));
    assertThat(savedSample.getLabSampleID(), is("Test lab sample id"));
    assertThat(savedSample.getSormasToSormasOriginInfo().getOrganizationId(), is(DEFAULT_SERVER_ID));
    assertThat(savedSample.getSormasToSormasOriginInfo().getSenderName(), is("John doe"));
    PathogenTestDto savedPathogenTest = getPathogenTestFacade().getByUuid(pathogenTest.getUuid());
    assertThat(savedPathogenTest, is(notNullValue()));
    assertThat(savedPathogenTest.getLab(), is(localLab.toReference()));
    assertThat(savedPathogenTest.getTestType(), is(PathogenTestType.RAPID_TEST));
    assertThat(savedPathogenTest.getTestResult(), is(PathogenTestResultType.PENDING));
    AdditionalTestDto savedAdditionalTest = getAdditionalTestFacade().getByUuid(additionalTest.getUuid());
    assertThat(savedAdditionalTest, is(notNullValue()));
    assertThat(savedAdditionalTest.getHaemoglobin(), is(0.2F));
    assertThat(savedAdditionalTest.getConjBilirubin(), is(0.3F));
}
Also used : SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) Date(java.util.Date) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) AdditionalTestDto(de.symeda.sormas.api.sample.AdditionalTestDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 12 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasEventFacadeEjbTest method createEventDto.

private EventDto createEventDto(TestDataCreator.RDCF rdcf) {
    EventDto eventDto = EventDto.build();
    eventDto.setEventTitle("Test event title");
    eventDto.getEventLocation().setRegion(rdcf.region);
    eventDto.getEventLocation().setDistrict(rdcf.district);
    return eventDto;
}
Also used : EventDto(de.symeda.sormas.api.event.EventDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto)

Example 13 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasEventFacadeEjbTest method testShareEventWithSamples.

@Test
public void testShareEventWithSamples() throws SormasToSormasException {
    UserDto user = creator.createUser(rdcf, UserRole.NATIONAL_USER);
    useSurveillanceOfficerLogin(rdcf);
    EventDto event = creator.createEvent(EventStatus.SCREENING, EventInvestigationStatus.ONGOING, "Test event title", "Test description", user.toReference(), (e) -> {
        e.getEventLocation().setRegion(rdcf.region);
        e.getEventLocation().setDistrict(rdcf.district);
    });
    EventParticipantDto eventParticipant = creator.createEventParticipant(event.toReference(), creator.createPerson("John", "Doe", p -> p.setBirthName("Test birth name")), "Involved", user.toReference(), (ep) -> {
        ep.setRegion(rdcf.region);
        ep.setDistrict(rdcf.district);
        ep.setVaccinationStatus(VaccinationStatus.VACCINATED);
    }, null);
    SampleDto sample = creator.createSample(eventParticipant.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
    creator.createPathogenTest(sample.toReference(), PathogenTestType.CULTURE, Disease.CORONAVIRUS, new Date(), rdcf.facility, user.toReference(), PathogenTestResultType.INDETERMINATE, "Test result", true, null);
    creator.createAdditionalTest(sample.toReference());
    SormasToSormasOptionsDto options = new SormasToSormasOptionsDto();
    options.setOrganization(new SormasServerDescriptor(SECOND_SERVER_ID));
    options.setWithEventParticipants(true);
    options.setWithSamples(true);
    options.setComment("Test comment");
    Mockito.when(MockProducer.getSormasToSormasClient().post(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(), ArgumentMatchers.any())).thenAnswer(invocation -> {
        assertThat(invocation.getArgument(0, String.class), is(SECOND_SERVER_ID));
        assertThat(invocation.getArgument(1, String.class), is("/sormasToSormas/events"));
        SormasToSormasDto postBody = invocation.getArgument(2, SormasToSormasDto.class);
        assertThat(postBody.getEvents().size(), is(1));
        List<SormasToSormasEventParticipantDto> eventParticipants = postBody.getEventParticipants();
        assertThat(eventParticipants, hasSize(1));
        List<SormasToSormasSampleDto> samples = postBody.getSamples();
        assertThat(samples, hasSize(1));
        assertThat(samples.get(0).getPathogenTests(), hasSize(1));
        assertThat(samples.get(0).getAdditionalTests(), hasSize(1));
        return Response.noContent().build();
    });
    getSormasToSormasEventFacade().share(Collections.singletonList(event.getUuid()), options);
    List<SormasToSormasShareInfoDto> shareInfoList = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().event(event.toReference()), 0, 100);
    assertThat(shareInfoList.size(), is(1));
    assertThat(shareInfoList.get(0).getTargetDescriptor().getId(), is(SECOND_SERVER_ID));
    assertThat(shareInfoList.get(0).getSender().getCaption(), is("Surv OFF - Surveillance Officer"));
    assertThat(shareInfoList.get(0).getComment(), is("Test comment"));
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers(org.mockito.ArgumentMatchers) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Date(java.util.Date) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SormasToSormasOptionsDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) PersonDto(de.symeda.sormas.api.person.PersonDto) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) Matchers.nullValue(org.hamcrest.Matchers.nullValue) EventInvestigationStatus(de.symeda.sormas.api.event.EventInvestigationStatus) UserRole(de.symeda.sormas.api.user.UserRole) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) VaccinationStatus(de.symeda.sormas.api.caze.VaccinationStatus) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) SormasToSormasShareInfoCriteria(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) EventDto(de.symeda.sormas.api.event.EventDto) RiskLevel(de.symeda.sormas.api.event.RiskLevel) SormasToSormasException(de.symeda.sormas.api.sormastosormas.SormasToSormasException) ShareTreeCriteria(de.symeda.sormas.api.sormastosormas.ShareTreeCriteria) List(java.util.List) User(de.symeda.sormas.backend.user.User) Response(javax.ws.rs.core.Response) PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) Matchers.is(org.hamcrest.Matchers.is) ShareRequestInfo(de.symeda.sormas.backend.sormastosormas.share.shareinfo.ShareRequestInfo) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) SamplePurpose(de.symeda.sormas.api.sample.SamplePurpose) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) MockProducer(de.symeda.sormas.backend.MockProducer) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) SormasToSormasValidationException(de.symeda.sormas.api.sormastosormas.validation.SormasToSormasValidationException) SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) RunWith(org.junit.runner.RunWith) AdditionalTestDto(de.symeda.sormas.api.sample.AdditionalTestDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) EventStatus(de.symeda.sormas.api.event.EventStatus) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) Calendar(java.util.Calendar) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) DataHelper(de.symeda.sormas.api.utils.DataHelper) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) SormasToSormasShareRequestDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto) UserDto(de.symeda.sormas.api.user.UserDto) Test(org.junit.Test) ShareRequestStatus(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestStatus) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) SampleMaterial(de.symeda.sormas.api.sample.SampleMaterial) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) Mockito(org.mockito.Mockito) Disease(de.symeda.sormas.api.Disease) SampleDto(de.symeda.sormas.api.sample.SampleDto) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) EventSourceType(de.symeda.sormas.api.event.EventSourceType) Collections(java.util.Collections) SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SormasToSormasShareInfoCriteria(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria) Date(java.util.Date) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) SormasToSormasOptionsDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 14 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasEventFacadeEjbTest method testSaveReturnedEvent.

@Test
public void testSaveReturnedEvent() throws SormasToSormasException, SormasToSormasValidationException {
    UserReferenceDto officer = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
    EventDto event = creator.createEvent(officer);
    EventParticipantDto eventParticipant = creator.createEventParticipant(event.toReference(), creator.createPerson(), officer);
    EventParticipantDto newEventParticipant = createEventParticipantDto(event.toReference(), UserDto.build().toReference(), rdcf);
    FacilityDto lab = creator.createFacility("Test Lab", rdcf.region, rdcf.district, null, FacilityType.LABORATORY);
    SampleDto newSample = createSample(newEventParticipant.toReference(), officer, lab.toReference());
    User officerUser = getUserService().getByReferenceDto(officer);
    ShareRequestInfo shareRequestInfo = createShareRequestInfo(officerUser, DEFAULT_SERVER_ID, true, i -> i.setEvent(getEventService().getByReferenceDto(event.toReference())));
    shareRequestInfo.setWithEventParticipants(true);
    shareRequestInfo.getShares().add(createShareInfo(DEFAULT_SERVER_ID, true, i -> i.setEventParticipant(getEventParticipantService().getByReferenceDto(eventParticipant.toReference()))));
    getShareRequestInfoService().persist(shareRequestInfo);
    event.setEventDesc("Test updated description");
    eventParticipant.getPerson().setBirthName("Test birth name");
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(event.getChangeDate());
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    event.setChangeDate(calendar.getTime());
    SormasToSormasDto shareData = new SormasToSormasDto();
    shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, true));
    shareData.setEvents(Collections.singletonList(new SormasToSormasEventDto(event)));
    shareData.setEventParticipants(Arrays.asList(new SormasToSormasEventParticipantDto(eventParticipant), new SormasToSormasEventParticipantDto(newEventParticipant)));
    shareData.setSamples(Collections.singletonList(new SormasToSormasSampleDto(newSample, Collections.emptyList(), Collections.emptyList())));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
    getSormasToSormasEventFacade().saveSharedEntities(encryptedData);
    EventDto returnedEvent = getEventFacade().getEventByUuid(event.getUuid(), false);
    assertThat(returnedEvent.getEventDesc(), is("Test updated description"));
    assertThat(returnedEvent.getReportingUser(), is(officer));
    List<SormasToSormasShareInfoDto> eventShares = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().event(event.toReference()), 0, 100);
    assertThat(eventShares.get(0).isOwnershipHandedOver(), is(false));
    assertThat(getEventParticipantFacade().getEventParticipantByUuid(eventParticipant.getUuid()).getPerson().getBirthName(), is("Test birth name"));
    List<SormasToSormasShareInfoDto> eventParticipantShares = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().eventParticipant(eventParticipant.toReference()), 0, 100);
    assertThat(eventParticipantShares.get(0).isOwnershipHandedOver(), is(false));
    EventParticipantDto returnedNewEventParticipant = getEventParticipantFacade().getEventParticipantByUuid(newEventParticipant.getUuid());
    assertThat(returnedNewEventParticipant.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(true));
    SampleDto returnedNewSample = getSampleFacade().getSampleByUuid(newSample.getUuid());
    assertThat(returnedNewSample.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(true));
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers(org.mockito.ArgumentMatchers) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Date(java.util.Date) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SormasToSormasOptionsDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) PersonDto(de.symeda.sormas.api.person.PersonDto) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) Matchers.nullValue(org.hamcrest.Matchers.nullValue) EventInvestigationStatus(de.symeda.sormas.api.event.EventInvestigationStatus) UserRole(de.symeda.sormas.api.user.UserRole) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) VaccinationStatus(de.symeda.sormas.api.caze.VaccinationStatus) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) SormasToSormasShareInfoCriteria(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) EventDto(de.symeda.sormas.api.event.EventDto) RiskLevel(de.symeda.sormas.api.event.RiskLevel) SormasToSormasException(de.symeda.sormas.api.sormastosormas.SormasToSormasException) ShareTreeCriteria(de.symeda.sormas.api.sormastosormas.ShareTreeCriteria) List(java.util.List) User(de.symeda.sormas.backend.user.User) Response(javax.ws.rs.core.Response) PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) Matchers.is(org.hamcrest.Matchers.is) ShareRequestInfo(de.symeda.sormas.backend.sormastosormas.share.shareinfo.ShareRequestInfo) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) SamplePurpose(de.symeda.sormas.api.sample.SamplePurpose) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) MockProducer(de.symeda.sormas.backend.MockProducer) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) SormasToSormasValidationException(de.symeda.sormas.api.sormastosormas.validation.SormasToSormasValidationException) SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) RunWith(org.junit.runner.RunWith) AdditionalTestDto(de.symeda.sormas.api.sample.AdditionalTestDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) EventStatus(de.symeda.sormas.api.event.EventStatus) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) Calendar(java.util.Calendar) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) DataHelper(de.symeda.sormas.api.utils.DataHelper) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) SormasToSormasShareRequestDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto) UserDto(de.symeda.sormas.api.user.UserDto) Test(org.junit.Test) ShareRequestStatus(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestStatus) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) SampleMaterial(de.symeda.sormas.api.sample.SampleMaterial) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) Mockito(org.mockito.Mockito) Disease(de.symeda.sormas.api.Disease) SampleDto(de.symeda.sormas.api.sample.SampleDto) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) EventSourceType(de.symeda.sormas.api.event.EventSourceType) Collections(java.util.Collections) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) User(de.symeda.sormas.backend.user.User) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) ShareRequestInfo(de.symeda.sormas.backend.sormastosormas.share.shareinfo.ShareRequestInfo) Calendar(java.util.Calendar) EventDto(de.symeda.sormas.api.event.EventDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SormasToSormasShareInfoCriteria(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 15 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasEventFacadeEjbTest method testSaveSharedEvents.

@Test
public void testSaveSharedEvents() throws SormasToSormasException, SormasToSormasValidationException {
    EventDto event = createEventDto(rdcf);
    event.setEventDesc("Test description");
    event.setEventStatus(EventStatus.SCREENING);
    event.setEventInvestigationStatus(EventInvestigationStatus.ONGOING);
    event.setRiskLevel(RiskLevel.MODERATE);
    event.setMultiDayEvent(true);
    Date dateNow = new Date();
    event.setStartDate(dateNow);
    event.setEndDate(dateNow);
    event.setSrcType(EventSourceType.MEDIA_NEWS);
    event.setSrcMediaWebsite("Test media name");
    event.setSrcMediaName("Test media website");
    event.setSrcMediaDetails("Test media details");
    SormasToSormasDto shareData = new SormasToSormasDto();
    shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, false));
    shareData.setEvents(Collections.singletonList(new SormasToSormasEventDto(event)));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
    getSormasToSormasEventFacade().saveSharedEntities(encryptedData);
    EventDto savedEvent = getEventFacade().getEventByUuid(event.getUuid(), false);
    assertThat(savedEvent, is(notNullValue()));
    assertThat(savedEvent.getEventTitle(), is("Test event title"));
    assertThat(savedEvent.getEventDesc(), is("Test description"));
    assertThat(savedEvent.getEventStatus(), is(EventStatus.SCREENING));
    assertThat(savedEvent.getEventInvestigationStatus(), is(EventInvestigationStatus.ONGOING));
    assertThat(savedEvent.getRiskLevel(), is(RiskLevel.MODERATE));
    assertThat(savedEvent.isMultiDayEvent(), is(true));
    assertThat(savedEvent.getStartDate().getTime(), is(dateNow.getTime()));
    assertThat(savedEvent.getEndDate().getTime(), is(dateNow.getTime()));
    assertThat(savedEvent.getSrcType(), is(EventSourceType.MEDIA_NEWS));
    assertThat(savedEvent.getSrcMediaWebsite(), is("Test media name"));
    assertThat(savedEvent.getSrcMediaName(), is("Test media website"));
    assertThat(savedEvent.getSrcMediaDetails(), is("Test media details"));
    assertThat(savedEvent.getEventLocation().getRegion(), is(rdcf.region));
    assertThat(savedEvent.getEventLocation().getDistrict(), is(rdcf.district));
    assertThat(savedEvent.getSormasToSormasOriginInfo().getOrganizationId(), is(DEFAULT_SERVER_ID));
    assertThat(savedEvent.getSormasToSormasOriginInfo().getSenderName(), is("John doe"));
}
Also used : SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) EventDto(de.symeda.sormas.api.event.EventDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) Date(java.util.Date) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Aggregations

EventDto (de.symeda.sormas.api.event.EventDto)125 Test (org.junit.Test)71 UserDto (de.symeda.sormas.api.user.UserDto)49 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)46 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)39 PersonDto (de.symeda.sormas.api.person.PersonDto)38 Date (java.util.Date)38 EventReferenceDto (de.symeda.sormas.api.event.EventReferenceDto)23 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)22 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)22 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)19 ContactDto (de.symeda.sormas.api.contact.ContactDto)17 SormasToSormasEventDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto)16 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)16 SampleDto (de.symeda.sormas.api.sample.SampleDto)14 SormasToSormasTest (de.symeda.sormas.backend.sormastosormas.SormasToSormasTest)14 List (java.util.List)13 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)11 LocalDate (java.time.LocalDate)11 EventParticipantCriteria (de.symeda.sormas.api.event.EventParticipantCriteria)10