コード例 #1
0
  @Test
  public void testPopulateAll() {
    final CustomerData customerData = mock(CustomerData.class);
    final CustomerModel customerModel = new CustomerModel();

    final CurrencyData currencyData = mock(CurrencyData.class);
    final LanguageData languageData = mock(LanguageData.class);
    final CurrencyModel currencyModel = mock(CurrencyModel.class);
    final LanguageModel languageModel = mock(LanguageModel.class);

    given(customerData.getFirstName()).willReturn("firstName");
    given(customerData.getLastName()).willReturn("lastName");
    given(customerData.getTitleCode()).willReturn(null);
    given(customerNameStrategy.getName("firstName", "lastName")).willReturn("firstName lastName");

    given(customerData.getCurrency()).willReturn(currencyData);
    given(currencyData.getIsocode()).willReturn("USD");
    given(currencyModel.getIsocode()).willReturn("USD");
    given(commonI18NService.getCurrency("USD")).willReturn(currencyModel);

    given(customerData.getLanguage()).willReturn(languageData);
    given(languageData.getIsocode()).willReturn("en");
    given(languageModel.getIsocode()).willReturn("en");
    given(commonI18NService.getLanguage("en")).willReturn(languageModel);

    customerReversePopulator.populate(customerData, customerModel);
    Assert.assertEquals("firstName lastName", customerModel.getName());
    Assert.assertNull(customerModel.getTitle());
    Assert.assertEquals("USD", customerModel.getSessionCurrency().getIsocode());
    Assert.assertEquals("en", customerModel.getSessionLanguage().getIsocode());
  }
コード例 #2
0
 @Test(expected = ConversionException.class)
 public void testPopulateCurrencyUnknownIdent() {
   final CustomerData customerData = mock(CustomerData.class);
   final CustomerModel customerModel = new CustomerModel();
   final CurrencyData currencyData = mock(CurrencyData.class);
   given(customerData.getCurrency()).willReturn(currencyData);
   given(currencyData.getIsocode()).willReturn("currencyIso");
   given(commonI18NService.getCurrency("currencyIso"))
       .willThrow(new UnknownIdentifierException(""));
   customerReversePopulator.populate(customerData, customerModel);
 }
コード例 #3
0
  @Test
  public void testConvert() {
    final CurrencyModel currencyModel = mock(CurrencyModel.class);

    given(currencyModel.getName()).willReturn(ISOCODE);
    given(currencyModel.getIsocode()).willReturn(ISOCODE);
    given(currencyModel.getActive()).willReturn(Boolean.TRUE);
    given(currencyModel.getSymbol()).willReturn(ISOCODE);

    final CurrencyData currencyData = currencyConverter.convert(currencyModel);

    Assert.assertEquals(currencyModel.getIsocode(), currencyData.getIsocode());
    Assert.assertEquals(currencyModel.getActive(), Boolean.valueOf(currencyData.isActive()));
    Assert.assertEquals(currencyModel.getSymbol(), currencyData.getSymbol());
    Assert.assertEquals(currencyModel.getName(), currencyData.getName());
  }