protected void setCronJobToTrigger(
     final CronJobModel cronJob, final List<TriggerModel> triggers) {
   for (final TriggerModel trigger : triggers) {
     trigger.setCronJob(cronJob);
   }
   cronJob.setTriggers(triggers);
 }
  @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);
  }