Search in sources :

Example 6 with SormasToSormasEventDto

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

the class SormasToSormasEventFacadeEjbTest method testShareEvent.

@Test
public void testShareEvent() throws SormasToSormasException {
    UserDto user = creator.createUser(rdcf, UserRole.NATIONAL_USER);
    useSurveillanceOfficerLogin(rdcf);
    Date dateNow = new Date();
    EventDto event = creator.createEvent(EventStatus.SCREENING, EventInvestigationStatus.ONGOING, "Test event title", "Test description", user.toReference(), (e) -> {
        e.setRiskLevel(RiskLevel.MODERATE);
        e.setMultiDayEvent(true);
        e.setStartDate(dateNow);
        e.setEndDate(dateNow);
        e.setSrcType(EventSourceType.MEDIA_NEWS);
        e.setSrcMediaWebsite("Test media name");
        e.setSrcMediaName("Test media website");
        e.setSrcMediaDetails("Test media details");
        e.getEventLocation().setRegion(rdcf.region);
        e.getEventLocation().setDistrict(rdcf.district);
    });
    SormasToSormasOptionsDto options = new SormasToSormasOptionsDto();
    options.setOrganization(new SormasServerDescriptor(SECOND_SERVER_ID));
    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));
        SormasToSormasEventDto sharedEventData = postBody.getEvents().get(0);
        EventDto sharedEvent = sharedEventData.getEntity();
        assertThat(sharedEvent.getEventTitle(), is("Test event title"));
        assertThat(sharedEvent.getEventDesc(), is("Test description"));
        assertThat(sharedEvent.getEventStatus(), is(EventStatus.SCREENING));
        assertThat(sharedEvent.getEventInvestigationStatus(), is(EventInvestigationStatus.ONGOING));
        assertThat(sharedEvent.getRiskLevel(), is(RiskLevel.MODERATE));
        assertThat(sharedEvent.isMultiDayEvent(), is(true));
        assertThat(sharedEvent.getStartDate().getTime(), is(dateNow.getTime()));
        assertThat(sharedEvent.getEndDate().getTime(), is(dateNow.getTime()));
        assertThat(sharedEvent.getSrcType(), is(EventSourceType.MEDIA_NEWS));
        assertThat(sharedEvent.getSrcMediaWebsite(), is("Test media name"));
        assertThat(sharedEvent.getSrcMediaName(), is("Test media website"));
        assertThat(sharedEvent.getSrcMediaDetails(), is("Test media details"));
        // share information
        assertThat(postBody.getOriginInfo().getOrganizationId(), is(DEFAULT_SERVER_ID));
        assertThat(postBody.getOriginInfo().getSenderName(), is("Surv Off"));
        assertThat(postBody.getOriginInfo().getComment(), is("Test comment"));
        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 : SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) 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) SormasToSormasOptionsDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto) SormasToSormasShareInfoCriteria(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria) Date(java.util.Date) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 7 with SormasToSormasEventDto

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

the class InfraValidationSoundnessTest method testShareEventValidation.

@Test
public void testShareEventValidation() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchFieldException {
    class EventDtoRootNode extends DtoRootNode<SormasToSormasEventDto> {

        public EventDtoRootNode(SormasToSormasEventDto dtoUnderTest) {
            super(dtoUnderTest);
        }
    }
    class EventPreviewRootNode extends DtoRootNode<SormasToSormasEventPreview> {

        public EventPreviewRootNode(SormasToSormasEventPreview dtoUnderTest) {
            super(dtoUnderTest);
        }
    }
    before();
    SormasToSormasEventDto eventDto = new SormasToSormasEventDto();
    EventDtoRootNode rootNode = new EventDtoRootNode(eventDto);
    assertValidationDto(eventDto, rootNode, eventDtoValidator);
    SormasToSormasEventPreview eventPreview = new SormasToSormasEventPreview();
    EventPreviewRootNode previewRootNode = new EventPreviewRootNode(eventPreview);
    assertValidationPreview(eventPreview, previewRootNode, eventDtoValidator);
}
Also used : SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) SormasToSormasEventPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 8 with SormasToSormasEventDto

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

the class ProcessedEventDataPersister method persistSharedData.

@Override
public void persistSharedData(SormasToSormasEventDto processedData, Event existingEvent) throws SormasToSormasValidationException {
    EventDto event = processedData.getEntity();
    handleValidationError(() -> eventFacade.save(event, false, false), Captions.CaseData, buildCaseValidationGroupName(event));
}
Also used : SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) EventDto(de.symeda.sormas.api.event.EventDto)

Example 9 with SormasToSormasEventDto

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

the class SormasToSormasEventDtoValidator method validate.

@Override
public ValidationErrors validate(SormasToSormasEventDto sharedData, ValidationDirection direction) {
    EventDto event = sharedData.getEntity();
    ValidationErrors validationErrors = new ValidationErrors(buildEventValidationGroupName(event));
    validateLocation(event.getEventLocation(), Captions.Event, validationErrors, direction);
    return validationErrors;
}
Also used : ValidationErrors(de.symeda.sormas.api.sormastosormas.validation.ValidationErrors) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) EventDto(de.symeda.sormas.api.event.EventDto)

Example 10 with SormasToSormasEventDto

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

the class SormasToSormasEventFacadeEjbTest method testSaveSyncedEvent.

@Test
public void testSaveSyncedEvent() throws SormasToSormasException, SormasToSormasValidationException {
    UserReferenceDto officer = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
    EventDto event = creator.createEvent(EventStatus.SCREENING, EventInvestigationStatus.ONGOING, "Test event title", "Test description", officer, e -> {
        SormasToSormasOriginInfoDto originInfo = new SormasToSormasOriginInfoDto();
        originInfo.setSenderName("Test Name");
        originInfo.setSenderEmail("test@email.com");
        originInfo.setOrganizationId(DEFAULT_SERVER_ID);
        originInfo.setOwnershipHandedOver(false);
        e.setSormasToSormasOriginInfo(originInfo);
    });
    EventParticipantDto eventParticipant = creator.createEventParticipant(event.toReference(), creator.createPerson(), "Involved", officer, (ep) -> ep.setSormasToSormasOriginInfo(event.getSormasToSormasOriginInfo()), null);
    EventParticipantDto newEventParticipant = createEventParticipantDto(event.toReference(), UserDto.build().toReference(), rdcf);
    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, false));
    shareData.setEvents(Collections.singletonList(new SormasToSormasEventDto(event)));
    shareData.setEventParticipants(Arrays.asList(new SormasToSormasEventParticipantDto(eventParticipant), new SormasToSormasEventParticipantDto(newEventParticipant)));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(new SyncDataDto(shareData, new ShareTreeCriteria(event.getUuid(), null, false)));
    getSormasToSormasEventFacade().saveSyncedEntity(encryptedData);
    EventDto syncedEvent = getEventFacade().getEventByUuid(event.getUuid(), false);
    assertThat(syncedEvent.getEventDesc(), is("Test updated description"));
    assertThat(syncedEvent.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(false));
    EventParticipantDto syncedEventParticipant = getEventParticipantFacade().getEventParticipantByUuid(eventParticipant.getUuid());
    assertThat(syncedEventParticipant.getPerson().getBirthName(), is("Test birth name"));
    assertThat(syncedEventParticipant.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(false));
    EventParticipantDto returnedNewEventParticipant = getEventParticipantFacade().getEventParticipantByUuid(newEventParticipant.getUuid());
    assertThat(returnedNewEventParticipant.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(false));
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) ShareTreeCriteria(de.symeda.sormas.api.sormastosormas.ShareTreeCriteria) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) 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) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Aggregations

SormasToSormasEventDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto)16 EventDto (de.symeda.sormas.api.event.EventDto)11 SormasToSormasEventParticipantDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto)9 SormasToSormasDto (de.symeda.sormas.api.sormastosormas.SormasToSormasDto)8 Test (org.junit.Test)8 SormasToSormasSampleDto (de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto)7 SormasToSormasTest (de.symeda.sormas.backend.sormastosormas.SormasToSormasTest)7 SormasToSormasEncryptedDataDto (de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto)6 Date (java.util.Date)6 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)5 SormasToSormasOriginInfoDto (de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto)4 SormasToSormasCaseDto (de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto)4 SormasToSormasContactDto (de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto)4 SormasToSormasImmunizationDto (de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto)4 FacilityDto (de.symeda.sormas.api.infrastructure.facility.FacilityDto)3 AdditionalTestDto (de.symeda.sormas.api.sample.AdditionalTestDto)3 PathogenTestDto (de.symeda.sormas.api.sample.PathogenTestDto)3 SampleDto (de.symeda.sormas.api.sample.SampleDto)3 ShareTreeCriteria (de.symeda.sormas.api.sormastosormas.ShareTreeCriteria)3 SormasServerDescriptor (de.symeda.sormas.api.sormastosormas.SormasServerDescriptor)3