public void testNext() {
    String[] columnNames = new String[] {"number"};
    Cursor cursor1 = getCursor(TABLE_NAME_1, null, columnNames);
    Cursor cursor2 = getCursor(TABLE_NAME_2, null, columnNames);

    // For cursor1 , values are '01'~'07' and 'EQUAL_START'~'MAX_VALUE'
    assertEquals(TEST_ITEM_COUNT, cursor1.getCount());
    // For cursor2 , values are '11'~'17' and 'EQUAL_START'~'MAX_VALUE'
    assertEquals(TEST_ITEM_COUNT, cursor2.getCount());
    CursorJoiner cursorJoiner =
        new CursorJoiner(cursor1, cursor1.getColumnNames(), cursor2, cursor2.getColumnNames());
    for (int i = 0; i < UNIQUE_COUNT; i++) {
      // For cursor1, value 1~7 result value as LEFT to cursor2 value '11'
      assertTrue(cursorJoiner.hasNext());
      assertEquals(Result.LEFT, cursorJoiner.next());
      assertEquals(
          getOrderNumberString(DEFAULT_TABLE1_VALUE_BEGINS + i, MAX_VALUE), cursor1.getString(0));
      assertEquals(
          getOrderNumberString(DEFAULT_TABLE2_VALUE_BEGINS, MAX_VALUE), cursor2.getString(0));
    }
    for (int i = 0; i < UNIQUE_COUNT; i++) {
      // For cursor2, value 11~17 result a value as LEFT to cursor1 value '18'
      assertTrue(cursorJoiner.hasNext());
      assertEquals(Result.RIGHT, cursorJoiner.next());
      assertEquals(getOrderNumberString(EQUAL_START, MAX_VALUE), cursor1.getString(0));
      assertEquals(
          getOrderNumberString(DEFAULT_TABLE2_VALUE_BEGINS + i, MAX_VALUE), cursor2.getString(0));
    }
    for (int i = 0; i < EQUAL_VALUE_COUNT; i++) {
      // For cursor1 and cursor2, value 18~20 result a value as BOTH
      assertTrue(cursorJoiner.hasNext());
      assertEquals(Result.BOTH, cursorJoiner.next());
      assertEquals(getOrderNumberString(EQUAL_START + i, MAX_VALUE), cursor1.getString(0));
      assertEquals(getOrderNumberString(EQUAL_START + i, MAX_VALUE), cursor2.getString(0));
    }
    closeCursor(cursor1);
    closeCursor(cursor2);
  }
  public void testCursorJoinerAndIterator() {
    Cursor cursor1 = getCursor(TABLE_NAME_1, null, null);
    Cursor cursor2 = getCursor(TABLE_NAME_2, null, null);
    // Test with different length ColumenNAmes
    try {
      new CursorJoiner(cursor1, cursor1.getColumnNames(), cursor2, cursor2.getColumnNames());
      fail("CursorJoiner's constructor should throws  IllegalArgumentException here.");
    } catch (IllegalArgumentException e) {
      // expected
    }
    closeCursor(cursor1);
    closeCursor(cursor2);

    String[] columnNames = new String[] {"number"};
    cursor1 = getCursor(TABLE_NAME_1, null, columnNames);
    cursor2 = getCursor(TABLE_NAME_2, null, columnNames);

    CursorJoiner cursorJoiner =
        new CursorJoiner(cursor1, cursor1.getColumnNames(), cursor2, cursor2.getColumnNames());

    // Test remove()
    try {
      cursorJoiner.remove();
      fail("remove() should throws UnsupportedOperationException here");
    } catch (UnsupportedOperationException e) {
      // expected
    }

    assertEquals(TEST_ITEM_COUNT, cursor1.getCount());
    assertEquals(TEST_ITEM_COUNT, cursor2.getCount());

    // Test iterator
    for (CursorJoiner.Result joinResult : cursorJoiner) {
      switch (joinResult) {
        case LEFT:
          // Add the values into table test1 which table test1 possess and table test2 don't.
          assertTrue(cursor1.getString(0).compareTo(cursor2.getString(0)) < 0);
          addValueIntoTable(TABLE_NAME_2, cursor1.getString(0));
          break;
        case RIGHT:
          // Add the values into table test2 which table test2 possess and table test1 don't.
          assertTrue(cursor1.getString(0).compareTo(cursor2.getString(0)) > 0);
          addValueIntoTable(TABLE_NAME_1, cursor2.getString(0));
          break;
        case BOTH:
          // Delete the values table test1 and test2 both possess.
          assertEquals(cursor1.getString(0), cursor2.getString(0));
          deleteValueFromTable(TABLE_NAME_1, cursor1.getString(0));
          deleteValueFromTable(TABLE_NAME_2, cursor2.getString(0));
          break;
      }
    }
    cursor1.requery();
    cursor2.requery();

    // Finally, two tables's number columns have the same contents
    assertEquals(UNIQUE_COUNT * 2, cursor1.getCount());
    assertEquals(UNIQUE_COUNT * 2, cursor2.getCount());

    // For every  table, merged with the other one's unique numbers, and deleted the originally
    // mutual same numbers(EQUAL_START~MAX_VALUE);
    cursor1.moveToFirst();
    cursor2.moveToFirst();
    for (int i = 0; i < UNIQUE_COUNT; i++) {
      assertEquals(
          getOrderNumberString(DEFAULT_TABLE1_VALUE_BEGINS + i, MAX_VALUE), cursor1.getString(0));
      assertEquals(cursor1.getString(0), cursor2.getString(0));
      cursor1.moveToNext();
      cursor2.moveToNext();
    }
    closeCursor(cursor2);
    closeCursor(cursor1);
  }