@Test public void testFilterDraftsForUnitSkipsSekretessIntygForUserWithoutAuthorithy() { setupUser("", LuseEntryPoint.MODULE_ID, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST); Map<Personnummer, SekretessStatus> sekretessMap = mock(Map.class); when(sekretessMap.get(eq(PATIENT_PERSONNUMMER))).thenReturn(SekretessStatus.FALSE); when(sekretessMap.get(eq(PATIENT_PERSONNUMMER_PU_SEKRETESS))).thenReturn(SekretessStatus.TRUE); when(patientDetailsResolver.getSekretessStatusForList(anyList())).thenReturn(sekretessMap); Map<Personnummer, Boolean> testIndicatorMap = mock(Map.class); when(testIndicatorMap.get(eq(PATIENT_PERSONNUMMER))).thenReturn(Boolean.FALSE); when(testIndicatorMap.get(eq(PATIENT_PERSONNUMMER_PU_SEKRETESS))).thenReturn(Boolean.FALSE); when(patientDetailsResolver.getTestIndicatorForList(anyList())).thenReturn(testIndicatorMap); when(utkastService.filterIntyg(any())) .thenReturn(Arrays.asList(buildUtkast(PATIENT_PERSONNUMMER), buildUtkast(PATIENT_PERSONNUMMER_PU_SEKRETESS))); final Response response = utkastController.filterDraftsForUnit(buildQueryIntygParameter()); final QueryIntygResponse queryIntygResponse = response.readEntity(QueryIntygResponse.class); assertEquals(1, queryIntygResponse.getTotalCount()); assertEquals(1, queryIntygResponse.getResults().size()); assertEquals(PATIENT_PERSONNUMMER, queryIntygResponse.getResults().get(0).getPatientId()); }
@GET @Path("/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod public Response filterDraftsForUnit(@QueryParam("") QueryIntygParameter filterParameters) { authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).orThrow(); UtkastFilter utkastFilter = createUtkastFilter(filterParameters); QueryIntygResponse queryResponse = performUtkastFilterQuery(utkastFilter); return Response.ok(queryResponse).build(); }
UtkastApiController extends AbstractApiController { @GET @Path("/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod public Response filterDraftsForUnit(@QueryParam("") QueryIntygParameter filterParameters) { authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).orThrow(); UtkastFilter utkastFilter = createUtkastFilter(filterParameters); QueryIntygResponse queryResponse = performUtkastFilterQuery(utkastFilter); return Response.ok(queryResponse).build(); } }
UtkastApiController extends AbstractApiController { @GET @Path("/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod public Response filterDraftsForUnit(@QueryParam("") QueryIntygParameter filterParameters) { authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).orThrow(); UtkastFilter utkastFilter = createUtkastFilter(filterParameters); QueryIntygResponse queryResponse = performUtkastFilterQuery(utkastFilter); return Response.ok(queryResponse).build(); }  }
UtkastApiController extends AbstractApiController { @GET @Path("/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod public Response filterDraftsForUnit(@QueryParam("") QueryIntygParameter filterParameters) { authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).orThrow(); UtkastFilter utkastFilter = createUtkastFilter(filterParameters); QueryIntygResponse queryResponse = performUtkastFilterQuery(utkastFilter); return Response.ok(queryResponse).build(); }  @POST @Path("/{intygsTyp}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response createUtkast(@PathParam("intygsTyp") String intygsTyp, CreateUtkastRequest request); @GET @Path("/questions/{intygsTyp}/{version}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response getQuestions(@PathParam("intygsTyp") String intygsTyp, @PathParam("version") String version); @GET @Path("/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response filterDraftsForUnit(@QueryParam("") QueryIntygParameter filterParameters); @GET @Path("/lakare") @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response getLakareWithDraftsByEnheter(); @GET @Path("/previousIntyg/{personnummer}/{currentDraftId}") @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response getPreviousCertificateWarnings(@PathParam("personnummer") String personnummer,
                                                   @PathParam("currentDraftId") String currentDraftId); }
UtkastApiController extends AbstractApiController { @GET @Path("/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod public Response filterDraftsForUnit(@QueryParam("") QueryIntygParameter filterParameters) { authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).orThrow(); UtkastFilter utkastFilter = createUtkastFilter(filterParameters); QueryIntygResponse queryResponse = performUtkastFilterQuery(utkastFilter); return Response.ok(queryResponse).build(); }  @POST @Path("/{intygsTyp}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response createUtkast(@PathParam("intygsTyp") String intygsTyp, CreateUtkastRequest request); @GET @Path("/questions/{intygsTyp}/{version}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response getQuestions(@PathParam("intygsTyp") String intygsTyp, @PathParam("version") String version); @GET @Path("/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response filterDraftsForUnit(@QueryParam("") QueryIntygParameter filterParameters); @GET @Path("/lakare") @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response getLakareWithDraftsByEnheter(); @GET @Path("/previousIntyg/{personnummer}/{currentDraftId}") @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response getPreviousCertificateWarnings(@PathParam("personnummer") String personnummer,
                                                   @PathParam("currentDraftId") String currentDraftId);  }