コード例 #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());
  }
  /** ******** */
  private B2BCustomerModel createB2BCustomerModel(final CustomerModel customer) {
    final B2BCustomerModel b2bCustomer = new B2BCustomerModel();

    b2bCustomer.setEmail(customer.getUid());
    b2bCustomer.setName(customer.getName());
    b2bCustomer.setTitle(customer.getTitle());
    b2bCustomer.setUid(customer.getUid());

    b2bCustomer.setDefaultB2BUnit(createB2BUnit());

    return b2bCustomer;
  }
コード例 #3
0
  @Test
  public void testPopulateEssencial() {
    final CustomerData customerData = mock(CustomerData.class);
    final CustomerModel customerModel = new CustomerModel();

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

    customerReversePopulator.populate(customerData, customerModel);
    Assert.assertEquals("firstName lastName", customerModel.getName());
    Assert.assertNull(customerModel.getTitle());
  }