@Test public void testCreateRenewalWithNewPatientInfo() { final String personnummer = "191212121212"; final String newIntygId = "newIntygId"; final String efternamn = "efternamn"; final String fornamn = "fornamn"; final String mellannamn = "mellannamn"; final String postadress = "postadress"; final String postort = "postort"; final String postnummer = "postnummer"; final String newPersonnummer = "201212121212"; CopyIntygRequest copyIntygRequest = new CopyIntygRequest(); copyIntygRequest.setPatientPersonnummer(createPnr(personnummer)); WebCertUser user = new WebCertUser(); user.setParameters(new IntegrationParameters(null, null, newPersonnummer, fornamn, mellannamn, efternamn, postadress, postnummer, postort, false, false, false, true)); addFeatures(user, CERTIFICATE_TYPE, AuthoritiesConstants.FEATURE_FORNYA_INTYG); addPrivileges(user, CERTIFICATE_TYPE, AuthoritiesConstants.PRIVILEGE_FORNYA_INTYG); user.setOrigin("NORMAL"); ArgumentCaptor<CreateRenewalCopyRequest> captor = ArgumentCaptor.forClass(CreateRenewalCopyRequest.class); when(copyUtkastService.createRenewalCopy(captor.capture())) .thenReturn(new CreateRenewalCopyResponse(CERTIFICATE_TYPE, CERTIFICATE_VERSION, newIntygId, CERTIFICATE_ID)); when(webcertUserService.getUser()).thenReturn(user); Response response = moduleApiController.createRenewal(copyIntygRequest, CERTIFICATE_TYPE, CERTIFICATE_ID); verify(copyUtkastService).createRenewalCopy(any()); verifyNoMoreInteractions(copyUtkastService); assertEquals(newIntygId, ((CopyIntygResponse) response.getEntity()).getIntygsUtkastId()); assertEquals(personnummer, captor.getValue().getPatient().getPersonId().getPersonnummer()); assertEquals(fornamn, captor.getValue().getPatient().getFornamn()); assertEquals(efternamn, captor.getValue().getPatient().getEfternamn()); assertEquals(mellannamn, captor.getValue().getPatient().getMellannamn()); assertEquals(postadress, captor.getValue().getPatient().getPostadress()); assertEquals(postnummer, captor.getValue().getPatient().getPostnummer()); assertEquals(postort, captor.getValue().getPatient().getPostort()); assertEquals(newPersonnummer, captor.getValue().getNyttPatientPersonnummer().getPersonnummer()); }
@POST @Path("/{intygsTyp}/{intygsId}/fornya") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) public Response createRenewal(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String orgIntygsId) { LOG.debug("Attempting to create a renewal of {} with id '{}'", intygsTyp, orgIntygsId); if (!request.isValid()) { LOG.error("Request to create renewal of '{}' is not valid", orgIntygsId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload"); } CreateRenewalCopyRequest serviceRequest = copyUtkastServiceHelper.createRenewalCopyRequest(orgIntygsId, intygsTyp, request); CreateRenewalCopyResponse serviceResponse = copyUtkastService.createRenewalCopy(serviceRequest); LOG.debug("Created a new draft with id: '{}' and type: {}, renewing certificate with id '{}'.", serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), orgIntygsId); CopyIntygResponse response = new CopyIntygResponse(serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), serviceResponse.getNewDraftIntygTypeVersion()); return Response.ok().entity(response).build(); }
IntygModuleApiController extends AbstractApiController { @POST @Path("/{intygsTyp}/{intygsId}/fornya") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) public Response createRenewal(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String orgIntygsId) { LOG.debug("Attempting to create a renewal of {} with id '{}'", intygsTyp, orgIntygsId); if (!request.isValid()) { LOG.error("Request to create renewal of '{}' is not valid", orgIntygsId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload"); } CreateRenewalCopyRequest serviceRequest = copyUtkastServiceHelper.createRenewalCopyRequest(orgIntygsId, intygsTyp, request); CreateRenewalCopyResponse serviceResponse = copyUtkastService.createRenewalCopy(serviceRequest); LOG.debug("Created a new draft with id: '{}' and type: {}, renewing certificate with id '{}'.", serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), orgIntygsId); CopyIntygResponse response = new CopyIntygResponse(serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), serviceResponse.getNewDraftIntygTypeVersion()); return Response.ok().entity(response).build(); } }
IntygModuleApiController extends AbstractApiController { @POST @Path("/{intygsTyp}/{intygsId}/fornya") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) public Response createRenewal(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String orgIntygsId) { LOG.debug("Attempting to create a renewal of {} with id '{}'", intygsTyp, orgIntygsId); if (!request.isValid()) { LOG.error("Request to create renewal of '{}' is not valid", orgIntygsId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload"); } CreateRenewalCopyRequest serviceRequest = copyUtkastServiceHelper.createRenewalCopyRequest(orgIntygsId, intygsTyp, request); CreateRenewalCopyResponse serviceResponse = copyUtkastService.createRenewalCopy(serviceRequest); LOG.debug("Created a new draft with id: '{}' and type: {}, renewing certificate with id '{}'.", serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), orgIntygsId); CopyIntygResponse response = new CopyIntygResponse(serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), serviceResponse.getNewDraftIntygTypeVersion()); return Response.ok().entity(response).build(); }  }
IntygModuleApiController extends AbstractApiController { @POST @Path("/{intygsTyp}/{intygsId}/fornya") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) public Response createRenewal(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String orgIntygsId) { LOG.debug("Attempting to create a renewal of {} with id '{}'", intygsTyp, orgIntygsId); if (!request.isValid()) { LOG.error("Request to create renewal of '{}' is not valid", orgIntygsId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload"); } CreateRenewalCopyRequest serviceRequest = copyUtkastServiceHelper.createRenewalCopyRequest(orgIntygsId, intygsTyp, request); CreateRenewalCopyResponse serviceResponse = copyUtkastService.createRenewalCopy(serviceRequest); LOG.debug("Created a new draft with id: '{}' and type: {}, renewing certificate with id '{}'.", serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), orgIntygsId); CopyIntygResponse response = new CopyIntygResponse(serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), serviceResponse.getNewDraftIntygTypeVersion()); return Response.ok().entity(response).build(); }  @GET @Path("/{intygsTyp}/{intygsId}") @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response getIntyg(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId); @GET @Path("/{intygsTyp}/{intygsId}/pdf") @Produces("application/pdf") final Response getIntygAsPdf(@PathParam("intygsTyp") String intygsTyp, @PathParam(value = "intygsId") final String intygsId); @GET @Path("/{intygsTyp}/{intygsId}/pdf/arbetsgivarutskrift") @Produces("application/pdf") final Response getIntygAsPdfForEmployer(@PathParam("intygsTyp") String intygsTyp,
        @PathParam(value = "intygsId") final String intygsId); @POST @Path("/{intygsTyp}/{intygsId}/skicka") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response sendSignedIntyg(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        SendSignedIntygParameter param); @POST @Path("/{intygsTyp}/{intygsId}/aterkalla") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response revokeSignedIntyg(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        RevokeSignedIntygParameter param); @POST @Path("/{intygsTyp}/{intygsId}/komplettera") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response createCompletion(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp,
        @PathParam("intygsId") String orgIntygsId); @POST @Path("/{intygsTyp}/{intygsId}/fornya") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response createRenewal(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp,
        @PathParam("intygsId") String orgIntygsId); @POST @Path("/{intygsTyp}/{intygsId}/{newIntygsTyp}/create") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response createUtkastFromSignedTemplate(CopyIntygRequest request, @PathParam("intygsTyp") String orgIntygsTyp,
        @PathParam("intygsId") String orgIntygsId, @PathParam("newIntygsTyp") String newIntygsTyp); @POST @Path("/{intygsTyp}/{intygsId}/ersatt") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response createReplacement(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp,
        @PathParam("intygsId") String orgIntygsId); }
IntygModuleApiController extends AbstractApiController { @POST @Path("/{intygsTyp}/{intygsId}/fornya") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) public Response createRenewal(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String orgIntygsId) { LOG.debug("Attempting to create a renewal of {} with id '{}'", intygsTyp, orgIntygsId); if (!request.isValid()) { LOG.error("Request to create renewal of '{}' is not valid", orgIntygsId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload"); } CreateRenewalCopyRequest serviceRequest = copyUtkastServiceHelper.createRenewalCopyRequest(orgIntygsId, intygsTyp, request); CreateRenewalCopyResponse serviceResponse = copyUtkastService.createRenewalCopy(serviceRequest); LOG.debug("Created a new draft with id: '{}' and type: {}, renewing certificate with id '{}'.", serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), orgIntygsId); CopyIntygResponse response = new CopyIntygResponse(serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), serviceResponse.getNewDraftIntygTypeVersion()); return Response.ok().entity(response).build(); }  @GET @Path("/{intygsTyp}/{intygsId}") @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response getIntyg(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId); @GET @Path("/{intygsTyp}/{intygsId}/pdf") @Produces("application/pdf") final Response getIntygAsPdf(@PathParam("intygsTyp") String intygsTyp, @PathParam(value = "intygsId") final String intygsId); @GET @Path("/{intygsTyp}/{intygsId}/pdf/arbetsgivarutskrift") @Produces("application/pdf") final Response getIntygAsPdfForEmployer(@PathParam("intygsTyp") String intygsTyp,
        @PathParam(value = "intygsId") final String intygsId); @POST @Path("/{intygsTyp}/{intygsId}/skicka") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response sendSignedIntyg(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        SendSignedIntygParameter param); @POST @Path("/{intygsTyp}/{intygsId}/aterkalla") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response revokeSignedIntyg(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        RevokeSignedIntygParameter param); @POST @Path("/{intygsTyp}/{intygsId}/komplettera") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response createCompletion(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp,
        @PathParam("intygsId") String orgIntygsId); @POST @Path("/{intygsTyp}/{intygsId}/fornya") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response createRenewal(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp,
        @PathParam("intygsId") String orgIntygsId); @POST @Path("/{intygsTyp}/{intygsId}/{newIntygsTyp}/create") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response createUtkastFromSignedTemplate(CopyIntygRequest request, @PathParam("intygsTyp") String orgIntygsTyp,
        @PathParam("intygsId") String orgIntygsId, @PathParam("newIntygsTyp") String newIntygsTyp); @POST @Path("/{intygsTyp}/{intygsId}/ersatt") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) Response createReplacement(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp,
        @PathParam("intygsId") String orgIntygsId);  }