public static void startSuite() throws IOException {
    if (robotTestSuite == null) {
      final PythonAware pythonAware =
          new DefaultPythonProvider(Config.getParameter("atddengine.libraries-path"));

      final RobotSettings robotSettings = new RobotSettings();

      robotSettings.setOutputDir(
          new File(Config.getParameter("atddengine.report-path"), "quotation"));
      robotSettings.setLogName("InsuranceQuotation_Test-log");
      robotSettings.setOutputName("InsuranceQuotation_Test-output");
      robotSettings.setReportName("InsuranceQuotation_Test-report");

      final RobotTestSuiteFactory robotTestSuiteFactory =
          new PythonRobotTestSuiteFactory(pythonAware);

      robotTestSuite =
          robotTestSuiteFactory.parseTestSuite(
              robotSettings,
              new File(
                  "/opt/bamboo-agent/xml-data/build-dir/HYM-IA1-JOB1/source/financialacceleratorstorefrontatddtests/genresources/robottests/InsuranceQuotation_Test.txt"));
    }

    if (!robotTestSuite.isStarted()) {
      robotTestSuite.start();
    }
  }
  @Override
  public Transition executeAction(final OrderProcessModel process) {
    LOG.info("Process: " + process.getCode() + " in step " + getClass());
    ServicesUtil.validateParameterNotNull(process, "Process can not be null");
    ServicesUtil.validateParameterNotNull(process.getOrder(), "Order can not be null");

    final double scoreLimit =
        Double.parseDouble(
            Config.getParameter(
                HybrisTestFulfilmentProcessConstants.EXTENSIONNAME + ".fraud.scoreLimitExternal"));
    final double scoreTolerance =
        Double.parseDouble(
            Config.getParameter(
                HybrisTestFulfilmentProcessConstants.EXTENSIONNAME
                    + ".fraud.scoreToleranceExternal"));

    final OrderModel order = process.getOrder();
    final FraudServiceResponse response =
        getFraudService().recognizeOrderSymptoms(getProviderName(), order);
    final double score = response.getScore();
    if (score < scoreLimit) {
      final FraudReportModel fraudReport =
          createFraudReport(providerName, response, order, FraudStatus.OK);
      final OrderHistoryEntryModel historyEntry =
          createHistoryLog(providerName, order, FraudStatus.OK, null);
      order.setFraudulent(Boolean.FALSE);
      order.setPotentiallyFraudulent(Boolean.FALSE);
      order.setStatus(OrderStatus.FRAUD_CHECKED);
      modelService.save(fraudReport);
      modelService.save(historyEntry);
      modelService.save(order);
      return Transition.OK;
    } else if (score < scoreLimit + scoreTolerance) {
      final FraudReportModel fraudReport =
          createFraudReport(providerName, response, order, FraudStatus.CHECK);
      final OrderHistoryEntryModel historyEntry =
          createHistoryLog(providerName, order, FraudStatus.CHECK, fraudReport.getCode());
      order.setFraudulent(Boolean.FALSE);
      order.setPotentiallyFraudulent(Boolean.TRUE);
      order.setStatus(OrderStatus.FRAUD_CHECKED);
      modelService.save(fraudReport);
      modelService.save(historyEntry);
      modelService.save(order);
      return Transition.POTENTIAL;
    } else {
      final FraudReportModel fraudReport =
          createFraudReport(providerName, response, order, FraudStatus.FRAUD);
      final OrderHistoryEntryModel historyEntry =
          createHistoryLog(providerName, order, FraudStatus.FRAUD, fraudReport.getCode());
      order.setFraudulent(Boolean.TRUE);
      order.setPotentiallyFraudulent(Boolean.FALSE);
      order.setStatus(OrderStatus.FRAUD_CHECKED);
      modelService.save(fraudReport);
      modelService.save(historyEntry);
      modelService.save(order);
      return Transition.FRAUD;
    }
  }
  @Before
  public void setUp() throws Exception {
    createCoreData();
    createDefaultCatalog();
    productModel01 = productService.getProduct("testProduct1");
    userModel01 = userService.getUser("anonymous");
    userModel02 = userService.getCurrentUser();

    oldMinimalRating = Config.getParameter(CustomerReviewConstants.KEYS.MINIMAL_RATING);
    oldMaximalRating = Config.getParameter(CustomerReviewConstants.KEYS.MAXIMAL_RATING);

    // Set some configuration values to be used generally in the tests
    Config.setParameter(CustomerReviewConstants.KEYS.MINIMAL_RATING, String.valueOf(0));
    Config.setParameter(CustomerReviewConstants.KEYS.MAXIMAL_RATING, String.valueOf(4));
  }
  @Test
  public void shouldImportScriptWithLegacyModeOffWhenGlobalSwitchIsOnUsingImportConfig() {
    // given
    Config.setParameter(ImpExConstants.Params.LEGACY_MODE_KEY, "true");
    final ImpExResource mediaRes =
        new StreamBasedImpExResource(
            new ByteArrayInputStream("INSERT Language;isocode;active\n;test;true".getBytes()),
            CSVConstants.HYBRIS_ENCODING);
    final ImportConfig config = new ImportConfig();
    config.setLegacyMode(Boolean.FALSE);
    config.setSynchronous(true);
    config.setFailOnError(true);
    config.setScript(mediaRes);
    config.setRemoveOnSuccess(false);

    // when
    final ImportResult importResult = importService.importData(config);

    // then
    assertThat(importResult.isFinished()).isTrue();
    assertThat(importResult.isError()).isFalse();
    assertThat(Boolean.parseBoolean(Config.getParameter(ImpExConstants.Params.LEGACY_MODE_KEY)))
        .isTrue();
    assertThat(importResult.getCronJob().getLegacyMode()).isFalse();
  }
  @RequestMapping(value = "/select-suggested-address", method = RequestMethod.POST)
  public String doSelectSuggestedAddress(
      final AddressForm addressForm, final RedirectAttributes redirectModel) {
    final Set<String> resolveCountryRegions =
        org.springframework.util.StringUtils.commaDelimitedListToSet(
            Config.getParameter("resolve.country.regions"));

    final AddressData selectedAddress = new AddressData();
    selectedAddress.setId(addressForm.getAddressId());
    selectedAddress.setTitleCode(addressForm.getTitleCode());
    selectedAddress.setFirstName(addressForm.getFirstName());
    selectedAddress.setLastName(addressForm.getLastName());
    selectedAddress.setLine1(addressForm.getLine1());
    selectedAddress.setLine2(addressForm.getLine2());
    selectedAddress.setTown(addressForm.getTownCity());
    selectedAddress.setPostalCode(addressForm.getPostcode());
    selectedAddress.setBillingAddress(false);
    selectedAddress.setShippingAddress(true);
    selectedAddress.setVisibleInAddressBook(true);

    final CountryData countryData = i18NFacade.getCountryForIsocode(addressForm.getCountryIso());
    selectedAddress.setCountry(countryData);

    if (resolveCountryRegions.contains(countryData.getIsocode())) {
      if (addressForm.getRegionIso() != null && !StringUtils.isEmpty(addressForm.getRegionIso())) {
        final RegionData regionData =
            getI18NFacade().getRegion(addressForm.getCountryIso(), addressForm.getRegionIso());
        selectedAddress.setRegion(regionData);
      }
    }

    if (resolveCountryRegions.contains(countryData.getIsocode())) {
      if (addressForm.getRegionIso() != null && !StringUtils.isEmpty(addressForm.getRegionIso())) {
        final RegionData regionData =
            getI18NFacade().getRegion(addressForm.getCountryIso(), addressForm.getRegionIso());
        selectedAddress.setRegion(regionData);
      }
    }

    if (Boolean.TRUE.equals(addressForm.getEditAddress())) {
      selectedAddress.setDefaultAddress(
          Boolean.TRUE.equals(addressForm.getDefaultAddress())
              || userFacade.getAddressBook().size() <= 1);
      userFacade.editAddress(selectedAddress);
    } else {
      selectedAddress.setDefaultAddress(
          Boolean.TRUE.equals(addressForm.getDefaultAddress()) || userFacade.isAddressBookEmpty());
      userFacade.addAddress(selectedAddress);
    }

    GlobalMessages.addFlashMessage(
        redirectModel, GlobalMessages.CONF_MESSAGES_HOLDER, "account.confirmation.address.added");

    return REDIRECT_TO_ADDRESS_BOOK_PAGE;
  }
 protected boolean isCSRFExemptUrl(final String servletPath) {
   if (servletPath != null) {
     final String allowedUrlPatterns = Config.getParameter(CSRF_ALLOWED_URLS);
     final Set<String> allowedUrls = StringUtils.commaDelimitedListToSet(allowedUrlPatterns);
     for (final String pattern : allowedUrls) {
       if (servletPath.matches(pattern)) {
         return true;
       }
     }
   }
   return false;
 }
  @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 {
    LOG.info("Creating data for SubscriptionEntitlementTest ...");
    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");
    Config.setParameter(ImpExConstants.Params.LEGACY_MODE_KEY, legacyModeBackup);

    LOG.info(
        "Finished data for SubscriptionEntitlementTest "
            + (System.currentTimeMillis() - startTime)
            + "ms");
    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");
  }
 @Before
 public void setUp() throws Exception {
   legacyModeBackup = Config.getParameter(ImpExConstants.Params.LEGACY_MODE_KEY);
   createCoreData();
 }