Search in sources :

Example 6 with GroupableItem

use of se.inera.intyg.webcert.common.model.GroupableItem in project webcert by sklintyg.

the class StatisticsGroupByUtilTest method testFilterInvalidGroupableItems.

@Test
public void testFilterInvalidGroupableItems() {
    List<GroupableItem> queryResult = new ArrayList<>();
    queryResult.add(new GroupableItem("id-1", HSA1, PNR1, FK7263));
    queryResult.add(new GroupableItem("id-2", HSA2, PNR2, TSBAS));
    queryResult.add(new GroupableItem("id-3", HSA1, null, FK7263));
    queryResult.add(new GroupableItem("id-4", HSA1, "", TSBAS));
    queryResult.add(new GroupableItem("id-5", HSA2, "thisisainvalidparameter", FK7263));
    List<GroupableItem> result = testee.getFilteredGroupableItemList(queryResult);
    assertEquals(2, result.size());
}
Also used : GroupableItem(se.inera.intyg.webcert.common.model.GroupableItem) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with GroupableItem

use of se.inera.intyg.webcert.common.model.GroupableItem in project webcert by sklintyg.

the class StatisticsGroupByUtilTest method testFilterAndGroupForMultipleUnitsForLakare.

@Test
public void testFilterAndGroupForMultipleUnitsForLakare() {
    when(webCertUserService.getUser()).thenReturn(createUser());
    List<GroupableItem> queryResult = new ArrayList<>();
    queryResult.add(new GroupableItem("id-1", HSA1, PNR1, FK7263));
    queryResult.add(new GroupableItem("id-2", HSA1, PNR2, FK7263));
    queryResult.add(new GroupableItem("id-3", HSA1, PNR3, FK7263));
    queryResult.add(new GroupableItem("id-4", HSA2, PNR3, FK7263));
    queryResult.add(new GroupableItem("id-5", HSA2, PNR1, FK7263));
    queryResult.add(new GroupableItem("id-6", HSA2, PNR3, FK7263));
    queryResult.add(new GroupableItem("id-7", HSA2, PNR1, TSBAS));
    // Never this one.
    queryResult.add(new GroupableItem("id-8", HSA1, PNR2, TSBAS));
    Map<String, Long> result = testee.toSekretessFilteredMap(queryResult);
    assertEquals(2, result.size());
    assertEquals(new Long(3L), result.get(HSA1));
    assertEquals(new Long(4L), result.get(HSA2));
}
Also used : GroupableItem(se.inera.intyg.webcert.common.model.GroupableItem) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 8 with GroupableItem

use of se.inera.intyg.webcert.common.model.GroupableItem in project webcert by sklintyg.

the class StatisticsGroupByUtilTest method testFilterInvalidPersonnummer.

@Test
public void testFilterInvalidPersonnummer() {
    List<GroupableItem> queryResult = new ArrayList<>();
    queryResult.add(new GroupableItem("id-1", HSA1, PNR1, FK7263));
    queryResult.add(new GroupableItem("id-2", HSA2, PNR2, TSBAS));
    queryResult.add(new GroupableItem("id-3", HSA1, null, FK7263));
    queryResult.add(new GroupableItem("id-4", HSA1, "", TSBAS));
    queryResult.add(new GroupableItem("id-5", HSA2, "thisisainvalidparameter", FK7263));
    List<Personnummer> result = testee.getPersonummerList(queryResult);
    assertEquals(2, result.size());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) GroupableItem(se.inera.intyg.webcert.common.model.GroupableItem) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with GroupableItem

use of se.inera.intyg.webcert.common.model.GroupableItem in project webcert by sklintyg.

the class StatisticsGroupByUtilTest method testFilterAndGroupForTwoResultsOfSameUnitOneIsSekrForVardadmin.

@Test
public void testFilterAndGroupForTwoResultsOfSameUnitOneIsSekrForVardadmin() {
    when(webCertUserService.getUser()).thenReturn(buildUserOfRole(AUTHORITIES_RESOLVER.getRole("VARDADMINISTRATOR")));
    Personnummer pnr1 = Personnummer.createPersonnummer(PNR1).get();
    Personnummer pnr2 = Personnummer.createPersonnummer(PNR2).get();
    Map<Personnummer, SekretessStatus> sekrMap = new HashMap<>();
    sekrMap.put(pnr1, SekretessStatus.FALSE);
    sekrMap.put(pnr2, SekretessStatus.TRUE);
    when(patientDetailsResolver.getSekretessStatusForList(anyList())).thenReturn(sekrMap);
    List<GroupableItem> queryResult = new ArrayList<>();
    queryResult.add(new GroupableItem("id-1", HSA1, PNR1, FK7263));
    queryResult.add(new GroupableItem("id-2", HSA1, PNR2, FK7263));
    // Should be filtered away
    queryResult.add(new GroupableItem("id-3", HSA1, PNR2, TSBAS));
    Map<String, Long> result = testee.toSekretessFilteredMap(queryResult);
    assertEquals(1, result.size());
    assertEquals(new Long(1L), result.get(HSA1));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) GroupableItem(se.inera.intyg.webcert.common.model.GroupableItem) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 10 with GroupableItem

use of se.inera.intyg.webcert.common.model.GroupableItem in project webcert by sklintyg.

the class StatisticsGroupByUtilTest method testFilterAndGroupForTwoResultsOfSameUnitOneIsSekrForLakare.

@Test
public void testFilterAndGroupForTwoResultsOfSameUnitOneIsSekrForLakare() {
    when(webCertUserService.getUser()).thenReturn(createUser());
    List<GroupableItem> queryResult = new ArrayList<>();
    queryResult.add(new GroupableItem("id-1", HSA1, PNR1, FK7263));
    queryResult.add(new GroupableItem("id-2", HSA1, PNR2, FK7263));
    Map<String, Long> result = testee.toSekretessFilteredMap(queryResult);
    assertEquals(1, result.size());
    assertEquals(new Long(2L), result.get(HSA1));
}
Also used : GroupableItem(se.inera.intyg.webcert.common.model.GroupableItem) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

GroupableItem (se.inera.intyg.webcert.common.model.GroupableItem)12 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 Personnummer (se.inera.intyg.schemas.contract.Personnummer)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)2 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)2 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Component (org.springframework.stereotype.Component)1 Transactional (org.springframework.transaction.annotation.Transactional)1 AuthoritiesValidator (se.inera.intyg.infra.security.authorities.validation.AuthoritiesValidator)1 AuthoritiesConstants (se.inera.intyg.infra.security.common.model.AuthoritiesConstants)1 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)1 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)1 PatientDetailsResolver (se.inera.intyg.webcert.web.service.patient.PatientDetailsResolver)1 WebCertUserService (se.inera.intyg.webcert.web.service.user.WebCertUserService)1