// Method that checks for 2 decimal places in above function
 public boolean checkDecimalPlaces(double d, int decimalPlaces) {
   if (d == 0) return true;
   double multiplier = Math.pow(10, decimalPlaces);
   double check = d * multiplier;
   check = Math.round(check);
   check = check / multiplier;
   return (d == check);
 }
Beispiel #2
0
 public String generateRandomEmailAddress(String domain) {
   String emailAddress = "";
   // Generate random email address
   String alphabet = "abcdefghijklmnopqrstuvwxyz";
   while (emailAddress.length() < 5) {
     int character = (int) (Math.random() * 26);
     emailAddress += alphabet.substring(character, character + 1);
   }
   emailAddress += Integer.valueOf((int) (Math.random() * 99)).toString();
   emailAddress += "@" + domain;
   return emailAddress;
 }
  // Returns are randomly generated email id, part before the domain name
  private String shuffleEmail(String email) {

    String shuffledString = "";

    while (email.length() != 0) {
      int index = (int) Math.floor(Math.random() * email.length());
      char c = email.charAt(index);
      email = email.substring(0, index) + email.substring(index + 1);
      shuffledString += c;
    }

    return shuffledString;
  }
  // ODI6.x-627:generate cssr report with valid filters and check the number if they are reasonable
  public void cssrNumbers() {
    int CallVolumeValue = 0, TransfersValue = 0, PeakHourValue = 0;
    double roundOff = 0, AverageCallValue = 0;
    String dmName = "US_AIRWAYS";
    gotoreports(dmName);
    pickAvalidDate();
    try {
      new WebDriverWait(driver, 10)
          .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("reportContent"));
      WebElement page =
          new WebDriverWait(driver, 10)
              .until(ExpectedConditions.visibilityOfElementLocated(By.id("CrystalViewer")));
      List<WebElement> check = page.findElements(By.tagName("span"));
      for (int i = 0; i < check.size(); i++) {
        String content = (check.get(i).getText());
        if (content.equals("Call Volume")) {
          String CallVolume = (check.get(i + 1).getText());
          String[] CallVolumes = CallVolume.split("\\s");
          CallVolumeValue = Integer.parseInt(CallVolumes[1]);
          System.out.println(CallVolumeValue);
        } else if (content.equals("Transfers (All)")) {
          String TransfersAll = (check.get(i + 1).getText());
          String[] Tvalues = TransfersAll.split("\\s");
          TransfersValue = Integer.parseInt(Tvalues[1]);
          System.out.println(TransfersValue);
        } else if (content.equals("Peak Hour Call Volume")) {
          String PeakHourCallVolume = (check.get(i + 1).getText());
          String[] PeakHourCallValues = PeakHourCallVolume.split("\\s");
          PeakHourValue = Integer.parseInt(PeakHourCallValues[1]);
        } else if (content.equals("Call Duration (minutes)")) {
          String CallDuration = (check.get(i + 1).getText());
          String[] CallDurationValues = CallDuration.split("\\s");
          double CallDurationValue = Double.parseDouble(CallDurationValues[1]);
          double x = CallDurationValue / CallVolumeValue;
          roundOff = Math.round(x * 100.0) / 100.0;
        } else if (content.equals("Average Call Duration (minutes)")) {
          String AverageCallDuration = (check.get(i + 1).getText());
          String[] AverageCallDurationValues = AverageCallDuration.split("\\s");
          AverageCallValue = Double.parseDouble(AverageCallDurationValues[1]);
        }
      }
      try {
        if (CallVolumeValue >= TransfersValue) {
          logger.info("the call volume is greater than the Transfer");
          System.out.println("CallVolumeValue >= TransfersValue");
        }
        if (PeakHourValue <= CallVolumeValue) {
          System.out.println("PeakHourValue <= CallVolumeValue");
        }
        if (AverageCallValue == roundOff) {
          System.out.println("Average Call Duration =Call Duration (minutes)/Call Volume");
        }

      } catch (Exception e) {
        e.printStackTrace();
      }
      ReportFile.addTestCase(
          "ODI6.x-627:CSSR numbers must be reasonable",
          "ODI6.x-627:CSSR numbers must be reasonable => Pass");
    } catch (Exception e) {
      e.printStackTrace();
    }
    ReportFile.WriteToFile();
    driver.quit();
  }