Search in sources :

Example 11 with GroupableItem

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

the class StatisticsGroupByUtilTest method testFilterAndGroupForMultipleUnitsForVardadmin.

@Test
public void testFilterAndGroupForMultipleUnitsForVardadmin() {
    when(webCertUserService.getUser()).thenReturn(buildUserOfRole(AUTHORITIES_RESOLVER.getRole("VARDADMINISTRATOR")));
    List<GroupableItem> queryResult = new ArrayList<>();
    queryResult.add(new GroupableItem("id-1", HSA1, PNR1, FK7263));
    // Not this
    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(2L), 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 12 with GroupableItem

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

the class StatisticsGroupByUtilTest method testAssumeNotSekrWhenPUNotResponding.

@Test
public void testAssumeNotSekrWhenPUNotResponding() {
    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