Search in sources :

Example 21 with SampleDto

use of de.symeda.sormas.api.sample.SampleDto in project SORMAS-Project by hzi-braunschweig.

the class PathogenTestFacadeEjbPseudonymizationTest method testPathogenTestOnSampleOutsideJurisdiction.

@Test
public void testPathogenTestOnSampleOutsideJurisdiction() {
    Facility lab = getFacilityService().getByUuid(creator.createFacility("Lab", rdcf1.region, rdcf1.district, rdcf1.community).getUuid());
    loginWith(user2);
    CaseDataDto caze = creator.createCase(user1.toReference(), creator.createPerson("First", "Last").toReference(), rdcf1);
    SampleDto sample = creator.createSample(caze.toReference(), user1.toReference(), lab);
    PathogenTestDto pathogenTest = createPathogenTest(lab, sample, user1);
    assertPseudonymized(getPathogenTestFacade().getByUuid(pathogenTest.getUuid()));
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 22 with SampleDto

use of de.symeda.sormas.api.sample.SampleDto in project SORMAS-Project by hzi-braunschweig.

the class PathogenTestFacadeEjbPseudonymizationTest method updatePathogenTestInJurisdictionWithPseudonymizedDto.

@Test
public void updatePathogenTestInJurisdictionWithPseudonymizedDto() {
    Facility lab = getFacilityService().getByUuid(creator.createFacility("Lab", rdcf2.region, rdcf2.district, rdcf2.community).getUuid());
    loginWith(user2);
    CaseDataDto caze = creator.createCase(user2.toReference(), creator.createPerson("First", "Last").toReference(), rdcf2);
    SampleDto sample = creator.createSample(caze.toReference(), user2.toReference(), lab);
    PathogenTestDto pathogenTest = createPathogenTest(lab, sample, user2);
    pathogenTest.setPseudonymized(true);
    pathogenTest.setLab(null);
    pathogenTest.setLabUser(null);
    getPathogenTestFacade().savePathogenTest(pathogenTest);
    PathogenTest updatedTest = getPathogenTestService().getByUuid(pathogenTest.getUuid());
    assertThat(updatedTest.getLab(), is(nullValue()));
    assertThat(updatedTest.getLabUser().getUuid(), is(user2.getUuid()));
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 23 with SampleDto

use of de.symeda.sormas.api.sample.SampleDto in project SORMAS-Project by hzi-braunschweig.

the class PathogenTestFacadeEjbPseudonymizationTest method testPseudonymizeGetAllActive.

@Test
public void testPseudonymizeGetAllActive() {
    Facility lab1 = getFacilityService().getByUuid(creator.createFacility("Lab", rdcf2.region, rdcf2.district, rdcf2.community).getUuid());
    Facility lab2 = getFacilityService().getByUuid(creator.createFacility("Lab", rdcf1.region, rdcf1.district, rdcf1.community).getUuid());
    loginWith(user2);
    CaseDataDto caze1 = creator.createCase(user2.toReference(), creator.createPerson("First", "Last").toReference(), rdcf2);
    SampleDto sample1 = creator.createSample(caze1.toReference(), user2.toReference(), lab1);
    PathogenTestDto pathogenTest1 = createPathogenTest(lab1, sample1, user2);
    CaseDataDto caze2 = creator.createCase(user1.toReference(), creator.createPerson("First", "Last").toReference(), rdcf1);
    creator.createContact(user2.toReference(), creator.createPerson("First", "Last").toReference(), caze2);
    SampleDto sample2 = creator.createSample(caze2.toReference(), user1.toReference(), lab2);
    PathogenTestDto pathogenTest2 = createPathogenTest(lab2, sample2, user1);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 2019);
    List<PathogenTestDto> activeTests = getPathogenTestFacade().getAllActivePathogenTestsAfter(calendar.getTime());
    assertNotPseudonymized(activeTests.stream().filter(t -> t.getUuid().equals(pathogenTest1.getUuid())).findFirst().get());
    assertPseudonymized(activeTests.stream().filter(t -> t.getUuid().equals(pathogenTest2.getUuid())).findFirst().get());
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) UserDto(de.symeda.sormas.api.user.UserDto) RunWith(org.junit.runner.RunWith) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType) List(java.util.List) Calendar(java.util.Calendar) Disease(de.symeda.sormas.api.Disease) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) SampleDto(de.symeda.sormas.api.sample.SampleDto) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Matchers.is(org.hamcrest.Matchers.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) UserRole(de.symeda.sormas.api.user.UserRole) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Calendar(java.util.Calendar) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 24 with SampleDto

use of de.symeda.sormas.api.sample.SampleDto in project SORMAS-Project by hzi-braunschweig.

the class PathogenTestFacadeEjbPseudonymizationTest method testPseudonymizeGetAllByUuds.

@Test
public void testPseudonymizeGetAllByUuds() {
    Facility lab1 = getFacilityService().getByUuid(creator.createFacility("Lab", rdcf2.region, rdcf2.district, rdcf2.community).getUuid());
    Facility lab2 = getFacilityService().getByUuid(creator.createFacility("Lab", rdcf1.region, rdcf1.district, rdcf1.community).getUuid());
    loginWith(user2);
    CaseDataDto caze1 = creator.createCase(user2.toReference(), creator.createPerson("First", "Last").toReference(), rdcf2);
    SampleDto sample1 = creator.createSample(caze1.toReference(), user2.toReference(), lab1);
    PathogenTestDto pathogenTest1 = createPathogenTest(lab1, sample1, user2);
    CaseDataDto caze2 = creator.createCase(user1.toReference(), creator.createPerson("First", "Last").toReference(), rdcf1);
    creator.createContact(user2.toReference(), creator.createPerson("First", "Last").toReference(), caze2);
    SampleDto sample2 = creator.createSample(caze2.toReference(), user1.toReference(), lab2);
    PathogenTestDto pathogenTest2 = createPathogenTest(lab2, sample2, user1);
    List<PathogenTestDto> activeTests = getPathogenTestFacade().getByUuids(Arrays.asList(pathogenTest1.getUuid(), pathogenTest2.getUuid()));
    assertNotPseudonymized(activeTests.stream().filter(t -> t.getUuid().equals(pathogenTest1.getUuid())).findFirst().get());
    assertPseudonymized(activeTests.stream().filter(t -> t.getUuid().equals(pathogenTest2.getUuid())).findFirst().get());
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) UserDto(de.symeda.sormas.api.user.UserDto) RunWith(org.junit.runner.RunWith) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType) List(java.util.List) Calendar(java.util.Calendar) Disease(de.symeda.sormas.api.Disease) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) SampleDto(de.symeda.sormas.api.sample.SampleDto) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Matchers.is(org.hamcrest.Matchers.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) UserRole(de.symeda.sormas.api.user.UserRole) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 25 with SampleDto

use of de.symeda.sormas.api.sample.SampleDto in project SORMAS-Project by hzi-braunschweig.

the class PathogenTestFacadeEjbTest method testSaveAndUpdatePathogenTestAssociatedToContact.

@Test
public void testSaveAndUpdatePathogenTestAssociatedToContact() {
    final RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    final UserDto user = creator.createUser(rdcf, UserRole.SURVEILLANCE_SUPERVISOR);
    final PersonDto person = creator.createPerson();
    final CaseDataDto caze = creator.createCase(user.toReference(), person.toReference(), rdcf);
    final ContactDto contact = creator.createContact(user.toReference(), person.toReference(), caze);
    final SampleDto sample = creator.createSample(contact.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
    final PathogenTestDto newPathogenTest = creator.buildPathogenTestDto(rdcf, user, sample, contact.getDisease(), testDateTime);
    testSaveAndUpdatePathogenTest(newPathogenTest);
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Date(java.util.Date) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

SampleDto (de.symeda.sormas.api.sample.SampleDto)179 Test (org.junit.Test)111 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)81 PersonDto (de.symeda.sormas.api.person.PersonDto)71 Date (java.util.Date)71 PathogenTestDto (de.symeda.sormas.api.sample.PathogenTestDto)64 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)60 UserDto (de.symeda.sormas.api.user.UserDto)56 ContactDto (de.symeda.sormas.api.contact.ContactDto)42 LabMessageDto (de.symeda.sormas.api.labmessage.LabMessageDto)34 AbstractBeanTest (de.symeda.sormas.ui.AbstractBeanTest)34 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)27 List (java.util.List)25 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)24 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)22 Facility (de.symeda.sormas.backend.infrastructure.facility.Facility)22 Disease (de.symeda.sormas.api.Disease)20 CaseReferenceDto (de.symeda.sormas.api.caze.CaseReferenceDto)20 EventDto (de.symeda.sormas.api.event.EventDto)20 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)20