AbstractWorldpayPaymentMethodCheckoutStepController extends AbstractCheckoutStepController { @ModelAttribute("expiryYears") public List<SelectOption> getExpiryYears() { final LocalDate localDate = LocalDate.now(); return IntStream.range(localDate.getYear(), localDate.getYear() + PLUS_YEARS) .mapToObj(i -> new SelectOption(String.valueOf(i), String.valueOf(i))) .collect(Collectors.toList()); }  @ModelAttribute("billingCountries") Collection<CountryData> getBillingCountries(); @ModelAttribute("cardTypes") Collection<CardTypeData> getCardTypes(); @ModelAttribute("months") List<SelectOption> getMonths(); @ModelAttribute("expiryYears") List<SelectOption> getExpiryYears(); WorldpayPaymentCheckoutFacade getWorldpayPaymentCheckoutFacade(); WorldpayHostedOrderFacade getWorldpayHostedOrderFacade(); WorldpayAdditionalInfoFacade getWorldpayAdditionalInfoFacade(); WorldpayMerchantConfigDataFacade getWorldpayMerchantConfigDataFacade();  }
@Test public void shouldPopulateModelWithExpiryYears() { final List<AbstractCheckoutController.SelectOption> result = testObj.getExpiryYears(); final int currentYear = LocalDate.now().getYear(); assertEquals(11, result.size()); for (int i = 0; i < result.size(); i++) { assertEquals(String.valueOf(currentYear + i), result.get(i).getCode()); assertEquals(String.valueOf(currentYear + i), result.get(i).getName()); } }