@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 void prepareData() {
    catVersion = catalogVersionService.getCatalogVersion("hwcatalog", "Online");
    catalogVersionService.addSessionCatalogVersion(catVersion);

    user = userService.getUserForUID("ariel");
    userService.setCurrentUser(user);
    cart = cartService.getSessionCart();
    commonI18NService.setCurrentCurrency(commonI18NService.getCurrency("EUR"));
    product1 = productService.getProductForCode(catVersion, "HW2110-0012");
  }
 @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);
 }
  @Before
  public void before() throws Exception {
    de.hybris.platform.servicelayer.ServicelayerTest.createCoreData();
    de.hybris.platform.servicelayer.ServicelayerTest.createDefaultCatalog();
    de.hybris.platform.catalog.jalo.CatalogManager.getInstance()
        .createEssentialData(java.util.Collections.EMPTY_MAP, null);
    importCsv("/impex/essentialdata_1_usergroups.impex", "UTF-8");
    importCsv("/impex/essentialdata_2_b2bcommerce.impex", "UTF-8");
    importCsv("/b2bapprovalprocess/test/b2borganizations.csv", "UTF-8");

    i18nService.setCurrentLocale(Locale.ENGLISH);
    commonI18NService.setCurrentLanguage(commonI18NService.getLanguage("en"));
    commonI18NService.setCurrentCurrency(commonI18NService.getCurrency("USD"));
  }
  @Before
  public void beforeTest() throws Exception {
    B2BIntegrationTest.loadTestData();
    importCsv("/b2bapprovalprocess/test/b2borganizations.csv", "UTF-8");
    importCsv("/b2bapprovalprocess/test/creditlimit.impex", "UTF-8");

    sessionService
        .getCurrentSession()
        .setAttribute(
            "user", this.modelService.<Object>toPersistenceLayer(userService.getAdminUser()));
    i18nService.setCurrentLocale(Locale.ENGLISH);
    commonI18NService.setCurrentLanguage(commonI18NService.getLanguage("en"));
    commonI18NService.setCurrentCurrency(commonI18NService.getCurrency("EUR"));
  }
  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();

    final CatalogVersionModel version =
        catalogVersionService.getCatalogVersion("hwcatalog", "Online");
    catalogVersionService.addSessionCatalogVersion(version);
    baseProduct = productService.getProductForCode(version, "HW2110-0019");
    partnerProduct = productService.getProductForCode(version, "HW2200-0561");
    user = userService.getUserForUID("demo");
    userService.setCurrentUser(user);
    currency = commonI18NService.getCurrency("EUR");
    commonI18NService.setCurrentCurrency(currency);
  }
  @Before
  public void setUp() throws Exception {
    // final Create data for tests
    LOG.info("Creating data for DefaultChangeProductPriceBundleRuleDaoIntegrationTest ..");
    userService.setCurrentUser(userService.getAdminUser());
    final long startTime = System.currentTimeMillis();
    new CoreBasicDataCreator().createEssentialData(Collections.EMPTY_MAP, null);

    // importing test csv
    final String legacyModeBackup = Config.getParameter(ImpExConstants.Params.LEGACY_MODE_KEY);
    LOG.info(
        "Existing value for " + ImpExConstants.Params.LEGACY_MODE_KEY + " :" + legacyModeBackup);
    Config.setParameter(ImpExConstants.Params.LEGACY_MODE_KEY, "true");
    importCsv("/commerceservices/test/testCommerceCart.csv", "utf-8");
    Config.setParameter(ImpExConstants.Params.LEGACY_MODE_KEY, "false");
    importCsv("/subscriptionservices/test/testSubscriptionCommerceCartService.impex", "utf-8");
    importCsv("/configurablebundleservices/test/testBundleCommerceCartService.impex", "utf-8");
    importCsv("/configurablebundleservices/test/testApproveAllBundleTemplates.impex", "utf-8");
    Config.setParameter(ImpExConstants.Params.LEGACY_MODE_KEY, legacyModeBackup);

    LOG.info(
        "Finished data for DefaultChangeProductPriceBundleRuleDaoIntegrationTest "
            + (System.currentTimeMillis() - startTime)
            + "ms");

    baseSiteService.setCurrentBaseSite(baseSiteService.getBaseSiteForUID(TEST_BASESITE_UID), false);
    catalogVersionService.setSessionCatalogVersion("testCatalog", "Online");

    currencyUSD = commonI18NService.getCurrency("USD");
    currencyEUR = commonI18NService.getCurrency("EUR");
    galaxynexus = productService.getProductForCode("GALAXY_NEXUS");
    standardplan1y = productService.getProductForCode("PLAN_STANDARD_1Y");
    standardplan3y = productService.getProductForCode("PLAN_STANDARD_3Y");
    smartPhonePlanBundleTemplate =
        bundleTemplateService.getBundleTemplateForCode("SmartPhonePlanSelection");
    smartPhoneDeviceBundleTemplate =
        bundleTemplateService.getBundleTemplateForCode("SmartPhoneDeviceSelection");

    modelService.detachAll();
  }