Exemplo n.º 1
0
  /**
   * Helper method for testing the provided LDAPSearchDetails against expected values
   *
   * @param searchDetails the LDAPSearchDetails object
   * @param expectedContextName the expected context name
   * @param expectedContextFilter the expected context filter string
   * @param expectedAttrNameList list of expected attribute names
   * @param expectedCountLimit the expected count limit
   * @param expectedSearchScope the expected search scope
   * @param expectedSortKeys the expected sortKeys list.
   */
  public void helpTestSearchDetails(
      final LDAPSearchDetails searchDetails,
      final String expectedContextName,
      final String expectedContextFilter,
      final List<String> expectedAttrNameList,
      final long expectedCountLimit,
      final int expectedSearchScope,
      final SortKey[] expectedSortKeys) {

    // Get all of the actual values
    String contextName = searchDetails.getContextName();
    String contextFilter = searchDetails.getContextFilter();
    List<Column> attrList = searchDetails.getElementList();
    long countLimit = searchDetails.getCountLimit();
    int searchScope = searchDetails.getSearchScope();
    SortKey[] sortKeys = searchDetails.getSortKeys();

    // Compare actual with Expected
    assertEquals(expectedContextName, contextName);
    assertEquals(expectedContextFilter, contextFilter);

    assertEquals(attrList.size(), expectedAttrNameList.size());
    Iterator<Column> iter = attrList.iterator();
    Iterator<String> eIter = expectedAttrNameList.iterator();
    while (iter.hasNext() && eIter.hasNext()) {
      String actualName = iter.next().getSourceName();
      String expectedName = eIter.next();
      assertEquals(actualName, expectedName);
    }

    assertEquals(expectedCountLimit, countLimit);
    assertEquals(expectedSearchScope, searchScope);
    assertArrayEquals(expectedSortKeys, sortKeys);
  }