Search in sources :

Example 1 with DeletionDetails

use of de.symeda.sormas.api.common.DeletionDetails in project SORMAS-Project by hzi-braunschweig.

the class SampleFacadeEjbTest method testAllSamplesDeletionWithMultipleAdditionalTest.

@Test
public void testAllSamplesDeletionWithMultipleAdditionalTest() {
    Date since = new Date();
    RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    PersonDto secondCazePerson = creator.createPerson("SecondCase", "SecondPerson");
    CaseDataDto secondCaze = creator.createCase(user.toReference(), secondCazePerson.toReference(), Disease.ACUTE_VIRAL_HEPATITIS, CaseClassification.NOT_CLASSIFIED, InvestigationStatus.PENDING, new Date(), rdcf);
    SampleDto thirdSample = creator.createSample(secondCaze.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
    SampleDto forthSample = creator.createSample(secondCaze.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
    PathogenTestDto secondSamplePathogenTest = creator.createPathogenTest(thirdSample.toReference(), PathogenTestType.RAPID_TEST, secondCaze.getDisease(), new Date(), rdcf.facility, user.toReference(), PathogenTestResultType.INDETERMINATE, "Indeterminate", true);
    PathogenTestDto thirdSamplePathogenTest = creator.createPathogenTest(forthSample.toReference(), PathogenTestType.CQ_VALUE_DETECTION, secondCaze.getDisease(), new Date(), rdcf.facility, user.toReference(), PathogenTestResultType.NOT_DONE, "Not done", true);
    AdditionalTestDto secondSampleAdditionalTest = creator.createAdditionalTest(thirdSample.toReference());
    AdditionalTestDto thirdSampleAdditionalTest = creator.createAdditionalTest(forthSample.toReference());
    // Database should contain the created sample, sample test and additional tests
    assertNotNull(getSampleTestFacade().getByUuid(secondSamplePathogenTest.getUuid()));
    assertNotNull(getSampleTestFacade().getByUuid(thirdSamplePathogenTest.getUuid()));
    assertNotNull(getAdditionalTestFacade().getByUuid(secondSampleAdditionalTest.getUuid()));
    assertNotNull(getAdditionalTestFacade().getByUuid(thirdSampleAdditionalTest.getUuid()));
    getSampleFacade().deleteAllSamples(Arrays.asList(thirdSample.getUuid(), forthSample.getUuid()), new DeletionDetails(DeletionReason.OTHER_REASON, "test reason"));
    // Sample and pathogen test should be marked as deleted, additional tests should be deleted
    List<String> sampleUuids = getSampleFacade().getDeletedUuidsSince(since);
    assertTrue(sampleUuids.contains(thirdSample.getUuid()));
    assertTrue(sampleUuids.contains(forthSample.getUuid()));
    assertTrue(getSampleTestFacade().getDeletedUuidsSince(since).contains(secondSamplePathogenTest.getUuid()));
    assertTrue(getSampleTestFacade().getDeletedUuidsSince(since).contains(thirdSamplePathogenTest.getUuid()));
    assertNull(getAdditionalTestFacade().getByUuid(secondSampleAdditionalTest.getUuid()));
    assertNull(getAdditionalTestFacade().getByUuid(thirdSampleAdditionalTest.getUuid()));
}
Also used : DeletionDetails(de.symeda.sormas.api.common.DeletionDetails) 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) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Date(java.util.Date) AdditionalTestDto(de.symeda.sormas.api.sample.AdditionalTestDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 2 with DeletionDetails

use of de.symeda.sormas.api.common.DeletionDetails in project SORMAS-Project by hzi-braunschweig.

the class SampleFacadeEjbTest method testSampleDeletion.

@Test
public void testSampleDeletion() {
    Date since = new Date();
    RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    UserDto admin = getUserFacade().getByUserName("admin");
    String adminUuid = admin.getUuid();
    PersonDto cazePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    SampleDto sample = creator.createSample(caze.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
    PathogenTestDto sampleTest = creator.createPathogenTest(sample.toReference(), PathogenTestType.MICROSCOPY, caze.getDisease(), new Date(), rdcf.facility, user.toReference(), PathogenTestResultType.POSITIVE, "Positive", true);
    // Database should contain the created sample and sample test
    assertNotNull(getSampleFacade().getSampleByUuid(sample.getUuid()));
    assertNotNull(getSampleTestFacade().getByUuid(sampleTest.getUuid()));
    getSampleFacade().deleteSample(sample.toReference(), new DeletionDetails(DeletionReason.OTHER_REASON, "test reason"));
    // Sample and pathogen test should be marked as deleted
    assertTrue(getSampleFacade().getDeletedUuidsSince(since).contains(sample.getUuid()));
    assertTrue(getSampleTestFacade().getDeletedUuidsSince(since).contains(sampleTest.getUuid()));
    assertEquals(DeletionReason.OTHER_REASON, getSampleFacade().getSampleByUuid(sample.getUuid()).getDeletionReason());
    assertEquals("test reason", getSampleFacade().getSampleByUuid(sample.getUuid()).getOtherDeletionReason());
}
Also used : DeletionDetails(de.symeda.sormas.api.common.DeletionDetails) 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) 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)

Example 3 with DeletionDetails

use of de.symeda.sormas.api.common.DeletionDetails in project SORMAS-Project by hzi-braunschweig.

the class SampleServiceTest method testSamplePermanentDeletion.

@Test
public void testSamplePermanentDeletion() {
    TestDataCreator.RDCF rdcf = creator.createRDCF();
    UserDto user = creator.createUser(rdcf, UserRole.ADMIN, UserRole.NATIONAL_USER);
    PersonDto person = creator.createPerson();
    CaseDataDto caze = creator.createCase(user.toReference(), person.toReference(), rdcf);
    SampleDto sample = creator.createSample(caze.toReference(), user.toReference(), rdcf.facility);
    SampleDto referralSample = creator.createSample(caze.toReference(), user.toReference(), rdcf.facility, s -> s.setReferredTo(sample.toReference()));
    creator.createPathogenTest(sample.toReference(), caze);
    creator.createAdditionalTest(sample.toReference());
    LabMessageDto labMessage = creator.createLabMessage(lm -> lm.setSample(sample.toReference()));
    getSampleFacade().deleteSample(sample.toReference(), new DeletionDetails(DeletionReason.OTHER_REASON, "test reason"));
    Sample sampleEntity = getSampleService().getByUuid(sample.getUuid());
    List<PathogenTest> pathogenTests = getPathogenTestService().getAll();
    assertEquals(2, getSampleService().count());
    assertTrue(sampleEntity.isDeleted());
    assertEquals(1, pathogenTests.size());
    assertTrue(pathogenTests.get(0).isDeleted());
    assertEquals(1, getAdditionalTestService().count());
    assertNull(getSampleService().getByUuid(referralSample.getUuid()).getReferredTo());
    assertNull(getLabMessageService().getByUuid(labMessage.getUuid()).getSample());
    getSampleService().deletePermanent(getEntityAttached(sampleEntity));
    assertEquals(1, getSampleService().count());
    assertEquals(0, getPathogenTestService().count());
    assertEquals(0, getAdditionalTestService().count());
    assertEquals(1, getLabMessageService().count());
}
Also used : DeletionDetails(de.symeda.sormas.api.common.DeletionDetails) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) LabMessageDto(de.symeda.sormas.api.labmessage.LabMessageDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) SampleDto(de.symeda.sormas.api.sample.SampleDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 4 with DeletionDetails

use of de.symeda.sormas.api.common.DeletionDetails in project SORMAS-Project by hzi-braunschweig.

the class EventParticipantFacadeEjbTest method testExistEventParticipantWithDeletedTrue.

@Test
public void testExistEventParticipantWithDeletedTrue() {
    RDCFEntities rdcf = creator.createRDCFEntities();
    UserDto user = creator.createUser(rdcf, UserRole.SURVEILLANCE_SUPERVISOR);
    EventDto event = creator.createEvent(user.toReference());
    PersonDto person = creator.createPerson();
    EventParticipantDto eventParticipant = creator.createEventParticipant(event.toReference(), person, user.toReference());
    getEventParticipantFacade().delete(eventParticipant.toReference().getUuid(), new DeletionDetails(DeletionReason.OTHER_REASON, "test reason"));
    boolean exist = getEventParticipantFacade().exists(person.getUuid(), event.getUuid());
    Assert.assertFalse(exist);
}
Also used : DeletionDetails(de.symeda.sormas.api.common.DeletionDetails) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 5 with DeletionDetails

use of de.symeda.sormas.api.common.DeletionDetails in project SORMAS-Project by hzi-braunschweig.

the class TaskFacadeEjbTest method testTaskDirectoryForDeletedLinkedCase.

@Test
public void testTaskDirectoryForDeletedLinkedCase() {
    RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    PersonDto cazePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    TaskDto task = creator.createTask(TaskContext.CASE, TaskType.OTHER, TaskStatus.PENDING, caze.toReference(), null, null, DateHelper.addDays(new Date(), 1), user.toReference());
    getCaseFacade().delete(caze.getUuid(), new DeletionDetails());
    List<TaskIndexDto> tasks = getTaskFacade().getIndexList(new TaskCriteria().relevanceStatus(EntityRelevanceStatus.ALL), 0, 100, null);
    Assert.assertEquals(0, tasks.size());
}
Also used : DeletionDetails(de.symeda.sormas.api.common.DeletionDetails) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) TaskIndexDto(de.symeda.sormas.api.task.TaskIndexDto) TaskCriteria(de.symeda.sormas.api.task.TaskCriteria) TaskDto(de.symeda.sormas.api.task.TaskDto) Date(java.util.Date) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

DeletionDetails (de.symeda.sormas.api.common.DeletionDetails)24 UserDto (de.symeda.sormas.api.user.UserDto)19 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)19 Test (org.junit.Test)19 PersonDto (de.symeda.sormas.api.person.PersonDto)18 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)16 Date (java.util.Date)13 SampleDto (de.symeda.sormas.api.sample.SampleDto)10 ContactDto (de.symeda.sormas.api.contact.ContactDto)9 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)8 PathogenTestDto (de.symeda.sormas.api.sample.PathogenTestDto)5 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)5 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)5 CasePersonDto (de.symeda.sormas.api.caze.CasePersonDto)4 LocalDate (java.time.LocalDate)4 MapContactDto (de.symeda.sormas.api.contact.MapContactDto)3 VisitDto (de.symeda.sormas.api.visit.VisitDto)3 Timestamp (java.sql.Timestamp)3 Label (com.vaadin.ui.Label)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2