Search in sources :

Example 1 with DateHelper8

use of de.symeda.sormas.backend.util.DateHelper8 in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testGenerateContactFollowUpTasks.

@Test
public void testGenerateContactFollowUpTasks() {
    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 contactOfficer = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Cont", "Off", UserRole.CONTACT_OFFICER);
    PersonDto cazePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    PersonDto contactPerson = creator.createPerson("Contact", "Person");
    ContactDto contact = creator.createContact(user.toReference(), contactOfficer.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
    getContactFacade().generateContactFollowUpTasks();
    // task should have been generated
    List<TaskDto> tasks = getTaskFacade().getAllByContact(contact.toReference()).stream().filter(t -> t.getTaskType() == TaskType.CONTACT_FOLLOW_UP).collect(Collectors.toList());
    assertEquals(1, tasks.size());
    TaskDto task = tasks.get(0);
    assertEquals(TaskType.CONTACT_FOLLOW_UP, task.getTaskType());
    assertEquals(TaskStatus.PENDING, task.getTaskStatus());
    assertEquals(LocalDate.now(), DateHelper8.toLocalDate(task.getDueDate()));
    assertEquals(contactOfficer.toReference(), task.getAssigneeUser());
    // task should not be generated multiple times
    getContactFacade().generateContactFollowUpTasks();
    tasks = getTaskFacade().getAllByContact(contact.toReference()).stream().filter(t -> t.getTaskType() == TaskType.CONTACT_FOLLOW_UP).collect(Collectors.toList());
    assertEquals(1, tasks.size());
}
Also used : FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) Arrays(java.util.Arrays) VisitStatus(de.symeda.sormas.api.visit.VisitStatus) Matchers.not(org.hamcrest.Matchers.not) Vaccine(de.symeda.sormas.api.caze.Vaccine) MeansOfImmunization(de.symeda.sormas.api.immunization.MeansOfImmunization) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) StringUtils(org.apache.commons.lang3.StringUtils) PersonDto(de.symeda.sormas.api.person.PersonDto) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) VaccineManufacturer(de.symeda.sormas.api.caze.VaccineManufacturer) DocumentRelatedEntityType(de.symeda.sormas.api.document.DocumentRelatedEntityType) Visit(de.symeda.sormas.backend.visit.Visit) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) ContactExportDto(de.symeda.sormas.api.contact.ContactExportDto) StandardCharsets(java.nio.charset.StandardCharsets) EpiDataDto(de.symeda.sormas.api.epidata.EpiDataDto) Assert.assertFalse(org.junit.Assert.assertFalse) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) Matchers.is(org.hamcrest.Matchers.is) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ContactFacade(de.symeda.sormas.api.contact.ContactFacade) HealthConditionsDto(de.symeda.sormas.api.clinicalcourse.HealthConditionsDto) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) EventStatus(de.symeda.sormas.api.event.EventStatus) ArrayList(java.util.ArrayList) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) VaccinationInfoSource(de.symeda.sormas.api.caze.VaccinationInfoSource) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ContactSimilarityCriteria(de.symeda.sormas.api.contact.ContactSimilarityCriteria) DataHelper(de.symeda.sormas.api.utils.DataHelper) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) DocumentDto(de.symeda.sormas.api.document.DocumentDto) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) SortProperty(de.symeda.sormas.api.utils.SortProperty) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) DateUtils(org.apache.commons.lang3.time.DateUtils) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) Assert.assertNull(org.junit.Assert.assertNull) Disease(de.symeda.sormas.api.Disease) VisitDto(de.symeda.sormas.api.visit.VisitDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) DeletionReason(de.symeda.sormas.api.common.DeletionReason) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) DateHelper8(de.symeda.sormas.backend.util.DateHelper8) FollowUpLogic(de.symeda.sormas.api.followup.FollowUpLogic) ImmunizationStatus(de.symeda.sormas.api.immunization.ImmunizationStatus) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) ImmunizationManagementStatus(de.symeda.sormas.api.immunization.ImmunizationManagementStatus) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) ExposureType(de.symeda.sormas.api.exposure.ExposureType) ContactIndexDetailedDto(de.symeda.sormas.api.contact.ContactIndexDetailedDto) Assert.assertThat(org.junit.Assert.assertThat) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) EventInvestigationStatus(de.symeda.sormas.api.event.EventInvestigationStatus) UserRole(de.symeda.sormas.api.user.UserRole) VaccinationStatus(de.symeda.sormas.api.caze.VaccinationStatus) TaskDto(de.symeda.sormas.api.task.TaskDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) Region(de.symeda.sormas.backend.infrastructure.region.Region) EventDto(de.symeda.sormas.api.event.EventDto) District(de.symeda.sormas.backend.infrastructure.district.District) Collectors(java.util.stream.Collectors) Language(de.symeda.sormas.api.Language) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) TaskType(de.symeda.sormas.api.task.TaskType) List(java.util.List) ContactDto(de.symeda.sormas.api.contact.ContactDto) PersonContactDetailType(de.symeda.sormas.api.person.PersonContactDetailType) LocalDate(java.time.LocalDate) VisitIndexDto(de.symeda.sormas.api.visit.VisitIndexDto) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) EpiDataHelper(de.symeda.sormas.api.epidata.EpiDataHelper) VisitSummaryExportDto(de.symeda.sormas.api.visit.VisitSummaryExportDto) MockProducer(de.symeda.sormas.backend.MockProducer) ContactFacadeEjbLocal(de.symeda.sormas.backend.contact.ContactFacadeEjb.ContactFacadeEjbLocal) DateHelper(de.symeda.sormas.api.utils.DateHelper) PersonContactDetailDto(de.symeda.sormas.api.person.PersonContactDetailDto) VisitOrigin(de.symeda.sormas.api.VisitOrigin) DeletionDetails(de.symeda.sormas.api.common.DeletionDetails) SymptomState(de.symeda.sormas.api.symptoms.SymptomState) TaskStatus(de.symeda.sormas.api.task.TaskStatus) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) TaskContext(de.symeda.sormas.api.task.TaskContext) Matchers.empty(org.hamcrest.Matchers.empty) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) Assert.assertNotNull(org.junit.Assert.assertNotNull) UserDto(de.symeda.sormas.api.user.UserDto) Mockito.when(org.mockito.Mockito.when) VisitCriteria(de.symeda.sormas.api.visit.VisitCriteria) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) SampleMaterial(de.symeda.sormas.api.sample.SampleMaterial) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) VisitSummaryExportDetailsDto(de.symeda.sormas.api.visit.VisitSummaryExportDetailsDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) 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) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) TaskDto(de.symeda.sormas.api.task.TaskDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

Disease (de.symeda.sormas.api.Disease)1 Language (de.symeda.sormas.api.Language)1 VisitOrigin (de.symeda.sormas.api.VisitOrigin)1 CaseClassification (de.symeda.sormas.api.caze.CaseClassification)1 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 CaseReferenceDto (de.symeda.sormas.api.caze.CaseReferenceDto)1 InvestigationStatus (de.symeda.sormas.api.caze.InvestigationStatus)1 VaccinationInfoSource (de.symeda.sormas.api.caze.VaccinationInfoSource)1 VaccinationStatus (de.symeda.sormas.api.caze.VaccinationStatus)1 Vaccine (de.symeda.sormas.api.caze.Vaccine)1 VaccineManufacturer (de.symeda.sormas.api.caze.VaccineManufacturer)1 HealthConditionsDto (de.symeda.sormas.api.clinicalcourse.HealthConditionsDto)1 DeletionDetails (de.symeda.sormas.api.common.DeletionDetails)1 DeletionReason (de.symeda.sormas.api.common.DeletionReason)1 ContactClassification (de.symeda.sormas.api.contact.ContactClassification)1 ContactCriteria (de.symeda.sormas.api.contact.ContactCriteria)1 ContactDto (de.symeda.sormas.api.contact.ContactDto)1 ContactExportDto (de.symeda.sormas.api.contact.ContactExportDto)1 ContactFacade (de.symeda.sormas.api.contact.ContactFacade)1 ContactIndexDetailedDto (de.symeda.sormas.api.contact.ContactIndexDetailedDto)1