Fix import in generated PagingSource

ClassName for DataSource.Factory was previously incorrectly instantiated
without the nestedClass syntax.

Fixes: 156996679
Test: ./gradlew room:integration-tests:room-testapp:cC
Change-Id: Id935b7d9656505568323bbe969ca60feda67f7cf
diff --git a/room/compiler/src/main/kotlin/androidx/room/ext/javapoet_ext.kt b/room/compiler/src/main/kotlin/androidx/room/ext/javapoet_ext.kt
index aae6621..e01dc6d 100644
--- a/room/compiler/src/main/kotlin/androidx/room/ext/javapoet_ext.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/ext/javapoet_ext.kt
@@ -99,8 +99,9 @@
     val POSITIONAL_DATA_SOURCE: ClassName =
             ClassName.get(PAGING_PACKAGE, "PositionalDataSource")
     val DATA_SOURCE_FACTORY: ClassName =
-            ClassName.get(PAGING_PACKAGE, "DataSource.Factory")
-    val PAGING_SOURCE: ClassName = ClassName.get(PAGING_PACKAGE, "PagingSource")
+            ClassName.get(PAGING_PACKAGE, "DataSource", "Factory")
+    val PAGING_SOURCE: ClassName =
+            ClassName.get(PAGING_PACKAGE, "PagingSource")
 }
 
 object LifecyclesTypeNames {
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/TestDatabase.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/TestDatabase.java
index 8e36cd8..4d4e446 100644
--- a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/TestDatabase.java
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/TestDatabase.java
@@ -23,6 +23,7 @@
 import androidx.room.integration.testapp.dao.BlobEntityDao;
 import androidx.room.integration.testapp.dao.FunnyNamedDao;
 import androidx.room.integration.testapp.dao.LibraryItemDao;
+import androidx.room.integration.testapp.dao.PagingSourceOnlyUserDao;
 import androidx.room.integration.testapp.dao.PetCoupleDao;
 import androidx.room.integration.testapp.dao.PetDao;
 import androidx.room.integration.testapp.dao.ProductDao;
@@ -65,6 +66,7 @@
 @TypeConverters(TestDatabase.Converters.class)
 public abstract class TestDatabase extends RoomDatabase {
     public abstract UserDao getUserDao();
+    public abstract PagingSourceOnlyUserDao getPagingSourceOnlyUserDao();
     public abstract PetDao getPetDao();
     public abstract UserPetDao getUserPetDao();
     public abstract SchoolDao getSchoolDao();
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/PagingSourceOnlyUserDao.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/PagingSourceOnlyUserDao.java
new file mode 100644
index 0000000..ab910fc
--- /dev/null
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/PagingSourceOnlyUserDao.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 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.dao;
+
+import androidx.paging.PagingSource;
+import androidx.room.Dao;
+import androidx.room.Query;
+import androidx.room.integration.testapp.TestDatabase;
+import androidx.room.integration.testapp.vo.User;
+
+@SuppressWarnings("SameParameterValue")
+@Dao
+public abstract class PagingSourceOnlyUserDao {
+
+    private final TestDatabase mDatabase;
+
+    public PagingSourceOnlyUserDao(TestDatabase database) {
+        mDatabase = database;
+    }
+
+    @Query("SELECT * FROM user where mAge > :age")
+    public abstract PagingSource<Integer, User> loadPagedByAgePagingSource(int age);
+}
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/UserDao.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/UserDao.java
index 485a938..449f2b5 100644
--- a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/UserDao.java
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/UserDao.java
@@ -20,7 +20,6 @@
 
 import androidx.lifecycle.LiveData;
 import androidx.paging.DataSource;
-import androidx.paging.PagingSource;
 import androidx.room.Dao;
 import androidx.room.Delete;
 import androidx.room.Insert;
@@ -247,9 +246,6 @@
     }
 
     @Query("SELECT * FROM user where mAge > :age")
-    public abstract PagingSource<Integer, User> loadPagedByAgePagingSource(int age);
-
-    @Query("SELECT * FROM user where mAge > :age")
     public abstract DataSource.Factory<Integer, User> loadPagedByAge(int age);
 
     @RawQuery(observedEntities = User.class)
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/paging/PagingSourceTest.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/paging/PagingSourceTest.java
index 70e9f7b..8b073a5a 100644
--- a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/paging/PagingSourceTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/paging/PagingSourceTest.java
@@ -33,11 +33,13 @@
 
     @Test
     public void returnsNewInstance() {
-        PagingSource<Integer, User> pagingSource = mUserDao.loadPagedByAgePagingSource(3);
+        PagingSource<Integer, User> pagingSource = mPagingSourceOnlyUserDao
+                .loadPagedByAgePagingSource(3);
         pagingSource.invalidate();
         assertThat(pagingSource.getInvalid()).isTrue();
 
-        PagingSource<Integer, User> newPagingSource = mUserDao.loadPagedByAgePagingSource(3);
+        PagingSource<Integer, User> newPagingSource = mPagingSourceOnlyUserDao
+                .loadPagedByAgePagingSource(3);
         assertThat(newPagingSource.getInvalid()).isFalse();
 
         assertThat(pagingSource).isNotEqualTo(newPagingSource);
diff --git a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/TestDatabaseTest.java b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/TestDatabaseTest.java
index 6f6e8b8..35698f6 100644
--- a/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/TestDatabaseTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/TestDatabaseTest.java
@@ -21,6 +21,7 @@
 import androidx.room.Room;
 import androidx.room.integration.testapp.TestDatabase;
 import androidx.room.integration.testapp.dao.FunnyNamedDao;
+import androidx.room.integration.testapp.dao.PagingSourceOnlyUserDao;
 import androidx.room.integration.testapp.dao.PetCoupleDao;
 import androidx.room.integration.testapp.dao.PetDao;
 import androidx.room.integration.testapp.dao.RawDao;
@@ -40,6 +41,7 @@
 public abstract class TestDatabaseTest {
     protected TestDatabase mDatabase;
     protected UserDao mUserDao;
+    protected PagingSourceOnlyUserDao mPagingSourceOnlyUserDao;
     protected PetDao mPetDao;
     protected UserPetDao mUserPetDao;
     protected SchoolDao mSchoolDao;
@@ -57,6 +59,7 @@
         Context context = ApplicationProvider.getApplicationContext();
         mDatabase = Room.inMemoryDatabaseBuilder(context, TestDatabase.class).build();
         mUserDao = mDatabase.getUserDao();
+        mPagingSourceOnlyUserDao = mDatabase.getPagingSourceOnlyUserDao();
         mPetDao = mDatabase.getPetDao();
         mUserPetDao = mDatabase.getUserPetDao();
         mSchoolDao = mDatabase.getSchoolDao();