### Question:
PaymentSpiImpl implements PaymentSpi { @Override public <P extends SpiPayment> SpiResponse<? extends SpiPaymentInitiationResponse> initiatePayment(@NotNull SpiContextData contextData, @NotNull P spiPayment, @NotNull SpiAspspConsentDataProvider aspspConsentDataProvider) throws NotSupportedPaymentTypeException { PaymentType paymentType = spiPayment.getPaymentType(); switch (paymentType) { case SINGLE: return singlePaymentSpi.initiatePayment(contextData, (@NotNull SpiSinglePayment) spiPayment, aspspConsentDataProvider); case BULK: return bulkPaymentSpi.initiatePayment(contextData, (@NotNull SpiBulkPayment) spiPayment, aspspConsentDataProvider); case PERIODIC: return periodicPaymentSpi.initiatePayment(contextData, (@NotNull SpiPeriodicPayment) spiPayment, aspspConsentDataProvider); default: throw new NotSupportedPaymentTypeException(String.format("Unknown payment type: %s", paymentType.getValue())); } }  @Override SpiResponse<? extends SpiPaymentInitiationResponse> initiatePayment(@NotNull SpiContextData contextData,
                                                                                                      @NotNull P spiPayment,
                                                                                                      @NotNull SpiAspspConsentDataProvider aspspConsentDataProvider);  }### Answer:
@Test void initiatePayment_singlePayment() throws NotSupportedPaymentTypeException { SpiSinglePayment spiPayment = new SpiSinglePayment(PAYMENT_PRODUCT); when(singlePaymentSpi.initiatePayment(SPI_CONTEXT_DATA, spiPayment, spiAspspConsentDataProvider)).thenReturn(SpiResponse.<SpiSinglePaymentInitiationResponse>builder() .build()); paymentSpi.initiatePayment(SPI_CONTEXT_DATA, spiPayment, spiAspspConsentDataProvider); verify(singlePaymentSpi, times(1)).initiatePayment(SPI_CONTEXT_DATA, spiPayment, spiAspspConsentDataProvider); }
@Test void initiatePayment_periodicPayment() throws NotSupportedPaymentTypeException { SpiPeriodicPayment spiPayment = new SpiPeriodicPayment(PAYMENT_PRODUCT); when(periodicPaymentSpi.initiatePayment(SPI_CONTEXT_DATA, spiPayment, spiAspspConsentDataProvider)).thenReturn(SpiResponse.<SpiPeriodicPaymentInitiationResponse>builder() .build()); paymentSpi.initiatePayment(SPI_CONTEXT_DATA, spiPayment, spiAspspConsentDataProvider); verify(periodicPaymentSpi, times(1)).initiatePayment(SPI_CONTEXT_DATA, spiPayment, spiAspspConsentDataProvider); }
@Test void initiatePayment_bulkPayment() throws NotSupportedPaymentTypeException { SpiBulkPayment spiPayment = new SpiBulkPayment(); when(bulkPaymentSpi.initiatePayment(SPI_CONTEXT_DATA, spiPayment, spiAspspConsentDataProvider)).thenReturn(SpiResponse.<SpiBulkPaymentInitiationResponse>builder() .build()); paymentSpi.initiatePayment(SPI_CONTEXT_DATA, spiPayment, spiAspspConsentDataProvider); verify(bulkPaymentSpi, times(1)).initiatePayment(SPI_CONTEXT_DATA, spiPayment, spiAspspConsentDataProvider); }