/** This method is invoked after the SuiteRunner has run all the test suites. */
  public void onFinish(ISuite suite) {
    VirtualSuiteRunner runner = new VirtualSuiteRunner();
    CustomTestNgReportSetter reportSetter = new CustomTestNgReportSetter();
    /*          If Execution mode is all attempts for the second test execution cycle*/
    log.info(
        "***********Finishing executing test Suite "
            + suite.getName()
            + " on "
            + executionMode.toString()
            + "*******");
    try {
      EnvironmentBuilder environmentBuilder = new EnvironmentBuilder();

      if (!environmentBuilder.getFrameworkSettings().getEnvironmentSettings().is_builderEnabled()) {
        stopMultipleServers(suite.getParameter("server.list"));
      }
      // Runtime.getRuntime().gc();
    } catch (Exception e) {
      /*cannot throw the exception */
      log.error(e);
      reportSetter.createReport(suite, e);
      Assert.fail("Fail to stop servers " + e);
    }
    if (((executionMode.equals(ExecutionMode.all.name())))
        && RunnerSetter.getCount() <= 1
        && !RunnerSetter.getMixedModeRun()) {
      setEnvoronmentSettingsForTenant(true);
      reportSetter.createReport(suite);
      try {
        runner.testset(currentSuite);
        setEnvoronmentSettingsForTenant(false);
      } catch (MojoFailureException e) {
        log.error(e);
        reportSetter.createReport(suite, e);
      }
      reportSetter.createReport(suite);
    }
    RunnerSetter.resetRunner();
  }
  /** This method is invoked before the SuiteRunner starts. */
  public synchronized void onStart(ISuite suite) {
    currentSuite = suite;
    PlatformUtil.setKeyStoreProperties();
    int exeCount = RunnerSetter.getCount();
    boolean isFirstExecution = RunnerSetter.getIsFirstRun();
    RunnerSetter.setRunner(suite.getName(), exeCount + 1);
    environmentBuilder = new EnvironmentBuilder();
    environmentBuilder = new EnvironmentBuilder();

    boolean deploymentEnabled =
        environmentBuilder.getFrameworkSettings().getEnvironmentSettings().isEnableDipFramework();
    boolean startosEnabled =
        environmentBuilder.getFrameworkSettings().getEnvironmentSettings().is_runningOnStratos();
    boolean builderEnabled =
        environmentBuilder.getFrameworkSettings().getEnvironmentSettings().is_builderEnabled();
    defaultProductList =
        environmentBuilder.getFrameworkSettings().getEnvironmentVariables().getProductList();
    environmet =
        environmentBuilder.getFrameworkSettings().getEnvironmentSettings().executionEnvironment();
    executionMode =
        environmentBuilder.getFrameworkSettings().getEnvironmentSettings().executionMode();
    log.info(
        "**********Starting executing test Suite "
            + suite.getName()
            + " on "
            + executionMode.toString()
            + "***********");
    try {
      /* If Execution mode is tenant executes main execution as tenant*/
      if (executionMode.equals(ExecutionMode.tenant.name())
          && !environmet.equalsIgnoreCase(ExecutionEnvironment.stratos.name())) {
        setEnvoronmentSettingsForTenant(true);
      }
      serverGroupManager = new ServerGroupManager(0);
      if (startosEnabled) {
        UserPopulator populator = new UserPopulator();
        if (!environmet.equals(ExecutionEnvironment.stratos)) {
          if (executionMode.equals(ExecutionMode.tenant.name())
              || executionMode.equals(ExecutionMode.all.name())) {
            populator.populateUsers(defaultProductList);
          } else {
            log.error(
                "\n......................................................"
                    + "Invalid Environment Settings.......\n "
                    + "Please Check The automation.properties file \n"
                    + "......................................................");
          }
        } else {
          populator.populateUsers(null);
        }
      } else if (deploymentEnabled) {
        if (suite.getParameter("server.list") != null) {
          List<String> productList = Arrays.asList(suite.getParameter("server.list").split(","));
          log.info("Starting servers...");
          serverGroupManager.startServers(productList);
          UserPopulator populator = new UserPopulator();
          populator.populateUsers(defaultProductList);
        } else {
          log.info("Starting servers with default product list...");
          serverGroupManager.startServers(defaultProductList);
          if (executionMode.equals(ExecutionMode.user.name())
              || executionMode.equals(ExecutionMode.all.name())) {
            UserPopulator populator = new UserPopulator();
            populator.populateUsers(defaultProductList);
          }
        }
      } else {
        UserPopulator populator = new UserPopulator();
        if (populator.framework.getEnvironmentSettings().isUserManagementEnable()) {
          populator.populateUsers(defaultProductList);
        }
      }

    } catch (Exception e) {
      /*cannot throw the exception */
      log.error(e);
      CustomTestNgReportSetter reportSetter = new CustomTestNgReportSetter();
      reportSetter.createReport(suite, e);
    }
  }