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()));
}
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());
}
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());
}
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);
}
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());
}
Aggregations