Fix FTS failings tests in API 15

Extract out recently added FTS table in SampleDatabase to
its own database to reduce the number of affected tests
that need to be min SDK 16.

Bug: 150588491
Bug: 150589426
Test: PojoTest
Change-Id: I2da7c68952bf00433e4f2a9e0bf01ac7b8edf259
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/MultiInstanceInvalidationTest.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/MultiInstanceInvalidationTest.java
index 0549d299..de24eaa 100644
--- a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/MultiInstanceInvalidationTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/MultiInstanceInvalidationTest.java
@@ -44,6 +44,7 @@
 import androidx.room.integration.testapp.database.Description;
 import androidx.room.integration.testapp.database.Product;
 import androidx.room.integration.testapp.database.SampleDatabase;
+import androidx.room.integration.testapp.database.SampleFtsDatabase;
 import androidx.test.core.app.ApplicationProvider;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 import androidx.test.filters.LargeTest;
@@ -130,8 +131,8 @@
 
     @Test
     public void invalidateInAnotherInstanceFts() throws Exception {
-        final SampleDatabase db1 = openDatabase(true);
-        final SampleDatabase db2 = openDatabase(true);
+        final SampleFtsDatabase db1 = openFtsDatabase(true);
+        final SampleFtsDatabase db2 = openFtsDatabase(true);
 
         Product theProduct = new Product(1, "Candy");
         db2.getProductDao().insert(theProduct);
@@ -382,6 +383,19 @@
         return db;
     }
 
+    private SampleFtsDatabase openFtsDatabase(boolean multiInstanceInvalidation) {
+        final Context context = ApplicationProvider.getApplicationContext();
+        final RoomDatabase.Builder<SampleFtsDatabase> builder = Room
+                .databaseBuilder(context, SampleFtsDatabase.class,
+                        SampleDatabaseService.DATABASE_NAME);
+        if (multiInstanceInvalidation) {
+            builder.enableMultiInstanceInvalidation();
+        }
+        final SampleFtsDatabase db = builder.build();
+        mDatabases.add(db);
+        return db;
+    }
+
     private void bindTestService() throws TimeoutException {
         final Context context = ApplicationProvider.getApplicationContext();
         mService = ISampleDatabaseService.Stub.asInterface(
diff --git a/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/ProductDao.java b/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/ProductDao.java
index 56e4beb..3107224 100644
--- a/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/ProductDao.java
+++ b/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/ProductDao.java
@@ -35,25 +35,12 @@
     void insert(Product product);
 
     /**
-     * Insert a product description.
-     */
-    @Insert
-    void addDescription(Description description);
-
-    /**
      * Insert a review.
      */
     @Insert
     void addReview(Review review);
 
     /**
-     * Query product with matching description.
-     */
-    @Query("SELECT DISTINCT Product.* FROM Product JOIN Description ON mId = mProductId "
-            + "WHERE mText MATCH :query")
-    List<Product> getProductsWithDescription(String query);
-
-    /**
      * Query a products reviews.
      */
     @Query("SELECT * FROM Review WHERE mProductId = :productId")
diff --git a/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/ProductFtsDao.java b/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/ProductFtsDao.java
new file mode 100644
index 0000000..b1913b2
--- /dev/null
+++ b/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/ProductFtsDao.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.room.integration.testapp.database;
+
+import androidx.room.Dao;
+import androidx.room.Insert;
+import androidx.room.Query;
+
+import java.util.List;
+
+/**
+ * Simple Product DAO with FTS.
+ */
+@Dao
+public interface ProductFtsDao extends ProductDao {
+
+    /**
+     * Insert a product description.
+     */
+    @Insert
+    void addDescription(Description description);
+
+    /**
+     * Query product with matching description.
+     */
+    @Query("SELECT DISTINCT Product.* FROM Product JOIN Description ON mId = mProductId "
+            + "WHERE mText MATCH :query")
+    List<Product> getProductsWithDescription(String query);
+}
diff --git a/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/SampleDatabase.java b/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/SampleDatabase.java
index 0c62a26..b0dba5b 100644
--- a/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/SampleDatabase.java
+++ b/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/SampleDatabase.java
@@ -22,7 +22,7 @@
 /**
  * Sample database of customers.
  */
-@Database(entities = {Customer.class, Product.class, Review.class, Description.class},
+@Database(entities = {Customer.class, Product.class, Review.class},
         version = 1, exportSchema = false)
 public abstract class SampleDatabase extends RoomDatabase {
     /**
diff --git a/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/SampleFtsDatabase.java b/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/SampleFtsDatabase.java
new file mode 100644
index 0000000..b6af38a
--- /dev/null
+++ b/room/integration-tests/testapp/src/main/java/androidx/room/integration/testapp/database/SampleFtsDatabase.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.room.integration.testapp.database;
+
+import androidx.room.Database;
+import androidx.room.RoomDatabase;
+
+/**
+ * Sample database of customers and products with FTS.
+ */
+@Database(entities = {Product.class, Review.class, Description.class},
+        version = 1, exportSchema = false)
+public abstract class SampleFtsDatabase extends RoomDatabase {
+    /**
+     * @return product dao.
+     */
+    public abstract ProductFtsDao getProductDao();
+}