Search in sources :

Example 11 with SormasToSormasOriginInfoDto

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

the class SormasToSormasCaseFacadeEjbTest method testReturnCase.

@Test
public void testReturnCase() throws SormasToSormasException {
    useSurveillanceOfficerLogin(rdcf);
    PersonDto person = creator.createPerson();
    UserReferenceDto officer = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
    CaseDataDto caze = creator.createCase(officer, rdcf, dto -> {
        dto.setPerson(person.toReference());
        dto.setSurveillanceOfficer(officer);
        dto.setClassificationUser(officer);
        SormasToSormasOriginInfoDto originInfo = new SormasToSormasOriginInfoDto();
        originInfo.setSenderName("Test Name");
        originInfo.setSenderEmail("test@email.com");
        originInfo.setOrganizationId(DEFAULT_SERVER_ID);
        originInfo.setOwnershipHandedOver(true);
        dto.setSormasToSormasOriginInfo(originInfo);
    });
    SormasToSormasShareRequestDto shareRequest = new SormasToSormasShareRequestDto();
    shareRequest.setUuid(DataHelper.createUuid());
    shareRequest.setOriginInfo(caze.getSormasToSormasOriginInfo());
    getSormasToSormasShareRequestFacade().saveShareRequest(shareRequest);
    ContactDto sharedContact = creator.createContact(officer, officer, creator.createPerson().toReference(), caze, new Date(), new Date(), Disease.CORONAVIRUS, rdcf, c -> c.setSormasToSormasOriginInfo(caze.getSormasToSormasOriginInfo()));
    SampleDto sharedSample = creator.createSample(caze.toReference(), officer, rdcf.facility, s -> s.setSormasToSormasOriginInfo(caze.getSormasToSormasOriginInfo()));
    SormasToSormasOptionsDto options = new SormasToSormasOptionsDto();
    options.setOrganization(new SormasServerDescriptor(SECOND_SERVER_ID));
    options.setHandOverOwnership(true);
    options.setWithAssociatedContacts(true);
    options.setWithSamples(true);
    options.setComment("Test comment");
    Mockito.when(MockProducer.getSormasToSormasClient().put(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(), ArgumentMatchers.any())).thenAnswer(invocation -> Response.noContent().build());
    getSormasToSormasCaseFacade().share(Collections.singletonList(caze.getUuid()), options);
    // case ownership should be lost
    CaseDataDto sharedCase = getCaseFacade().getCaseDataByUuid(caze.getUuid());
    assertThat(sharedCase.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(false));
    // contact ownership should be lost
    sharedContact = getContactFacade().getByUuid(sharedContact.getUuid());
    assertThat(sharedContact.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(false));
    // sample ownership should be lost
    sharedSample = getSampleFacade().getSampleByUuid(sharedSample.getUuid());
    assertThat(sharedSample.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(false));
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) SormasToSormasShareRequestDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) SormasToSormasOptionsDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Date(java.util.Date) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 12 with SormasToSormasOriginInfoDto

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

the class SormasToSormasContactFacadeEjbTest method testSyncContacts.

@Test
public void testSyncContacts() throws SormasToSormasValidationException, SormasToSormasException {
    UserReferenceDto officer = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
    PersonDto contactPerson = creator.createPerson();
    ContactDto contact = creator.createContact(officer, officer, contactPerson.toReference(), null, new Date(), new Date(), Disease.CORONAVIRUS, rdcf, c -> {
        SormasToSormasOriginInfoDto originInfo = new SormasToSormasOriginInfoDto();
        originInfo.setSenderName("Test Name");
        originInfo.setSenderEmail("test@email.com");
        originInfo.setOrganizationId(DEFAULT_SERVER_ID);
        originInfo.setWithAssociatedContacts(true);
        originInfo.setOwnershipHandedOver(true);
        c.setSormasToSormasOriginInfo(originInfo);
    });
    getShareRequestInfoService().persist(createShareRequestInfo(getUserService().getByUuid(officer.getUuid()), SECOND_SERVER_ID, false, ShareRequestStatus.ACCEPTED, i -> {
        i.setContact(getContactService().getByUuid(contact.getUuid()));
    }));
    contact.setAdditionalDetails("Test updated details");
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(contact.getChangeDate());
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    contact.setChangeDate(calendar.getTime());
    SormasToSormasDto shareData = new SormasToSormasDto();
    shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, true));
    shareData.setContacts(Collections.singletonList(new SormasToSormasContactDto(contactPerson, contact)));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(new SyncDataDto(shareData, new ShareTreeCriteria(contact.getUuid(), null, false)));
    MockProducer.getProperties().setProperty(SormasToSormasConfig.SORMAS2SORMAS_IGNORE_ADDITIONAL_DETAILS, Boolean.FALSE.toString());
    Mockito.when(MockProducer.getManagedScheduledExecutorService().schedule(ArgumentMatchers.any(Runnable.class), ArgumentMatchers.anyLong(), ArgumentMatchers.any())).then(invocation -> {
        ((Runnable) invocation.getArgument(0)).run();
        return null;
    });
    Mockito.when(MockProducer.getSormasToSormasClient().post(eq(DEFAULT_SERVER_ID), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())).then(restInvocation -> {
        SyncDataDto syncData = restInvocation.getArgument(2);
        assertThat(syncData.getCriteria().getEntityUuid(), is(contact.getUuid()));
        assertThat(syncData.getCriteria().getExceptedOrganizationId(), is(SECOND_SERVER_ID));
        assertThat(syncData.getCriteria().isForwardOnly(), is(false));
        assertThat(syncData.getShareData().getContacts().get(0).getEntity().getUuid(), is(contact.getUuid()));
        assertThat(syncData.getShareData().getContacts().get(0).getEntity().getAdditionalDetails(), is("Test updated details"));
        return Response.noContent().build();
    });
    Mockito.when(MockProducer.getSormasToSormasClient().post(eq(SECOND_SERVER_ID), ArgumentMatchers.contains("/contacts/sync"), ArgumentMatchers.any(), ArgumentMatchers.any())).then(invocation -> {
        SyncDataDto syncData = invocation.getArgument(2);
        assertThat(syncData.getCriteria().getEntityUuid(), is(contact.getUuid()));
        assertThat(syncData.getCriteria().getExceptedOrganizationId(), is(nullValue()));
        assertThat(syncData.getCriteria().isForwardOnly(), is(true));
        assertThat(syncData.getShareData().getContacts().get(0).getEntity().getUuid(), is(contact.getUuid()));
        assertThat(syncData.getShareData().getContacts().get(0).getEntity().getAdditionalDetails(), is("Test updated details"));
        return Response.noContent().build();
    });
    getSormasToSormasContactFacade().saveSyncedEntity(encryptedData);
    Mockito.verify(MockProducer.getSormasToSormasClient(), Mockito.times(1)).post(eq(DEFAULT_SERVER_ID), ArgumentMatchers.contains("/contacts/sync"), ArgumentMatchers.any(), ArgumentMatchers.any());
    Mockito.verify(MockProducer.getSormasToSormasClient(), Mockito.times(1)).post(eq(SECOND_SERVER_ID), ArgumentMatchers.contains("/contacts/sync"), ArgumentMatchers.any(), ArgumentMatchers.any());
}
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) ExposureType(de.symeda.sormas.api.exposure.ExposureType) PersonDto(de.symeda.sormas.api.person.PersonDto) Matchers.nullValue(org.hamcrest.Matchers.nullValue) UserRole(de.symeda.sormas.api.user.UserRole) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) SormasToSormasShareInfoCriteria(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) 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) ContactDto(de.symeda.sormas.api.contact.ContactDto) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) Matchers.is(org.hamcrest.Matchers.is) 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) SormasToSormasValidationException(de.symeda.sormas.api.sormastosormas.validation.SormasToSormasValidationException) SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) RunWith(org.junit.runner.RunWith) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType) QuarantineType(de.symeda.sormas.api.contact.QuarantineType) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) Calendar(java.util.Calendar) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) AnimalCondition(de.symeda.sormas.api.epidata.AnimalCondition) DataHelper(de.symeda.sormas.api.utils.DataHelper) SormasToSormasShareRequestDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto) Test(org.junit.Test) ShareRequestStatus(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestStatus) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) SormasToSormasConfig(de.symeda.sormas.api.sormastosormas.SormasToSormasConfig) SampleMaterial(de.symeda.sormas.api.sample.SampleMaterial) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) Mockito(org.mockito.Mockito) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) Disease(de.symeda.sormas.api.Disease) SampleDto(de.symeda.sormas.api.sample.SampleDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) Collections(java.util.Collections) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) ShareTreeCriteria(de.symeda.sormas.api.sormastosormas.ShareTreeCriteria) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) PersonDto(de.symeda.sormas.api.person.PersonDto) Calendar(java.util.Calendar) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) Date(java.util.Date) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 13 with SormasToSormasOriginInfoDto

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

the class SormasToSormasCaseFacadeEjbTest method testGetAllSharesOnMiddleLevel.

@Test
public void testGetAllSharesOnMiddleLevel() throws SormasToSormasException {
    useSurveillanceOfficerLogin(rdcf);
    UserReferenceDto officer = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
    CaseDataDto caze = creator.createCase(officer, creator.createPerson().toReference(), rdcf, c -> {
        SormasToSormasOriginInfoDto originInfo = new SormasToSormasOriginInfoDto();
        originInfo.setSenderName("Test Name");
        originInfo.setOrganizationId(DEFAULT_SERVER_ID);
        originInfo.setOwnershipHandedOver(true);
        originInfo.setComment("first share");
        c.setSormasToSormasOriginInfo(originInfo);
    });
    // initial share by the creator of case
    SormasToSormasShareInfoDto shareToSecond = createShareInfoDto(officer, SECOND_SERVER_ID, true);
    // another share by the creator
    SormasToSormasShareInfoDto anotherShareFromDefault = createShareInfoDto(officer, "anotherShareFromDefault", false);
    // forwarded by the second system
    User officerUser = getUserService().getByReferenceDto(officer);
    ShareRequestInfo shareFromSecond = createShareRequestInfo(officerUser, "shareFromSecond", false, ShareRequestStatus.ACCEPTED, i -> i.setCaze(getCaseService().getByReferenceDto(caze.toReference())));
    getShareRequestInfoService().persist(shareFromSecond);
    // The share tree for the above code is:
    // |- default
    // |- second
    // |- shareFromSecond
    // |- another from default
    mockSecondServerAccess();
    // mock share tree on the case creator system
    Mockito.when(MockProducer.getSormasToSormasClient().post(eq(DEFAULT_SERVER_ID), eq("/sormasToSormas/cases/shares"), ArgumentMatchers.any(), ArgumentMatchers.any())).thenAnswer(invocation -> {
        List<SormasToSormasShareTree> shareTrees = new ArrayList<>();
        shareTrees.add(new SormasToSormasShareTree(null, shareToSecond, Collections.emptyList(), false));
        shareTrees.add(new SormasToSormasShareTree(null, anotherShareFromDefault, Collections.emptyList(), false));
        return encryptShareData(shareTrees);
    });
    // Mock shares from "anotherShareFromDefault" -> no more shares
    Mockito.when(MockProducer.getSormasToSormasClient().post(eq("anotherShareFromDefault"), eq("/sormasToSormas/cases/shares"), ArgumentMatchers.any(), ArgumentMatchers.any())).thenAnswer(invocation -> encryptShareData(Collections.emptyList()));
    // Mock shares from "shareFromSecond" server -> no more shares
    Mockito.when(MockProducer.getSormasToSormasClient().post(eq("shareFromSecond"), eq("/sormasToSormas/cases/shares"), ArgumentMatchers.any(), ArgumentMatchers.any())).thenAnswer(invocation -> encryptShareData(Collections.emptyList()));
    List<SormasToSormasShareTree> shares = getSormasToSormasCaseFacade().getAllShares(caze.getUuid());
    assertThat(shares, hasSize(2));
    SormasToSormasShareInfoDto fistShare = shares.get(0).getShare();
    assertThat(fistShare.getTargetDescriptor().getId(), is(SECOND_SERVER_ID));
    assertThat(fistShare.isOwnershipHandedOver(), is(true));
    List<SormasToSormasShareTree> reShares = shares.get(0).getReShares();
    assertThat(reShares, hasSize(1));
    SormasToSormasShareInfoDto reShare = reShares.get(0).getShare();
    assertThat(reShare.getTargetDescriptor().getId(), is("shareFromSecond"));
    assertThat(reShare.isOwnershipHandedOver(), is(false));
    assertThat(reShares.get(0).getReShares(), hasSize(0));
    SormasToSormasShareTree secondReShareFromDefault = shares.get(1);
    assertThat(secondReShareFromDefault.getShare().getTargetDescriptor().getId(), is("anotherShareFromDefault"));
    assertThat(secondReShareFromDefault.getShare().isOwnershipHandedOver(), is(false));
    assertThat(secondReShareFromDefault.getReShares(), hasSize(0));
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) User(de.symeda.sormas.backend.user.User) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ShareRequestInfo(de.symeda.sormas.backend.sormastosormas.share.shareinfo.ShareRequestInfo) ArrayList(java.util.ArrayList) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) SormasToSormasShareTree(de.symeda.sormas.api.sormastosormas.SormasToSormasShareTree) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 14 with SormasToSormasOriginInfoDto

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

the class SormasToSormasCaseFacadeEjbTest method testSaveReturnedCase.

@Test
public void testSaveReturnedCase() throws SormasToSormasException {
    UserReferenceDto officer = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
    PersonDto person = creator.createPerson();
    CaseDataDto caze = creator.createCase(officer, person.toReference(), rdcf);
    PersonDto sharedContactPerson = creator.createPerson();
    ContactDto sharedContact = creator.createContact(officer, sharedContactPerson.toReference(), caze);
    PersonDto newContactPerson = creator.createPerson();
    ContactDto newContact = createContactRemoteContact(officer, newContactPerson.toReference(), caze);
    ContactDto newContact2 = createContactRemoteContact(officer, newContactPerson.toReference(), caze);
    SampleDto sharedSample = creator.createSample(caze.toReference(), officer, rdcf.facility);
    SampleDto newSample = createRemoteSample(caze.toReference(), officer, rdcf.facility);
    SampleDto newSample2 = createRemoteSample(caze.toReference(), officer, rdcf.facility);
    User officerUser = getUserService().getByReferenceDto(officer);
    getShareRequestInfoService().persist(createShareRequestInfo(officerUser, DEFAULT_SERVER_ID, true, i -> i.setCaze(getCaseService().getByReferenceDto(caze.toReference()))));
    getShareRequestInfoService().persist(createShareRequestInfo(officerUser, DEFAULT_SERVER_ID, true, i -> i.setContact(getContactService().getByReferenceDto(sharedContact.toReference()))));
    getShareRequestInfoService().persist(createShareRequestInfo(officerUser, DEFAULT_SERVER_ID, true, i -> i.setSample(getSampleService().getByReferenceDto(sharedSample.toReference()))));
    caze.setQuarantine(QuarantineType.HOTEL);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(caze.getChangeDate());
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    caze.setChangeDate(calendar.getTime());
    SormasToSormasOriginInfoDto originInfo = createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, true);
    SormasToSormasDto shareData = new SormasToSormasDto();
    shareData.setOriginInfo(originInfo);
    shareData.setCases(Collections.singletonList(new SormasToSormasCaseDto(person, caze)));
    shareData.setContacts(Arrays.asList(new SormasToSormasContactDto(sharedContactPerson, sharedContact), new SormasToSormasContactDto(newContactPerson, newContact), new SormasToSormasContactDto(newContactPerson, newContact2)));
    shareData.setSamples(Arrays.asList(new SormasToSormasSampleDto(sharedSample, Collections.emptyList(), Collections.emptyList()), new SormasToSormasSampleDto(newSample, Collections.emptyList(), Collections.emptyList()), new SormasToSormasSampleDto(newSample2, Collections.emptyList(), Collections.emptyList())));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
    try {
        getSormasToSormasCaseFacade().saveSharedEntities(encryptedData);
    } catch (Exception e) {
        e.printStackTrace();
    }
    CaseDataDto returnedCase = getCaseFacade().getCaseDataByUuid(caze.getUuid());
    assertThat(returnedCase.getQuarantine(), is(QuarantineType.HOTEL));
    assertThat(returnedCase.getReportingUser(), is(officer));
    List<SormasToSormasShareInfoDto> caseShares = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().caze(caze.toReference()), 0, 100);
    assertThat(caseShares.get(0).isOwnershipHandedOver(), is(false));
    List<SormasToSormasShareInfoDto> contactShares = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().contact(sharedContact.toReference()), 0, 100);
    assertThat(contactShares.get(0).isOwnershipHandedOver(), is(false));
    ContactDto returnedNewContact = getContactFacade().getByUuid(newContact.getUuid());
    assertThat(returnedNewContact.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(true));
    ContactDto returnedNewContact2 = getContactFacade().getByUuid(newContact.getUuid());
    assertThat(returnedNewContact2.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(true));
    List<SormasToSormasShareInfoDto> sampleShares = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().sample(sharedSample.toReference()), 0, 100);
    assertThat(sampleShares.get(0).isOwnershipHandedOver(), is(false));
    SampleDto returnedNewSample = getSampleFacade().getSampleByUuid(newSample.getUuid());
    assertThat(returnedNewSample.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(true));
    SampleDto returnedNewSample2 = getSampleFacade().getSampleByUuid(newSample.getUuid());
    assertThat(returnedNewSample2.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(true));
}
Also used : Arrays(java.util.Arrays) SormasToSormasShareTree(de.symeda.sormas.api.sormastosormas.SormasToSormasShareTree) 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) ExposureType(de.symeda.sormas.api.exposure.ExposureType) PersonDto(de.symeda.sormas.api.person.PersonDto) PortHealthInfoDto(de.symeda.sormas.api.caze.porthealthinfo.PortHealthInfoDto) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) Matchers.nullValue(org.hamcrest.Matchers.nullValue) PointOfEntryType(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryType) UserRole(de.symeda.sormas.api.user.UserRole) AnimalContactType(de.symeda.sormas.api.exposure.AnimalContactType) PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto) 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) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) 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) EpiDataDto(de.symeda.sormas.api.epidata.EpiDataDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) 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) Matchers.arrayWithSize(org.hamcrest.Matchers.arrayWithSize) 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) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) ArrayList(java.util.ArrayList) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) QuarantineType(de.symeda.sormas.api.contact.QuarantineType) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) Calendar(java.util.Calendar) SymptomState(de.symeda.sormas.api.symptoms.SymptomState) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DataHelper(de.symeda.sormas.api.utils.DataHelper) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) SormasToSormasShareRequestDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto) UserDto(de.symeda.sormas.api.user.UserDto) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Test(org.junit.Test) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) ShareRequestStatus(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestStatus) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) SormasToSormasConfig(de.symeda.sormas.api.sormastosormas.SormasToSormasConfig) SampleMaterial(de.symeda.sormas.api.sample.SampleMaterial) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) Mockito(org.mockito.Mockito) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) Disease(de.symeda.sormas.api.Disease) SampleDto(de.symeda.sormas.api.sample.SampleDto) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) Collections(java.util.Collections) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) User(de.symeda.sormas.backend.user.User) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) Calendar(java.util.Calendar) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SormasToSormasShareInfoCriteria(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto) SormasToSormasException(de.symeda.sormas.api.sormastosormas.SormasToSormasException) SormasToSormasValidationException(de.symeda.sormas.api.sormastosormas.validation.SormasToSormasValidationException) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) 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 SormasToSormasOriginInfoDto

use of de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto 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

SormasToSormasOriginInfoDto (de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto)20 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)13 SormasToSormasTest (de.symeda.sormas.backend.sormastosormas.SormasToSormasTest)13 Test (org.junit.Test)13 Date (java.util.Date)12 PersonDto (de.symeda.sormas.api.person.PersonDto)11 SormasServerDescriptor (de.symeda.sormas.api.sormastosormas.SormasServerDescriptor)11 SampleDto (de.symeda.sormas.api.sample.SampleDto)10 SormasToSormasOptionsDto (de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto)10 SormasToSormasSampleDto (de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto)10 SormasToSormasShareRequestDto (de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto)10 SormasToSormasDto (de.symeda.sormas.api.sormastosormas.SormasToSormasDto)9 SormasToSormasEncryptedDataDto (de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto)9 SormasToSormasShareInfoDto (de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto)9 User (de.symeda.sormas.backend.user.User)9 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)8 ContactDto (de.symeda.sormas.api.contact.ContactDto)8 ShareTreeCriteria (de.symeda.sormas.api.sormastosormas.ShareTreeCriteria)8 SormasToSormasContactDto (de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto)8 SormasToSormasShareInfoCriteria (de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria)8