@Override
 public void executeAction(final ReplenishmentProcessModel process) throws Exception {
   final CartToOrderCronJobModel cartToOrderCronJob = process.getCartToOrderCronJob();
   final CartModel cronJobCart = cartToOrderCronJob.getCart();
   getUserService().setCurrentUser(cronJobCart.getUser());
   final CartModel clone =
       getCartService()
           .clone(
               getTypeService().getComposedTypeForClass(CartModel.class),
               getTypeService().getComposedTypeForClass(CartEntryModel.class),
               cronJobCart,
               getGuidKeyGenerator().generate().toString());
   clone.setPaymentAddress(cartToOrderCronJob.getPaymentAddress());
   clone.setDeliveryAddress(cartToOrderCronJob.getDeliveryAddress());
   clone.setPaymentInfo(cartToOrderCronJob.getPaymentInfo());
   clone.setStatus(OrderStatus.CREATED);
   clone.setAllPromotionResults(Collections.EMPTY_SET);
   clone.setPaymentTransactions(Collections.EMPTY_LIST);
   clone.setPermissionResults(Collections.EMPTY_LIST);
   clone.setGuid(getGuidKeyGenerator().generate().toString());
   this.modelService.save(clone);
   processParameterHelper.setProcessParameter(process, "cart", clone);
 }
  @Before
  public void beforeTest() throws Exception {
    MockitoAnnotations.initMocks(this);
    // inject a mock payment provider
    cardPaymentService.setCommandFactoryRegistry(mockupCommandFactoryRegistry);
    paymentService.setCardPaymentService(cardPaymentService);
    commerceCheckoutService.setPaymentService(paymentService);

    createCoreData();
    createDefaultCatalog();

    importCsv("/energizercore/test/testOrganizations.csv", "utf-8");
    importCsv("/energizercore/test/testB2BCommerceCart.csv", "utf-8");

    final CartModel modelByExample = new CartModel();
    modelByExample.setCode("dc_shhCart_b2bas");

    final CartModel cart = flexibleSearchService.getModelByExample(modelByExample);
    Assert.assertNotNull(cart);
    cartService.setSessionCart(cart);
    userService.setCurrentUser(cart.getUser());

    if (flexibleSearchService
        .search(
            "SELECT {"
                + ServicelayerJobModel.PK
                + "} FROM {"
                + ServicelayerJobModel._TYPECODE
                + "} WHERE "
                + "{"
                + ServicelayerJobModel.SPRINGID
                + "}=?springid",
            Collections.singletonMap("springid", "b2bAcceleratorCartToOrderJob"))
        .getResult()
        .isEmpty()) {
      final ServicelayerJobModel servicelayerJobModel =
          modelService.create(ServicelayerJobModel.class);
      servicelayerJobModel.setCode("b2bAcceleratorCartToOrderJob");
      servicelayerJobModel.setSpringId("b2bAcceleratorCartToOrderJob");
      modelService.save(servicelayerJobModel);
    }

    final Date startDate = new Date();
    final Integer day = Integer.valueOf(5);
    final Integer week = Integer.valueOf(2);
    final List<DayOfWeek> days = new ArrayList<DayOfWeek>();
    days.add(DayOfWeek.TUESDAY);
    days.add(DayOfWeek.FRIDAY);
    triggerModel = modelService.create(TriggerModel.class);
    triggerModel.setRelative(Boolean.TRUE);
    triggerModel.setActivationTime(startDate);
    triggerModel.setDay(day);
    triggerModel.setWeekInterval(week);
    triggerModel.setDaysOfWeek(days);

    cartToOrderCronJob = modelService.create(CartToOrderCronJobModel.class);
    cartToOrderCronJob.setCart(cartService.getSessionCart());
    cartToOrderCronJob.setDeliveryAddress(userService.getCurrentUser().getDefaultShipmentAddress());
    cartToOrderCronJob.setPaymentAddress(userService.getCurrentUser().getDefaultPaymentAddress());
    cartToOrderCronJob.setPaymentInfo(cartService.getSessionCart().getPaymentInfo());
    setCronJobToTrigger(cartToOrderCronJob, Collections.singletonList(triggerModel));
    cartToOrderCronJob.setJob(cronJobService.getJob("b2bAcceleratorCartToOrderJob"));
    modelService.save(cartToOrderCronJob);
    final BaseSiteModel site = baseSiteService.getBaseSiteForUID("b2bstoretemplate");
    Assert.assertNotNull("no site found for id 'site'", site);
    baseSiteService.setCurrentBaseSite(site, false);
  }