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;
}
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");
}
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);
}
Aggregations