### Question:
AIS401ErrorMapper extends Psd2ErrorMapper<MessageError, Error401NGAIS> { @Override public Function<MessageError, Error401NGAIS> getMapper() { return this::mapToPsd2Error; }  @Override Function<MessageError, Error401NGAIS> getMapper(); @Override HttpStatus getErrorStatus();  }### Answer:
@Test void getMapper_shouldReturnCorrectErrorMapper() { Error401NGAIS expectedError = jsonReader.getObjectFromFile(ERROR_JSON_PATH, Error401NGAIS.class); when(messageService.getMessage(CONSENT_INVALID.getName())).thenReturn("The %s was created by this TPP but is not valid for the addressed service/resource"); Function<MessageError, Error401NGAIS> mapper = ais401ErrorMapper.getMapper(); Error401NGAIS actualError = mapper.apply(MESSAGE_ERROR); assertEquals(expectedError, actualError); }
@Test void getMapper_withNoTextInTppMessage_shouldGetTextFromMessageService() { when(messageService.getMessage(CONSENT_INVALID.name())) .thenReturn(CUSTOM_ERROR_TEXT); Error401NGAIS expectedError = jsonReader.getObjectFromFile(ERROR_CUSTOM_TEXT_JSON_PATH, Error401NGAIS.class); Function<MessageError, Error401NGAIS> mapper = ais401ErrorMapper.getMapper(); Error401NGAIS actualError = mapper.apply(MESSAGE_ERROR_WITHOUT_TEXT); assertEquals(expectedError, actualError); verify(messageService).getMessage(CONSENT_INVALID.name()); }