### Question:
AuthorisationProcessor { AuthorisationProcessorService getProcessorService(AuthorisationProcessorRequest request) { if (request.getServiceType() == ServiceType.AIS) { return applicationContext.getBean(AisAuthorisationProcessorServiceImpl.class); } else if (request.getServiceType() == ServiceType.PIS && request.getAuthorisation().getAuthorisationType() == AuthorisationType.PIS_CREATION) { return applicationContext.getBean(PisAuthorisationProcessorServiceImpl.class); } else if (request.getServiceType() == ServiceType.PIS && request.getAuthorisation().getAuthorisationType() == AuthorisationType.PIS_CANCELLATION) { return applicationContext.getBean(PisCancellationAuthorisationProcessorServiceImpl.class); } else if (request.getServiceType() == ServiceType.PIIS) { return applicationContext.getBean(PiisAuthorisationProcessorServiceImpl.class); } throw new IllegalArgumentException("Authorisation processor service is unknown: " + request); } AuthorisationProcessor(ApplicationContext applicationContext); void setNext(AuthorisationProcessor nextProcessor); abstract ScaStatus getScaStatus(); AuthorisationProcessorResponse apply(AuthorisationProcessorRequest request);  }### Answer:
@Test void getProcessorService_AIS() { request.setServiceType(ServiceType.AIS); when(applicationContext.getBean(AisAuthorisationProcessorServiceImpl.class)).thenReturn(aisAuthorisationProcessorServiceImpl); authorisationProcessor.getProcessorService(request); verify(applicationContext, times(1)).getBean(AisAuthorisationProcessorServiceImpl.class); }
@Test void getProcessorService_PIIS() { request.setServiceType(ServiceType.PIIS); when(applicationContext.getBean(PiisAuthorisationProcessorServiceImpl.class)).thenReturn(piisAuthorisationProcessorService); authorisationProcessor.getProcessorService(request); verify(applicationContext, times(1)).getBean(PiisAuthorisationProcessorServiceImpl.class); }
@Test void getProcessorService_PIS_initiation() { request.setServiceType(ServiceType.PIS); Authorisation authorisation = new Authorisation(); authorisation.setAuthorisationType(AuthorisationType.PIS_CREATION); request.setAuthorisation(authorisation); when(applicationContext.getBean(PisAuthorisationProcessorServiceImpl.class)).thenReturn(pisAuthorisationProcessorService); authorisationProcessor.getProcessorService(request); verify(applicationContext, times(1)).getBean(PisAuthorisationProcessorServiceImpl.class); }
@Test void getProcessorService_PIS_cancellation() { request.setServiceType(ServiceType.PIS); Authorisation authorisation = new Authorisation(); authorisation.setAuthorisationType(AuthorisationType.PIS_CANCELLATION); request.setAuthorisation(authorisation); when(applicationContext.getBean(PisCancellationAuthorisationProcessorServiceImpl.class)).thenReturn(pisCancellationAuthorisationProcessorServiceImpl); authorisationProcessor.getProcessorService(request); verify(applicationContext, times(1)).getBean(PisCancellationAuthorisationProcessorServiceImpl.class); }
@Test void getProcessorService_PIS_noPaymentAuthorisationType() { request.setServiceType(ServiceType.PIS); Authorisation authorisation = new Authorisation(); request.setAuthorisation(authorisation); assertThrows(IllegalArgumentException.class, () -> authorisationProcessor.getProcessorService(request)); verify(applicationContext, never()).getBean(anyString()); }