Search in sources :

Example 1 with ValidatePrivatePractitionerType

use of se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerType 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 ValidatePrivatePractitionerType

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

the class ValidatePrivatePractitionerResponderTest method defaultRequest.

private ValidatePrivatePractitionerType defaultRequest() {
    ValidatePrivatePractitionerType request = new ValidatePrivatePractitionerType();
    request.setPersonalIdentityNumber(PERSONNUMMER);
    return request;
}
Also used : ValidatePrivatePractitionerType(se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerType)

Example 3 with ValidatePrivatePractitionerType

use of se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerType 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 4 with ValidatePrivatePractitionerType

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

the class ValidatePrivatePractitionerResponderTest method noPersonIdThrowsException.

@Test(expected = IllegalArgumentException.class)
public void noPersonIdThrowsException() {
    ValidatePrivatePractitionerType request = new ValidatePrivatePractitionerType();
    ws.validatePrivatePractitioner(null, request);
}
Also used : ValidatePrivatePractitionerType(se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerType) Test(org.junit.Test)

Example 5 with ValidatePrivatePractitionerType

use of se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerType 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

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