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");
  }
  @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);
  }
 private void setupProducts() {
   final CatalogVersionModel catalogVersionModel =
       catalogVersionService.getCatalogVersion("testCatalog", "Online");
   subscriptionProduct =
       (SubscriptionProductModel)
           productService.getProductForCode(catalogVersionModel, SUBSCRIPTION_PRODUCT_CODE);
 }
  @Test
  public void testGenerateBundleSelectionCriteriaID() {
    final CatalogVersionModel catalogVersion =
        catalogVersionService.getSessionCatalogVersions().iterator().next();

    final AutoPickBundleSelectionCriteriaModel selecCrit1 =
        modelService.create(AutoPickBundleSelectionCriteriaModel.class);
    Assert.assertNull(selecCrit1.getId());
    selecCrit1.setCatalogVersion(catalogVersion);
    modelService.save(selecCrit1);
    Assert.assertNotNull(selecCrit1.getId());
    LOG.info("selecCrit1.id: " + selecCrit1.getId());

    final PickExactlyNBundleSelectionCriteriaModel selecCrit2 =
        modelService.create(PickExactlyNBundleSelectionCriteriaModel.class);
    Assert.assertNull(selecCrit2.getId());
    selecCrit2.setCatalogVersion(catalogVersion);
    selecCrit2.setN(Integer.valueOf(1));
    modelService.save(selecCrit2);
    Assert.assertNotNull(selecCrit2.getId());
    Assert.assertTrue(!selecCrit1.getId().equals(selecCrit2.getId()));
    LOG.info("selecCrit2.id: " + selecCrit2.getId());

    final PickNToMBundleSelectionCriteriaModel selecCrit3 =
        modelService.create(PickNToMBundleSelectionCriteriaModel.class);
    Assert.assertNull(selecCrit3.getId());
    selecCrit3.setCatalogVersion(catalogVersion);
    selecCrit3.setN(Integer.valueOf(1));
    selecCrit3.setM(Integer.valueOf(2));
    modelService.save(selecCrit3);
    Assert.assertNotNull(selecCrit3.getId());
    Assert.assertTrue(!selecCrit1.getId().equals(selecCrit3.getId()));
    Assert.assertTrue(!selecCrit2.getId().equals(selecCrit3.getId()));
    LOG.info("selecCrit3.id: " + selecCrit3.getId());

    final AutoPickBundleSelectionCriteriaModel selecCrit4 =
        modelService.create(AutoPickBundleSelectionCriteriaModel.class);
    Assert.assertNull(selecCrit4.getId());
    selecCrit4.setCatalogVersion(catalogVersion);
    selecCrit4.setId("MyOwnSelecCritID");
    modelService.save(selecCrit4);
    Assert.assertEquals("MyOwnSelecCritID", selecCrit4.getId());
    LOG.info("selecCrit4.id: " + selecCrit4.getId());

    final PickNToMBundleSelectionCriteriaModel selecCrit5 =
        modelService.create(PickNToMBundleSelectionCriteriaModel.class);
    Assert.assertNull(selecCrit5.getId());
    selecCrit5.setCatalogVersion(catalogVersion);
    selecCrit5.setN(Integer.valueOf(1));
    selecCrit5.setM(Integer.valueOf(2));
    modelService.save(selecCrit5);
    Assert.assertNotNull(selecCrit5.getId());
    Assert.assertTrue(!selecCrit1.getId().equals(selecCrit5.getId()));
    Assert.assertTrue(!selecCrit2.getId().equals(selecCrit5.getId()));
    Assert.assertTrue(!selecCrit3.getId().equals(selecCrit5.getId()));
    LOG.info("selecCrit5.id: " + selecCrit5.getId());
  }
  @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();
  }
  @Before
  public void setUp() throws Exception {
    // final Create data for tests
    LOG.info("Creating data for BundleSelectionCriteriaIDPrepareInterceptorIntegrationTest ...");
    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, legacyModeBackup);

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

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