CTS updates resulting from merging AppSearchImpl & removing FakeIcing.

Bug: 162450968
Test: AppSearchManagerTest
Change-Id: I6fca4ef4d1014f79f6663e7454d4a08b9dcac4d7
diff --git a/tests/appsearch/src/com/android/cts/appsearch/AppSearchManagerTest.java b/tests/appsearch/src/com/android/cts/appsearch/AppSearchManagerTest.java
index 7da22ac..165fde9 100644
--- a/tests/appsearch/src/com/android/cts/appsearch/AppSearchManagerTest.java
+++ b/tests/appsearch/src/com/android/cts/appsearch/AppSearchManagerTest.java
@@ -35,7 +35,7 @@
 
 import junit.framework.AssertionFailedError;
 
-import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -48,9 +48,10 @@
     private final Context mContext = InstrumentationRegistry.getInstrumentation().getContext();
     private final AppSearchManager mAppSearch = mContext.getSystemService(AppSearchManager.class);
 
-    @After
-    public void tearDown() {
-        mAppSearch.deleteAll();
+    @Before
+    public void setUp() {
+        // Remove all documents from any instances that may have been created in the tests.
+        checkIsSuccess(mAppSearch.setSchema(ImmutableList.of(), /*forceOverride=*/ true));
     }
 
     @Test
@@ -149,7 +150,15 @@
     @Test
     public void testQuery_TypeFilter() {
         // Schema registration
-        checkIsSuccess(mAppSearch.setSchema(AppSearchEmail.SCHEMA));
+        AppSearchSchema genericSchema = new AppSearchSchema.Builder("Generic")
+                .addProperty(new PropertyConfig.Builder("foo")
+                        .setDataType(PropertyConfig.DATA_TYPE_STRING)
+                        .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+                        .setTokenizerType(PropertyConfig.TOKENIZER_TYPE_PLAIN)
+                        .setIndexingType(PropertyConfig.INDEXING_TYPE_PREFIXES)
+                        .build()
+                ).build();
+        checkIsSuccess(mAppSearch.setSchema(AppSearchEmail.SCHEMA, genericSchema));
 
         // Index a document
         AppSearchEmail inEmail =
@@ -159,8 +168,8 @@
                         .setSubject("testPut example")
                         .setBody("This is the body of the testPut email")
                         .build();
-        AppSearchDocument inDoc =
-                new AppSearchDocument.Builder("uri2", "Test").setProperty("foo", "body").build();
+        AppSearchDocument inDoc = new AppSearchDocument.Builder<>("uri2", "Generic")
+                .setProperty("foo", "body").build();
         checkIsSuccess(mAppSearch.putDocuments(ImmutableList.of(inEmail, inDoc)));
 
         // Query for the documents
@@ -169,7 +178,7 @@
         assertThat(results).containsExactly(inEmail, inDoc);
 
         // Query only for Document
-        results = doQuery("body", "Test");
+        results = doQuery("body", "Generic");
         assertThat(results).hasSize(1);
         assertThat(results).containsExactly(inDoc);
     }
@@ -213,9 +222,11 @@
     }
 
     @Test
-    public void testDeleteByTypes() {
+    public void testRemoveByTypes() {
         // Schema registration
-        checkIsSuccess(mAppSearch.setSchema(AppSearchEmail.SCHEMA));
+        AppSearchSchema genericSchema = new AppSearchSchema.Builder("Generic").build();
+        checkIsSuccess(mAppSearch.setSchema(
+                ImmutableList.of(AppSearchEmail.SCHEMA, genericSchema), /*forceOverride=*/ false));
 
         // Index documents
         AppSearchEmail email1 =
@@ -233,8 +244,7 @@
                         .setBody("This is the body of the testPut second email")
                         .build();
         AppSearchDocument document1 =
-                new AppSearchDocument.Builder("uri3", "schemaType")
-                        .setProperty("foo", "bar").build();
+                new AppSearchDocument.Builder<>("uri3", "Generic").build();
         checkIsSuccess(mAppSearch.putDocuments(ImmutableList.of(email1, email2, document1)));
 
         // Check the presence of the documents