Example #1
0
  @Test(enabled = true, priority = 2)
  public void ValidateActualToltal() {
    actuals = new Actuals();

    int numberOfRows = actuals.getNumbreOfRows();
    AddTransaction transaction = new AddTransaction();
    for (int row = 0; row < numberOfRows; row++) {
      String rowTitle = actuals.getRowTitleByIndex(row);
      actuals.clickOnLineByIndex(row);
      if (rowTitle.contains(",")) {
        rowTitle = rowTitle.split(",")[1].trim();
        Assert.assertTrue(secondaryBoard.getSelectedLineName().contains(rowTitle));
      }

      transaction.clickTransactionTab();
      transaction.clickAddTransaction();

      TransactionTable table = new TransactionTable();

      DateRange date = table.openDate();
      date.setHireYear("2016");
      date.setHireMonth("Aug");

      table.setAmount("1000");

      table.clickSave();

      System.out.println(table.getAmountValue());
      System.out.println(table.getTotalValue());
      System.out.println(table.getTransactionDate());
      String Month =
          BudgetaUtils.getMonthWithIndex(
              Integer.parseInt(table.getTransactionDate().split("/")[0]));
      String Year = table.getTransactionDate().split("/")[1];

      String actualsDate = Month + " " + Year;

      String totalRowValue = table.getTotalValue();
      //	String amountRowValue = table.getAmountValue();

      transaction.clickSummaryTab();

      SummaryTable summary = new SummaryTable();

      // Assert.assertEquals(summary.getTotalOfRow(row), totalRowValue);

      topHeaderBar.openBudgetSettings();
      BudgetSettings settings = new BudgetSettings();
      String dateFrom = settings.getDateRangeFrom();
      String dateTo = settings.getDateRangeTo();
      settings.clickCancel();

      fromMonth = BudgetaUtils.getMonthWithIndex(Integer.parseInt(dateFrom.split("/")[0]));
      fromYear = dateFrom.split("/")[1];
      toMonth = BudgetaUtils.getMonthWithIndex(Integer.parseInt(dateTo.split("/")[0]));
      toYear = dateTo.split("/")[1];
      List<String> expectedDates =
          BudgetaUtils.getAllMonthsBetweenTwoMonths(fromMonth, fromYear, toMonth, toYear, 0, false);

      summary = new SummaryTable();
      dates = summary.getAllDates();

      Assert.assertEquals(dates.size(), expectedDates.size());

      for (int i = 0; i < expectedDates.size(); i++) {
        String getDate = dates.get(i);
        if (getDate.equals(actualsDate)) {
          Assert.assertEquals(
              summary.getActualsTotalOfRow(row, "Actual"),
              totalRowValue,
              "... Row title is: " + rowTitle + ", in header: " + dates.get(i));
        }
      }

      System.out.println(summary.getAllValuesOfRow(row));

      transaction = new AddTransaction();
      transaction.clickTransactionTab();
    }
  }