Search in sources :

Example 1 with PersonuppgifterResponse

use of se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse in project webcert by sklintyg.

the class PersonApiControllerTest method testGetPersonuppgifterMissingPerson.

@Test
public void testGetPersonuppgifterMissingPerson() {
    Personnummer personnummer = createPnr("19010101-0101");
    when(puService.getPerson(any(Personnummer.class))).thenReturn(new PersonSvar(null, PersonSvar.Status.NOT_FOUND));
    Response response = personCtrl.getPersonuppgifter(personnummer.getPersonnummer());
    assertNotNull(response);
    assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
    PersonuppgifterResponse res = (PersonuppgifterResponse) response.getEntity();
    assertEquals(PersonSvar.Status.NOT_FOUND, res.getStatus());
    assertNull(res.getPerson());
    verify(mockMonitoringService).logPULookup(personnummer, "NOT_FOUND");
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) Response(javax.ws.rs.core.Response) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Test(org.junit.Test)

Example 2 with PersonuppgifterResponse

use of se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse in project webcert by sklintyg.

the class PersonApiControllerTest method testGetPersonuppgifter.

@Test
public void testGetPersonuppgifter() {
    Personnummer personnummer = createPnr("19121212-1212");
    when(puService.getPerson(any(Personnummer.class))).thenReturn(new PersonSvar(new Person(personnummer, false, false, "fnamn", "mnamn", "enamn", "paddr", "pnr", "port"), PersonSvar.Status.FOUND));
    Response response = personCtrl.getPersonuppgifter(personnummer.getPersonnummer());
    assertNotNull(response);
    assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
    PersonuppgifterResponse res = (PersonuppgifterResponse) response.getEntity();
    assertEquals(PersonSvar.Status.FOUND, res.getStatus());
    assertEquals(false, res.getPerson().isSekretessmarkering());
    assertEquals("fnamn", res.getPerson().getFornamn());
    assertEquals("mnamn", res.getPerson().getMellannamn());
    assertEquals("enamn", res.getPerson().getEfternamn());
    assertEquals("paddr", res.getPerson().getPostadress());
    assertEquals("pnr", res.getPerson().getPostnummer());
    assertEquals("port", res.getPerson().getPostort());
    verify(mockMonitoringService).logPULookup(personnummer, "FOUND");
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) Response(javax.ws.rs.core.Response) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Person(se.inera.intyg.infra.integration.pu.model.Person) Test(org.junit.Test)

Example 3 with PersonuppgifterResponse

use of se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse in project webcert by sklintyg.

the class PersonApiControllerTest method testGetPersonuppgifterSekretess.

@Test
public void testGetPersonuppgifterSekretess() {
    Personnummer personnummer = createPnr("19121212-1212");
    when(puService.getPerson(any(Personnummer.class))).thenReturn(new PersonSvar(new Person(personnummer, true, false, "fnamn", "mnamn", "enamn", "paddr", "pnr", "port"), PersonSvar.Status.FOUND));
    Response response = personCtrl.getPersonuppgifter(personnummer.getPersonnummer());
    assertNotNull(response);
    assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
    PersonuppgifterResponse res = (PersonuppgifterResponse) response.getEntity();
    assertEquals(PersonSvar.Status.FOUND, res.getStatus());
    assertEquals(true, res.getPerson().isSekretessmarkering());
    assertEquals("fnamn", res.getPerson().getFornamn());
    assertEquals("mnamn", res.getPerson().getMellannamn());
    assertEquals("enamn", res.getPerson().getEfternamn());
    assertEquals("paddr", res.getPerson().getPostadress());
    assertEquals("pnr", res.getPerson().getPostnummer());
    assertEquals("port", res.getPerson().getPostort());
    verify(mockMonitoringService).logPULookup(personnummer, "FOUND");
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) Response(javax.ws.rs.core.Response) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Person(se.inera.intyg.infra.integration.pu.model.Person) Test(org.junit.Test)

Example 4 with PersonuppgifterResponse

use of se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse in project webcert by sklintyg.

the class PersonApiController method getPersonuppgifter.

@GET
@Path("/{personnummer}")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response getPersonuppgifter(@PathParam("personnummer") String personnummerIn) {
    try {
        Personnummer personnummer = createPnr(personnummerIn);
        LOG.debug("Hämtar personuppgifter för: {}", personnummer.getPersonnummerHash());
        PersonSvar personSvar = puService.getPerson(personnummer);
        monitoringService.logPULookup(personnummer, personSvar.getStatus().name());
        return Response.ok(new PersonuppgifterResponse(personSvar)).build();
    } catch (InvalidPersonNummerException e) {
        LOG.error(e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).build();
    }
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) InvalidPersonNummerException(se.inera.intyg.schemas.contract.InvalidPersonNummerException) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)4 Personnummer (se.inera.intyg.schemas.contract.Personnummer)4 PersonuppgifterResponse (se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse)4 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3 Person (se.inera.intyg.infra.integration.pu.model.Person)2 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 InvalidPersonNummerException (se.inera.intyg.schemas.contract.InvalidPersonNummerException)1