Search in sources :

Example 1 with ValidatePrivatePractitionerResponseType

use of se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerResponseType in project webcert by sklintyg.

the class ValidatePrivatePractitionerResponderStub method validatePrivatePractitioner.

@Override
public ValidatePrivatePractitionerResponseType validatePrivatePractitioner(String logicalAddress, ValidatePrivatePractitionerType parameters) {
    // Do validation of parameters object
    validate(parameters);
    String id = parameters.getPersonalIdentityNumber();
    Personnummer personnummer = Personnummer.createPersonnummer(id).orElse(null);
    ValidatePrivatePractitionerResponseType response = new ValidatePrivatePractitionerResponseType();
    HoSPersonType person = personStub.get(id);
    if (person == null) {
        response.setResultCode(ResultCodeEnum.ERROR);
        response.setResultText("No private practitioner with personal identity number: " + Personnummer.getPersonnummerHashSafe(personnummer) + " exists.");
    } else if (person.isGodkandAnvandare()) {
        response.setResultCode(ResultCodeEnum.OK);
    } else {
        response.setResultCode(ResultCodeEnum.ERROR);
        response.setResultText("Private practitioner with personal identity number: " + Personnummer.getPersonnummerHashSafe(personnummer) + " is not authorized to use webcert.");
    }
    return response;
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ValidatePrivatePractitionerResponseType(se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerResponseType) HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType)

Example 2 with ValidatePrivatePractitionerResponseType

use of se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerResponseType in project webcert by sklintyg.

the class ValidatePrivatePractitionerResponderTest method verifyNonExistingPerson.

@Test
public void verifyNonExistingPerson() {
    // Given
    ValidatePrivatePractitionerType request = defaultRequest();
    request.setPersonalIdentityNumber("1901010101-0101");
    // When
    when(personStub.get("1901010101-0101")).thenReturn(null);
    // Call web service
    ValidatePrivatePractitionerResponseType actual = ws.validatePrivatePractitioner("address", request);
    // Then
    assertTrue(ResultCodeEnum.ERROR == actual.getResultCode());
    verify(personStub, times(1)).get("1901010101-0101");
}
Also used : ValidatePrivatePractitionerType(se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerType) ValidatePrivatePractitionerResponseType(se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerResponseType) Test(org.junit.Test)

Example 3 with ValidatePrivatePractitionerResponseType

use of se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerResponseType in project webcert by sklintyg.

the class ValidatePrivatePractitionerResponderTest method verifyExistingPerson.

@Test
public void verifyExistingPerson() {
    // Given
    ObjectCreator objectCreator = new ObjectCreator();
    HoSPersonType hoSPersonType = objectCreator.getHoSPersonType();
    ValidatePrivatePractitionerType request = defaultRequest();
    ValidatePrivatePractitionerResponseType expected = new ValidatePrivatePractitionerResponseType();
    expected.setResultCode(ResultCodeEnum.OK);
    // When
    when(personStub.get(PERSONNUMMER)).thenReturn(hoSPersonType);
    // Call web service
    ValidatePrivatePractitionerResponseType actual = ws.validatePrivatePractitioner("address", request);
    // Then
    assertTrue(ResultCodeEnum.OK == actual.getResultCode());
    verify(personStub, times(1)).get(PERSONNUMMER);
}
Also used : ValidatePrivatePractitionerType(se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerType) ValidatePrivatePractitionerResponseType(se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerResponseType) HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType) ObjectCreator(se.inera.intyg.webcert.integration.pp.util.ObjectCreator) Test(org.junit.Test)

Aggregations

ValidatePrivatePractitionerResponseType (se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerResponseType)3 Test (org.junit.Test)2 HoSPersonType (se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType)2 ValidatePrivatePractitionerType (se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerType)2 Personnummer (se.inera.intyg.schemas.contract.Personnummer)1 ObjectCreator (se.inera.intyg.webcert.integration.pp.util.ObjectCreator)1