Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
test: add empty args exception check (#1859)
Browse files Browse the repository at this point in the history
* checking empty args in unit tests
  • Loading branch information
jayahariv committed Feb 6, 2019
1 parent a5efab0 commit c07bb49
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.io.File;
import java.util.ArrayList;
Expand All @@ -43,6 +45,9 @@
public class DatabaseTest extends BaseTest {
final static String kDatabaseTestBlob = "i'm blob";

@Rule
public ExpectedException thrown = ExpectedException.none();

//---------------------------------------------
// Helper methods
//---------------------------------------------
Expand Down Expand Up @@ -1390,6 +1395,15 @@ public void testCreateIndex() throws CouchbaseLiteException {
Log.i(TAG, "db.getIndexes() -> " + db.getIndexes());
}

@Test
public void testIndexBuilderEmptyArgs() {
thrown.expect(IllegalArgumentException.class);
IndexBuilder.fullTextIndex(null);

thrown.expect(IllegalArgumentException.class);
IndexBuilder.valueIndex(null);
}

@Test
public void testCreateSameIndexTwice() throws CouchbaseLiteException {
// Create index with first name:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,29 @@ public void testJoinWithArrayContains() throws Exception {
Log.e(TAG, "RESULT: " + r.toMap());
}

@Test
public void testJoinWithEmptyArgs() {
DataSource mainDS = DataSource.database(this.db).as("main");

thrown.expect(IllegalArgumentException.class);
QueryBuilder.select(SelectResult.all()).from(mainDS).join(null);

thrown.expect(IllegalArgumentException.class);
QueryBuilder.select(SelectResult.all()).from(mainDS).where(null);

thrown.expect(IllegalArgumentException.class);
QueryBuilder.select(SelectResult.all()).from(mainDS).groupBy(null);

thrown.expect(IllegalArgumentException.class);
QueryBuilder.select(SelectResult.all()).from(mainDS).orderBy(null);

thrown.expect(IllegalArgumentException.class);
QueryBuilder.select(SelectResult.all()).from(mainDS).limit(null);

thrown.expect(IllegalArgumentException.class);
QueryBuilder.select(SelectResult.all()).from(mainDS).limit(null, null);
}

//https://github.com/couchbase/couchbase-lite-android/issues/1785
@Test
public void testResultToMapWithBoolean() throws Exception {
Expand Down

0 comments on commit c07bb49

Please sign in to comment.