CallWebserviceProcessor implements ItemProcessor<TaxCalculation, TaxWebserviceCallResult> { @Override public TaxWebserviceCallResult process(TaxCalculation taxCalculation) throws Exception { LOG.info("Web service process: " + taxCalculation); RetryTemplate retryTemplate = retryConfig.createRetryTemplate(); Callable<Void> callable = () -> retryTemplate.execute(doWebserviceCallWithRetryCallback(taxCalculation)); TaxWebserviceCallResult taxWebserviceCallResult = taxPaymentWebServiceFacade.callTaxService(taxCalculation, callable); return taxWebserviceCallResult; }  @Override TaxWebserviceCallResult process(TaxCalculation taxCalculation);  }
@Test public void testProcessHappyPath_NoExceptionHasBeenThrownAndEmployeeIsReturned() throws Exception { when(taxPaymentWebServiceFacade.callTaxService(eq(taxCalculation), any(Callable.class))).thenReturn(taxWebserviceCallResult); TaxWebserviceCallResult taxWebserviceCallResult1 = callWebserviceProcessor.process(taxCalculation); assertThat(taxWebserviceCallResult1.getTaxCalculation().getEmployee()).isEqualTo(employee); }
@Test(expected = TaxWebServiceNonFatalException.class) public void testProcessBadResponse_ExceptionHasBeenThrownAndEmployeeIsReturned() throws Exception { when(taxPaymentWebServiceFacade.callTaxService(eq(taxCalculation), any(Callable.class))).thenThrow(new TaxWebServiceNonFatalException(new EmployeeTestBuilder().build(), Money.of(CurrencyUnit.EUR, 10), null, null, "boe")); callWebserviceProcessor.process(taxCalculation); }