use of se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarResponse in project webcert by sklintyg.
the class ArendeServiceTest method testFilterArendeInvalidStartPosition.
@Test
public void testFilterArendeInvalidStartPosition() {
when(webcertUserService.getUser()).thenReturn(createUser());
List<Arende> queryResults = new ArrayList<>();
queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now(), null));
queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now().plusDays(1), null));
when(arendeRepository.filterArende(any(Filter.class))).thenReturn(queryResults);
QueryFragaSvarResponse fsResponse = new QueryFragaSvarResponse();
fsResponse.setResults(new ArrayList<>());
fsResponse.getResults().add(buildArendeListItem("intyg1", LocalDateTime.now().minusDays(1)));
fsResponse.setTotalCount(1);
when(fragaSvarService.filterFragaSvar(any(Filter.class))).thenReturn(fsResponse);
QueryFragaSvarParameter params = new QueryFragaSvarParameter();
params.setStartFrom(5);
QueryFragaSvarResponse response = service.filterArende(params);
verify(webcertUserService).getUser();
verify(arendeRepository).filterArende(any(Filter.class));
// verify(arendeRepository).filterArendeCount(any(Filter.class));
verify(fragaSvarService).filterFragaSvar(any(Filter.class));
assertEquals(0, response.getResults().size());
// assertEquals(4, response.getTotalCount());
}
use of se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarResponse in project webcert by sklintyg.
the class ArendeServiceTest method testFilterArendeFiltersOutNonVerifiedSekretessPatients.
@Test
@SuppressWarnings("unchecked")
public void testFilterArendeFiltersOutNonVerifiedSekretessPatients() {
WebCertUser webCertUser = createUser();
Map<Personnummer, SekretessStatus> map = mock(Map.class);
when(map.get(any(Personnummer.class))).thenReturn(SekretessStatus.UNDEFINED);
doReturn(map).when(patientDetailsResolver).getSekretessStatusForList(anyList());
when(webcertUserService.getUser()).thenReturn(webCertUser);
when(webcertUserService.isAuthorizedForUnit(any(), eq(true))).thenReturn(true);
List<Arende> queryResults = new ArrayList<>();
queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now(), null));
queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now().minusDays(1), null));
when(arendeRepository.filterArende(any(Filter.class))).thenReturn(queryResults);
QueryFragaSvarResponse fsResponse = new QueryFragaSvarResponse();
fsResponse.setResults(new ArrayList<>());
fsResponse.setTotalCount(0);
when(fragaSvarService.filterFragaSvar(any(Filter.class))).thenReturn(fsResponse);
QueryFragaSvarParameter params = new QueryFragaSvarParameter();
params.setEnhetId(webCertUser.getValdVardenhet().getId());
QueryFragaSvarResponse response = service.filterArende(params);
verify(patientDetailsResolver, times(1)).getSekretessStatusForList(anyList());
verify(webcertUserService).isAuthorizedForUnit(anyString(), eq(true));
verify(arendeRepository).filterArende(any(Filter.class));
verify(fragaSvarService).filterFragaSvar(any(Filter.class));
assertEquals(0, response.getResults().size());
}
use of se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarResponse in project webcert by sklintyg.
the class ArendeServiceTest method testFilterArendeSelection.
@Test
public void testFilterArendeSelection() {
when(webcertUserService.getUser()).thenReturn(createUser());
when(authoritiesHelper.getIntygstyperForPrivilege(any(UserDetails.class), any())).thenReturn(new HashSet<>());
List<Arende> queryResults = new ArrayList<>();
queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now(), null));
queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now().plusDays(1), null));
when(arendeRepository.filterArende(any(Filter.class))).thenReturn(queryResults);
QueryFragaSvarResponse fsResponse = new QueryFragaSvarResponse();
fsResponse.setResults(new ArrayList<>());
fsResponse.getResults().add(buildArendeListItem("intyg1", LocalDateTime.now().minusDays(1)));
fsResponse.setTotalCount(1);
when(fragaSvarService.filterFragaSvar(any(Filter.class))).thenReturn(fsResponse);
QueryFragaSvarParameter params = new QueryFragaSvarParameter();
params.setStartFrom(2);
params.setPageSize(10);
QueryFragaSvarResponse response = service.filterArende(params);
verify(webcertUserService).getUser();
verify(arendeRepository, atLeastOnce()).filterArende(any(Filter.class));
// verify(arendeRepository).filterArendeCount(any(Filter.class));
verify(fragaSvarService).filterFragaSvar(any());
assertEquals(1, response.getResults().size());
// assertEquals(4, response.getTotalCount());
}
use of se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarResponse in project webcert by sklintyg.
the class ArendeServiceTest method testFilterArendeSortsArendeListItemsByReceivedDate.
@Test
public void testFilterArendeSortsArendeListItemsByReceivedDate() {
final String intygId1 = "intygId1";
final String intygId2 = "intygId2";
final String intygId3 = "intygId3";
final String MEDDELANDE_ID = "arendeWithPaminnelseMEDDELANDE_ID";
when(webcertUserService.getUser()).thenReturn(createUser());
List<Arende> queryResults = new ArrayList<>();
queryResults.add(buildArende(UUID.randomUUID().toString(), intygId3, LocalDateTime.now().plusDays(2), null, ENHET_ID));
Arende arendeWithPaminnelse = buildArende(UUID.randomUUID().toString(), intygId2, LocalDateTime.now(), null, ENHET_ID);
arendeWithPaminnelse.setMeddelandeId(MEDDELANDE_ID);
queryResults.add(arendeWithPaminnelse);
when(arendeRepository.filterArende(any(Filter.class))).thenReturn(queryResults);
QueryFragaSvarResponse fsResponse = new QueryFragaSvarResponse();
fsResponse.setResults(new ArrayList<>());
fsResponse.getResults().add(buildArendeListItem(intygId1, LocalDateTime.now().minusDays(1)));
fsResponse.setTotalCount(1);
when(fragaSvarService.filterFragaSvar(any(Filter.class))).thenReturn(fsResponse);
QueryFragaSvarParameter params = new QueryFragaSvarParameter();
QueryFragaSvarResponse response = service.filterArende(params);
assertEquals(3, response.getResults().size());
assertEquals(intygId3, response.getResults().get(0).getIntygId());
assertEquals(intygId2, response.getResults().get(1).getIntygId());
assertEquals(intygId1, response.getResults().get(2).getIntygId());
}
use of se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarResponse in project webcert by sklintyg.
the class FragaSvarApiController method query.
@GET
@Path("/sok")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response query(@QueryParam("") QueryFragaSvarParameter queryParam) {
authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR).orThrow();
QueryFragaSvarResponse result = arendeService.filterArende(queryParam);
LOG.debug("/api/fragasvar/sok about to return : " + result.getTotalCount());
return Response.ok(result).build();
}
Aggregations