Package org.openbankdata.core.client

Examples of org.openbankdata.core.client.Pagination


  public AmericanExpressTransactionPaginationStrategy() {}

  @Override
  public Pagination parsePagination(BankResponse pBankResponse) {
    Pagination pagination = new Pagination();

    Document doc = Jsoup.parse(pBankResponse.body());
    Element element = doc.select("#viewPeriod option[selected]").first();

    Element previous = element.previousElementSibling();
    if (previous != null) {
      pagination.setPrev(Integer.parseInt(previous.val()));
    }

    Element next = element.nextElementSibling();
    if (next != null && isDateWithinRange(next)) {
      pagination.setNext(Integer.parseInt(next.val()));
    } else {
      pagination.setNext(-1);
    }
    pagination.setFirst(0);
    pagination.setLast(Integer.parseInt(element.lastElementSibling().val()));
    return pagination;
  }
View Full Code Here


    BankResponse mockedResponse = mockedBankResponse();

    // When
    // The first page has been requested.

    Pagination pagination = mPaginationStrategy.parsePagination(mockedResponse);

    // Then
    assertNotNull("The pagination should not be null", pagination);
    assertEquals("The previous page should have been set.", 0, pagination.getPrev());
    assertEquals("The next page should have been set", 1, pagination.getNext());
    assertEquals("The first page should have been set", 0, pagination.getFirst());
    assertEquals("The last page should have been set", 1, pagination.getLast());

  }
View Full Code Here

TOP

Related Classes of org.openbankdata.core.client.Pagination

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.