SormasToSormasFacadeEjb implements SormasToSormasFacade { @Override @Transactional public void saveSharedContact(SormasToSormasEncryptedDataDto sharedData) throws SormasToSormasException { SormasToSormasContactDto sharedContact = decryptSharedData(sharedData, SormasToSormasContactDto.class); PersonDto person = sharedContact.getPerson(); ContactDto contact = sharedContact.getContact(); validateContact(contact); processContactData(contact, person); personFacade.savePerson(person); contactFacade.saveContact(contact); } SormasToSormasFacadeEjb(); @Override @Transactional void saveSharedCase(SormasToSormasEncryptedDataDto encryptedData); @Override @Transactional void saveSharedContact(SormasToSormasEncryptedDataDto sharedData); @Override void shareCase(String uuid, SormasToSormasOptionsDto options); @Override void shareContact(String uuid, SormasToSormasOptionsDto options); @Override List<ServerAccessDataReferenceDto> getAvailableOrganizations(); @Override List<SormasToSormasShareInfoDto> getShareInfoIndexList(SormasToSormasShareInfoCriteria criteria, Integer first, Integer max); @Override boolean isFeatureEnabled(); @Override ServerAccessDataReferenceDto getOrganizationRef(String id); SormasToSormasOriginInfo fromSormasToSormasOriginInfoDto(SormasToSormasOriginInfoDto source); static SormasToSormasOriginInfoDto toSormasToSormasOriginInfoDto(SormasToSormasOriginInfo source); SormasToSormasShareInfoDto toSormasToSormasShareInfoDto(SormasToSormasShareInfo source); static final String SAVE_SHARED_CASE_ENDPOINT; }
@Test public void testSaveSharedContact() throws JsonProcessingException, SormasToSormasException { MappableRdcf rdcf = createRDCF(); PersonDto person = createPersonDto(rdcf); person.setFirstName("James"); person.setLastName("Smith"); ContactDto contact = ContactDto.build(null, Disease.CORONAVIRUS, null); contact.setPerson(person.toReference()); contact.setRegion(rdcf.remoteRdcf.region); contact.setDistrict(rdcf.remoteRdcf.district); contact.setCommunity(rdcf.remoteRdcf.community); contact.getEpiData().setAnimalCondition(AnimalCondition.PROCESSED); contact.setSormasToSormasOriginInfo(createSormasToSormasOriginInfo()); byte[] encryptedData = encryptShareData(new SormasToSormasContactDto(person, contact)); getSormasToSormasFacade().saveSharedContact(new SormasToSormasEncryptedDataDto(DEFAULT_SERVER_ACCESS_CN, encryptedData)); ContactDto savedContact = getContactFacade().getContactByUuid(contact.getUuid()); assertThat(savedContact, is(notNullValue())); assertThat(savedContact.getRegion(), is(rdcf.localRdcf.region)); assertThat(savedContact.getDistrict(), is(rdcf.localRdcf.district)); assertThat(savedContact.getCommunity(), is(rdcf.localRdcf.community)); assertThat(savedContact.getEpiData().getAnimalCondition(), is(AnimalCondition.PROCESSED)); assertThat(savedContact.getSormasToSormasOriginInfo().getOrganizationId(), is("testHealthDep")); assertThat(savedContact.getSormasToSormasOriginInfo().getSenderName(), is("John doe")); PersonDto savedPerson = getPersonFacade().getPersonByUuid(savedContact.getPerson().getUuid()); assertThat(savedPerson, is(notNullValue())); assertThat(savedPerson.getAddress().getRegion(), is(rdcf.localRdcf.region)); assertThat(savedPerson.getAddress().getDistrict(), is(rdcf.localRdcf.district)); assertThat(savedPerson.getAddress().getCommunity(), is(rdcf.localRdcf.community)); assertThat(savedPerson.getFirstName(), is("James")); assertThat(savedPerson.getLastName(), is("Smith")); }