diff --git a/.circleci/.firebase.secrets.json.enc b/.circleci/.firebase.secrets.json.enc
index 84e8c322ed..63f49ac7c9 100644
Binary files a/.circleci/.firebase.secrets.json.enc and b/.circleci/.firebase.secrets.json.enc differ
diff --git a/.circleci/gradle.properties.enc b/.circleci/gradle.properties.enc
index 1c350e1c76..565c18aee9 100644
Binary files a/.circleci/gradle.properties.enc and b/.circleci/gradle.properties.enc differ
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000000..40146908b4
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,258 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+ ^$
+
+
+
+
+
+
+
+
+ style
+ ^$
+
+
+
+
+
+
+
+
+ .*
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:layout_width
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:layout_height
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:layout_.*
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:width
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:height
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 27e23cca9e..dc86b86b90 100644
--- a/build.gradle
+++ b/build.gradle
@@ -69,9 +69,11 @@ subprojects {
}
ext {
- daggerVersion = '2.11'
+ daggerVersion = '2.22.1'
wellSqlVersion = '1.4.0'
supportLibraryVersion = '27.1.1'
arch_paging_version = '1.0.1'
arch_lifecycle_version = '1.1.1'
+ arch_core_version = '2.0.1'
+ appcompat_version = '1.0.2'
}
diff --git a/config/checkstyle.xml b/config/checkstyle.xml
index 721b0aa929..340f075a2d 100644
--- a/config/checkstyle.xml
+++ b/config/checkstyle.xml
@@ -160,7 +160,7 @@
-
+
diff --git a/example/build.gradle b/example/build.gradle
index efe92af59f..c430e7b899 100644
--- a/example/build.gradle
+++ b/example/build.gradle
@@ -13,7 +13,7 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
- compileSdkVersion 27
+ compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
@@ -26,7 +26,7 @@ android {
versionCode 1
versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -87,10 +87,13 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
- implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
- implementation "com.android.support:support-v4:$supportLibraryVersion"
- implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
- implementation 'com.android.support.constraint:constraint-layout:1.1.3'
+ implementation "androidx.appcompat:appcompat:$appcompat_version"
+ implementation "androidx.legacy:legacy-support-v4:1.0.0"
+ implementation "androidx.recyclerview:recyclerview:1.0.0"
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation 'androidx.annotation:annotation:1.0.2'
+ implementation "androidx.arch.core:core-common:$arch_core_version"
+ implementation "androidx.arch.core:core-runtime:$arch_core_version"
// WordPress libs
implementation ('org.wordpress:utils:1.20.0') {
@@ -114,16 +117,16 @@ dependencies {
testImplementation 'org.mockito:mockito-core:2.23.0'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
testImplementation 'org.assertj:assertj-core:3.11.1'
- testImplementation "android.arch.core:core-testing:$arch_lifecycle_version"
+ testImplementation "androidx.arch.core:core-testing:$arch_core_version"
androidTestImplementation 'org.mockito:mockito-android:2.6.3'
androidTestImplementation 'org.apache.commons:commons-lang3:3.5'
- androidTestImplementation "android.arch.core:core-testing:1.1.1"
+ androidTestImplementation "androidx.arch.core:core-testing:$arch_core_version"
kaptAndroidTest "com.google.dagger:dagger-compiler:$daggerVersion"
androidTestCompileOnly 'org.glassfish:javax.annotation:10.0-b28'
// Test orchestrator
- androidTestImplementation 'com.android.support.test:runner:1.0.2'
- androidTestUtil 'com.android.support.test:orchestrator:1.0.2'
+ androidTestImplementation 'androidx.test:runner:1.2.0'
+ androidTestUtil 'androidx.test:orchestrator:1.2.0'
// Debug dependencies
debugImplementation 'com.facebook.stetho:stetho:1.5.0'
diff --git a/example/gradle.properties-example b/example/gradle.properties-example
index 3becc9875d..8e0f0567d0 100644
--- a/example/gradle.properties-example
+++ b/example/gradle.properties-example
@@ -1,3 +1,5 @@
# OAuth credentials for example app
wp.OAUTH.APP.ID = wp
wp.OAUTH.APP.SECRET = wp
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/TestUtils.java b/example/src/androidTest/java/org/wordpress/android/fluxc/TestUtils.java
index 3fa7e2d749..4834231021 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/TestUtils.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/TestUtils.java
@@ -2,9 +2,10 @@
import android.content.Context;
import android.content.res.Configuration;
-import android.support.annotation.NonNull;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+
import org.wordpress.android.fluxc.example.test.BuildConfig;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_AccountTest.java b/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_AccountTest.java
index 15b345d3ee..f29b70b94b 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_AccountTest.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_AccountTest.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.mocked;
-import android.support.test.runner.AndroidJUnit4;
+import androidx.test.runner.AndroidJUnit4;
import org.greenrobot.eventbus.Subscribe;
import org.junit.After;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_Base.java b/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_Base.java
index f87397258b..6d69a8b0a0 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_Base.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_Base.java
@@ -13,7 +13,7 @@
import javax.inject.Inject;
-import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static androidx.test.InstrumentationRegistry.getInstrumentation;
public class MockedStack_Base {
Context mAppContext;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_NotificationTest.kt b/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_NotificationTest.kt
index 76acbc2e80..bf336229aa 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_NotificationTest.kt
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_NotificationTest.kt
@@ -5,6 +5,7 @@ import org.greenrobot.eventbus.Subscribe
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
+import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.wordpress.android.fluxc.Dispatcher
@@ -16,11 +17,12 @@ import org.wordpress.android.fluxc.model.notification.NoteIdSet
import org.wordpress.android.fluxc.model.notification.NotificationModel
import org.wordpress.android.fluxc.module.ResponseMockingInterceptor
import org.wordpress.android.fluxc.network.rest.wpcom.notifications.NotificationRestClient
+import org.wordpress.android.fluxc.store.NotificationStore.DeviceRegistrationErrorType
import org.wordpress.android.fluxc.store.NotificationStore.FetchNotificationHashesResponsePayload
import org.wordpress.android.fluxc.store.NotificationStore.FetchNotificationResponsePayload
import org.wordpress.android.fluxc.store.NotificationStore.FetchNotificationsResponsePayload
-import org.wordpress.android.fluxc.store.NotificationStore.MarkNotificationsReadResponsePayload
import org.wordpress.android.fluxc.store.NotificationStore.MarkNotificationSeenResponsePayload
+import org.wordpress.android.fluxc.store.NotificationStore.MarkNotificationsReadResponsePayload
import org.wordpress.android.fluxc.store.NotificationStore.NotificationAppKey
import org.wordpress.android.fluxc.store.NotificationStore.RegisterDeviceResponsePayload
import org.wordpress.android.fluxc.store.SiteStore
@@ -105,6 +107,31 @@ class MockedStack_NotificationTest : MockedStack_Base() {
assertEquals(responseJson.get("ID").asString, payload.deviceId)
}
+ @Test
+ fun testRegistrationResponseNull() {
+ val errorJson = JsonObject().apply {
+ addProperty("error", DeviceRegistrationErrorType.INVALID_RESPONSE.name)
+ addProperty("message", "Response object is null")
+ }
+
+ interceptor.respondWithError(errorJson)
+
+ val gcmToken = "sample-token"
+ val uuid = "sample-uuid"
+ val site = SiteModel().apply { siteId = 123456 }
+ notificationRestClient.registerDeviceForPushNotifications(gcmToken, NotificationAppKey.WOOCOMMERCE, uuid, site)
+
+ countDownLatch = CountDownLatch(1)
+ assertTrue(countDownLatch.await(TestUtils.DEFAULT_TIMEOUT_MS.toLong(), TimeUnit.MILLISECONDS))
+
+ assertEquals(NotificationAction.REGISTERED_DEVICE, lastAction!!.type)
+
+ val payload = lastAction!!.payload as RegisterDeviceResponsePayload
+ assertNotNull(payload.error)
+ assertNull(payload.deviceId)
+ assertEquals(DeviceRegistrationErrorType.INVALID_RESPONSE, payload.error.type)
+ }
+
@Test
fun testUnregistration() {
val responseJson = JsonObject().apply { addProperty("success", "true") }
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_WCStatsTest.kt b/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_WCStatsTest.kt
index c77e3ea723..c734f3a988 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_WCStatsTest.kt
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_WCStatsTest.kt
@@ -21,6 +21,7 @@ import org.wordpress.android.fluxc.store.WCStatsStore.FetchOrderStatsResponsePay
import org.wordpress.android.fluxc.store.WCStatsStore.FetchTopEarnersStatsResponsePayload
import org.wordpress.android.fluxc.store.WCStatsStore.FetchVisitorStatsResponsePayload
import org.wordpress.android.fluxc.store.WCStatsStore.OrderStatsErrorType
+import org.wordpress.android.fluxc.store.WCStatsStore.OrderStatsErrorType.RESPONSE_NULL
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeUnit.MILLISECONDS
@@ -171,6 +172,28 @@ class MockedStack_WCStatsTest : MockedStack_Base() {
assertEquals(OrderStatsErrorType.INVALID_PARAM, payload.error.type)
}
+ @Test
+ fun testStatsFetchResponseNullError() {
+ val errorJson = JsonObject().apply {
+ addProperty("error", OrderStatsErrorType.RESPONSE_NULL.name)
+ addProperty("message", "Response object is null")
+ }
+
+ interceptor.respondWithError(errorJson)
+ orderStatsRestClient.fetchStats(siteModel, OrderStatsApiUnit.DAY, "2019-02-01", 7)
+
+ countDownLatch = CountDownLatch(1)
+ assertTrue(countDownLatch.await(TestUtils.DEFAULT_TIMEOUT_MS.toLong(), TimeUnit.MILLISECONDS))
+
+ assertEquals(WCStatsAction.FETCHED_ORDER_STATS, lastAction!!.type)
+ val payload = lastAction!!.payload as FetchOrderStatsResponsePayload
+ assertNotNull(payload.error)
+ assertEquals(siteModel, payload.site)
+ assertEquals(OrderStatsApiUnit.DAY, payload.apiUnit)
+ assertNull(payload.stats)
+ assertEquals(OrderStatsErrorType.RESPONSE_NULL, payload.error.type)
+ }
+
@Test
fun testFetchTopEarnersStatsSuccess() {
interceptor.respondWith("wc-top-earners-response-success.json")
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/module/MockedToolsModule.java b/example/src/androidTest/java/org/wordpress/android/fluxc/module/MockedToolsModule.java
index a80e8efa7e..0e78f49fac 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/module/MockedToolsModule.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/module/MockedToolsModule.java
@@ -1,7 +1,8 @@
package org.wordpress.android.fluxc.module;
import android.graphics.Bitmap;
-import android.support.v4.util.LruCache;
+
+import androidx.collection.LruCache;
import com.android.volley.toolbox.ImageLoader.ImageCache;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_Base.java b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_Base.java
index a4fd4a45a3..373be50222 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_Base.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_Base.java
@@ -17,7 +17,7 @@
import javax.inject.Inject;
import javax.inject.Named;
-import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static androidx.test.InstrumentationRegistry.getInstrumentation;
/**
* NOTE:
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_FluxCImageLoaderTest.java b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_FluxCImageLoaderTest.java
index a28049a81c..3b22620dd6 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_FluxCImageLoaderTest.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_FluxCImageLoaderTest.java
@@ -26,7 +26,7 @@
import javax.inject.Inject;
-import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_MediaTestWPCom.java b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_MediaTestWPCom.java
index 14fd8cdf71..6a5027f760 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_MediaTestWPCom.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_MediaTestWPCom.java
@@ -1,8 +1,9 @@
package org.wordpress.android.fluxc.release;
import android.annotation.SuppressLint;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PluginTestJetpack.java b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PluginTestJetpack.java
index 8d874744b0..71f0ba5bfc 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PluginTestJetpack.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PluginTestJetpack.java
@@ -1,8 +1,9 @@
package org.wordpress.android.fluxc.release;
-import android.support.annotation.NonNull;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+
import junit.framework.Assert;
import org.greenrobot.eventbus.Subscribe;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostListTestWpCom.kt b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostListTestWpCom.kt
index 9c4193b903..2542742e64 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostListTestWpCom.kt
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostListTestWpCom.kt
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.release
-import android.arch.core.executor.testing.InstantTaskExecutorRule
+import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostListTestXMLRPC.kt b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostListTestXMLRPC.kt
index cd2cef3cfb..ac3c82c3ce 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostListTestXMLRPC.kt
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostListTestXMLRPC.kt
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.release
-import android.arch.core.executor.testing.InstantTaskExecutorRule
+import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostTestWPCom.java b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostTestWPCom.java
index e1e3c93177..ba00640eb8 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostTestWPCom.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_PostTestWPCom.java
@@ -43,6 +43,7 @@
public class ReleaseStack_PostTestWPCom extends ReleaseStack_WPComBase {
@Inject PostStore mPostStore;
+ @Inject PostSqlUtils mPostSqlUtils;
private static final String POST_DEFAULT_TITLE = "PostTestWPCom base post";
private static final String POST_DEFAULT_DESCRIPTION = "Hi there, I'm a post from FluxC!";
@@ -93,7 +94,7 @@ public void testRemoveLocalDraft() throws InterruptedException {
mDispatcher.dispatch(PostActionBuilder.newRemovePostAction(post));
assertTrue(mCountDownLatch.await(TestUtils.DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS));
- assertEquals(0, PostSqlUtils.getPostsForSite(sSite, false).size());
+ assertEquals(0, mPostSqlUtils.getPostsForSite(sSite, false).size());
}
@Test
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_ReaderTest.java b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_ReaderTest.java
index a5d759a744..e5ee72b3e8 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_ReaderTest.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_ReaderTest.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.release;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import org.greenrobot.eventbus.Subscribe;
import org.junit.Test;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_StockMediaTest.java b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_StockMediaTest.java
index 1fe1f16515..a283004e07 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_StockMediaTest.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_StockMediaTest.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.release;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import org.greenrobot.eventbus.Subscribe;
import org.junit.Test;
@@ -21,8 +21,7 @@
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.wordpress.android.fluxc.network.rest.wpcom.stockmedia.StockMediaRestClient
- .DEFAULT_NUM_STOCK_MEDIA_PER_FETCH;
+import static org.wordpress.android.fluxc.network.rest.wpcom.stockmedia.StockMediaRestClient.DEFAULT_NUM_STOCK_MEDIA_PER_FETCH;
public class ReleaseStack_StockMediaTest extends ReleaseStack_WPComBase {
@Inject StockMediaStore mStockMediaStore;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_ThemeTestJetpack.java b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_ThemeTestJetpack.java
index 6a247d3df2..6e0a2dcf64 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_ThemeTestJetpack.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_ThemeTestJetpack.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.release;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_WPComBase.java b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_WPComBase.java
index 50040aee36..e89193846c 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_WPComBase.java
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_WPComBase.java
@@ -25,7 +25,7 @@
import javax.inject.Inject;
-import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/ListStoreConnectedTestHelper.kt b/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/ListStoreConnectedTestHelper.kt
index cc4e130596..cd415dc5e6 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/ListStoreConnectedTestHelper.kt
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/ListStoreConnectedTestHelper.kt
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.release.utils
-import android.arch.lifecycle.Lifecycle
+import androidx.lifecycle.Lifecycle
import org.wordpress.android.fluxc.model.list.ListDescriptor
import org.wordpress.android.fluxc.model.list.PagedListWrapper
import org.wordpress.android.fluxc.model.list.datasource.ListItemDataSourceInterface
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/LiveDataTextExtensions.kt b/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/LiveDataTextExtensions.kt
index 665300510f..4ee4890aa9 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/LiveDataTextExtensions.kt
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/LiveDataTextExtensions.kt
@@ -1,8 +1,8 @@
package org.wordpress.android.fluxc.release.utils
-import android.arch.lifecycle.LiveData
-import android.arch.lifecycle.MediatorLiveData
-import android.arch.lifecycle.Observer
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MediatorLiveData
+import androidx.lifecycle.Observer
import org.junit.Assert.assertEquals
/**
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/PagedListWrapperTestExtensions.kt b/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/PagedListWrapperTestExtensions.kt
index dc499dd496..3dfca762b0 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/PagedListWrapperTestExtensions.kt
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/PagedListWrapperTestExtensions.kt
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.release.utils
-import android.arch.lifecycle.Observer
+import androidx.lifecycle.Observer
import org.junit.Assert.assertTrue
import org.wordpress.android.fluxc.TestUtils
import org.wordpress.android.fluxc.model.list.PagedListWrapper
diff --git a/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/SimpleTestLifecycle.kt b/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/SimpleTestLifecycle.kt
index e47efd56de..bc76b5dd1c 100644
--- a/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/SimpleTestLifecycle.kt
+++ b/example/src/androidTest/java/org/wordpress/android/fluxc/release/utils/SimpleTestLifecycle.kt
@@ -1,8 +1,8 @@
package org.wordpress.android.fluxc.release.utils
-import android.arch.lifecycle.Lifecycle
-import android.arch.lifecycle.LifecycleOwner
-import android.arch.lifecycle.LifecycleRegistry
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.LifecycleOwner
+import androidx.lifecycle.LifecycleRegistry
/**
* A simple helper [LifecycleOwner] implementation to be used in tests.
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/AccountFragment.kt b/example/src/main/java/org/wordpress/android/fluxc/example/AccountFragment.kt
index 70d197c82e..333957fc0c 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/AccountFragment.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/AccountFragment.kt
@@ -3,11 +3,11 @@ package org.wordpress.android.fluxc.example
import android.app.AlertDialog
import android.content.Context
import android.os.Bundle
-import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
+import androidx.fragment.app.Fragment
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_account.*
import org.greenrobot.eventbus.Subscribe
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/CommentsFragment.java b/example/src/main/java/org/wordpress/android/fluxc/example/CommentsFragment.java
index 2e16abcf46..2acc2ee1c8 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/CommentsFragment.java
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/CommentsFragment.java
@@ -2,13 +2,14 @@
import android.content.Context;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.wordpress.android.fluxc.Dispatcher;
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/CustomStatsDialog.kt b/example/src/main/java/org/wordpress/android/fluxc/example/CustomStatsDialog.kt
index a2ae0c61f2..50c0c1eb0c 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/CustomStatsDialog.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/CustomStatsDialog.kt
@@ -3,14 +3,14 @@ package org.wordpress.android.fluxc.example
import android.R.layout
import android.app.DatePickerDialog
import android.os.Bundle
-import android.support.v4.app.DialogFragment
-import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.ArrayAdapter
import android.widget.Button
+import androidx.fragment.app.DialogFragment
+import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.dialog_custom_stats.*
import org.wordpress.android.fluxc.store.WCStatsStore.StatsGranularity
import org.wordpress.android.fluxc.utils.DateUtils
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/FragmentExt.kt b/example/src/main/java/org/wordpress/android/fluxc/example/FragmentExt.kt
index 99058900a3..099ca65710 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/FragmentExt.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/FragmentExt.kt
@@ -1,7 +1,7 @@
@file:JvmName("FragmentExtensions")
package org.wordpress.android.fluxc.example
-import android.support.v4.app.Fragment
+import androidx.fragment.app.Fragment
/**
* Shortcut for appending messages to the log in MainActivity
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/MainExampleActivity.kt b/example/src/main/java/org/wordpress/android/fluxc/example/MainExampleActivity.kt
index ae5e24817d..0b3530a95b 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/MainExampleActivity.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/MainExampleActivity.kt
@@ -1,9 +1,9 @@
package org.wordpress.android.fluxc.example
import android.os.Bundle
-import android.support.v4.app.Fragment
-import android.support.v4.app.FragmentActivity
import android.text.method.ScrollingMovementMethod
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.FragmentActivity
import dagger.android.AndroidInjection
import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/MainFragment.kt b/example/src/main/java/org/wordpress/android/fluxc/example/MainFragment.kt
index b629297c33..77918d8154 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/MainFragment.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/MainFragment.kt
@@ -2,12 +2,12 @@ package org.wordpress.android.fluxc.example
import android.content.Context
import android.os.Bundle
-import android.support.v4.app.Fragment
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.View.OnClickListener
import android.view.ViewGroup
+import androidx.fragment.app.Fragment
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_main.*
import org.greenrobot.eventbus.Subscribe
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/MediaFragment.java b/example/src/main/java/org/wordpress/android/fluxc/example/MediaFragment.java
index 995dee8405..0333276e57 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/MediaFragment.java
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/MediaFragment.java
@@ -5,8 +5,6 @@
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -15,6 +13,9 @@
import android.widget.Spinner;
import android.widget.TextView;
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.wordpress.android.fluxc.Dispatcher;
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/NotificationTypeSubtypeDialog.kt b/example/src/main/java/org/wordpress/android/fluxc/example/NotificationTypeSubtypeDialog.kt
index 03291dafe7..962159231f 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/NotificationTypeSubtypeDialog.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/NotificationTypeSubtypeDialog.kt
@@ -1,12 +1,12 @@
package org.wordpress.android.fluxc.example
import android.os.Bundle
-import android.support.v4.app.DialogFragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.ArrayAdapter
+import androidx.fragment.app.DialogFragment
import kotlinx.android.synthetic.main.dialog_notification_type_subtype.*
import org.wordpress.android.fluxc.model.notification.NotificationModel.Kind
import org.wordpress.android.fluxc.model.notification.NotificationModel.Subkind
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/NotificationsFragment.kt b/example/src/main/java/org/wordpress/android/fluxc/example/NotificationsFragment.kt
index fcf55e4e57..21d71f1d47 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/NotificationsFragment.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/NotificationsFragment.kt
@@ -2,10 +2,10 @@ package org.wordpress.android.fluxc.example
import android.content.Context
import android.os.Bundle
-import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.fragment.app.Fragment
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_notifications.*
import org.greenrobot.eventbus.Subscribe
@@ -13,8 +13,8 @@ import org.greenrobot.eventbus.ThreadMode.MAIN
import org.wordpress.android.fluxc.Dispatcher
import org.wordpress.android.fluxc.action.NotificationAction.FETCH_NOTIFICATION
import org.wordpress.android.fluxc.action.NotificationAction.FETCH_NOTIFICATIONS
-import org.wordpress.android.fluxc.action.NotificationAction.MARK_NOTIFICATIONS_SEEN
import org.wordpress.android.fluxc.action.NotificationAction.MARK_NOTIFICATIONS_READ
+import org.wordpress.android.fluxc.action.NotificationAction.MARK_NOTIFICATIONS_SEEN
import org.wordpress.android.fluxc.action.NotificationAction.UPDATE_NOTIFICATION
import org.wordpress.android.fluxc.example.NotificationTypeSubtypeDialog.Listener
import org.wordpress.android.fluxc.generated.NotificationActionBuilder
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/PostsFragment.kt b/example/src/main/java/org/wordpress/android/fluxc/example/PostsFragment.kt
index 66e64b2758..4d874ce129 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/PostsFragment.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/PostsFragment.kt
@@ -2,10 +2,10 @@ package org.wordpress.android.fluxc.example
import android.content.Context
import android.os.Bundle
-import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.fragment.app.Fragment
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_posts.*
import org.greenrobot.eventbus.Subscribe
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/SSLWarningDialog.java b/example/src/main/java/org/wordpress/android/fluxc/example/SSLWarningDialog.java
index 5e14370843..af3714b6fe 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/SSLWarningDialog.java
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/SSLWarningDialog.java
@@ -4,13 +4,14 @@
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v4.app.DialogFragment;
-import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
+
public class SSLWarningDialog extends DialogFragment {
public interface Listener {
void onClick(String username, String password, String url);
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/SignedOutActionsFragment.java b/example/src/main/java/org/wordpress/android/fluxc/example/SignedOutActionsFragment.java
index b535f27978..f6630b0bd1 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/SignedOutActionsFragment.java
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/SignedOutActionsFragment.java
@@ -4,16 +4,17 @@
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.EditText;
+import androidx.annotation.NonNull;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentTransaction;
+
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.wordpress.android.fluxc.Dispatcher;
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/SiteSelectorDialog.kt b/example/src/main/java/org/wordpress/android/fluxc/example/SiteSelectorDialog.kt
index 70d5158493..9fdc9e6007 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/SiteSelectorDialog.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/SiteSelectorDialog.kt
@@ -4,12 +4,12 @@ import android.app.AlertDialog
import android.app.Dialog
import android.content.Context
import android.os.Bundle
-import android.support.v4.app.DialogFragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.TextView
+import androidx.fragment.app.DialogFragment
import dagger.android.support.AndroidSupportInjection
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/SitesFragment.java b/example/src/main/java/org/wordpress/android/fluxc/example/SitesFragment.java
index 132687a001..8cf190e37a 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/SitesFragment.java
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/SitesFragment.java
@@ -2,14 +2,15 @@
import android.content.Context;
import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentTransaction;
+
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.wordpress.android.fluxc.Dispatcher;
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/TaxonomiesFragment.java b/example/src/main/java/org/wordpress/android/fluxc/example/TaxonomiesFragment.java
index 681d7bdb4b..b26ac7ecf1 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/TaxonomiesFragment.java
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/TaxonomiesFragment.java
@@ -2,12 +2,13 @@
import android.content.Context;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import androidx.fragment.app.Fragment;
+
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.wordpress.android.fluxc.Dispatcher;
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/ThemeFragment.kt b/example/src/main/java/org/wordpress/android/fluxc/example/ThemeFragment.kt
index 457ae4eccd..ae34b3419b 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/ThemeFragment.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/ThemeFragment.kt
@@ -2,12 +2,12 @@ package org.wordpress.android.fluxc.example
import android.content.Context
import android.os.Bundle
-import android.support.v4.app.Fragment
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
+import androidx.fragment.app.Fragment
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_themes.*
import org.greenrobot.eventbus.Subscribe
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/ThreeEditTextDialog.kt b/example/src/main/java/org/wordpress/android/fluxc/example/ThreeEditTextDialog.kt
index 2eab7d22ce..804a24d1ad 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/ThreeEditTextDialog.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/ThreeEditTextDialog.kt
@@ -2,11 +2,11 @@ package org.wordpress.android.fluxc.example
import android.app.Dialog
import android.os.Bundle
-import android.support.v4.app.DialogFragment
-import android.support.v7.app.AlertDialog
import android.text.TextUtils
import android.view.View
import android.widget.EditText
+import androidx.appcompat.app.AlertDialog
+import androidx.fragment.app.DialogFragment
class ThreeEditTextDialog : DialogFragment() {
private lateinit var editText1: EditText
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/UploadsFragment.java b/example/src/main/java/org/wordpress/android/fluxc/example/UploadsFragment.java
index a85e5c1d0e..e4cf6b99a8 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/UploadsFragment.java
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/UploadsFragment.java
@@ -5,13 +5,14 @@
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.wordpress.android.fluxc.Dispatcher;
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/WCAddOrderShipmentTrackingDialog.kt b/example/src/main/java/org/wordpress/android/fluxc/example/WCAddOrderShipmentTrackingDialog.kt
index 5581fc6a34..30fe112efa 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/WCAddOrderShipmentTrackingDialog.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/WCAddOrderShipmentTrackingDialog.kt
@@ -3,8 +3,6 @@ package org.wordpress.android.fluxc.example
import android.R.layout
import android.app.DatePickerDialog
import android.os.Bundle
-import android.support.v4.app.DialogFragment
-import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -12,6 +10,8 @@ import android.view.WindowManager
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Button
+import androidx.fragment.app.DialogFragment
+import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.dialog_wc_add_order_shipment_tracking.*
import org.wordpress.android.fluxc.model.SiteModel
import org.wordpress.android.fluxc.model.WCOrderModel
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/di/AppComponent.kt b/example/src/main/java/org/wordpress/android/fluxc/example/di/AppComponent.kt
index 45ad1784b9..e0ad17b328 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/di/AppComponent.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/di/AppComponent.kt
@@ -4,7 +4,7 @@ import android.app.Application
import dagger.BindsInstance
import dagger.Component
import dagger.android.AndroidInjector
-import dagger.android.support.AndroidSupportInjectionModule
+import dagger.android.AndroidInjectionModule
import org.wordpress.android.fluxc.example.ExampleApp
import org.wordpress.android.fluxc.module.ReleaseBaseModule
import org.wordpress.android.fluxc.module.ReleaseNetworkModule
@@ -14,7 +14,7 @@ import javax.inject.Singleton
@Singleton
@Component(modules = arrayOf(
- AndroidSupportInjectionModule::class,
+ AndroidInjectionModule::class,
ApplicationModule::class,
AppConfigModule::class,
ReleaseOkHttpClientModule::class,
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/ui/WooCommerceFragment.kt b/example/src/main/java/org/wordpress/android/fluxc/example/ui/WooCommerceFragment.kt
index d2f542f44d..aa3b6d107f 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/ui/WooCommerceFragment.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/ui/WooCommerceFragment.kt
@@ -2,10 +2,10 @@ package org.wordpress.android.fluxc.example.ui
import android.content.Context
import android.os.Bundle
-import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.fragment.app.Fragment
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_woocommerce.*
import org.greenrobot.eventbus.Subscribe
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/ui/orders/WooOrdersFragment.kt b/example/src/main/java/org/wordpress/android/fluxc/example/ui/orders/WooOrdersFragment.kt
index ed5407c915..c8fb504273 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/ui/orders/WooOrdersFragment.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/ui/orders/WooOrdersFragment.kt
@@ -2,10 +2,10 @@ package org.wordpress.android.fluxc.example.ui.orders
import android.content.Context
import android.os.Bundle
-import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.fragment.app.Fragment
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_woo_orders.*
import org.greenrobot.eventbus.Subscribe
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/ui/products/WooProductsFragment.kt b/example/src/main/java/org/wordpress/android/fluxc/example/ui/products/WooProductsFragment.kt
index 481532d2d5..08851d02a9 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/ui/products/WooProductsFragment.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/ui/products/WooProductsFragment.kt
@@ -2,10 +2,10 @@ package org.wordpress.android.fluxc.example.ui.products
import android.content.Context
import android.os.Bundle
-import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.fragment.app.Fragment
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_woo_products.*
import org.greenrobot.eventbus.Subscribe
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/ui/stats/WooStatsFragment.kt b/example/src/main/java/org/wordpress/android/fluxc/example/ui/stats/WooStatsFragment.kt
index 69d7ee6bae..ac08639dd4 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/ui/stats/WooStatsFragment.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/ui/stats/WooStatsFragment.kt
@@ -2,10 +2,10 @@ package org.wordpress.android.fluxc.example.ui.stats
import android.content.Context
import android.os.Bundle
-import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.fragment.app.Fragment
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_woo_stats.*
import org.greenrobot.eventbus.Subscribe
diff --git a/example/src/main/java/org/wordpress/android/fluxc/example/utils/AlertDialogUtils.kt b/example/src/main/java/org/wordpress/android/fluxc/example/utils/AlertDialogUtils.kt
index ec1e39a9f0..3b20cb1348 100644
--- a/example/src/main/java/org/wordpress/android/fluxc/example/utils/AlertDialogUtils.kt
+++ b/example/src/main/java/org/wordpress/android/fluxc/example/utils/AlertDialogUtils.kt
@@ -1,8 +1,8 @@
package org.wordpress.android.fluxc.example.utils
-import android.support.v4.app.FragmentActivity
-import android.support.v7.app.AlertDialog
import android.widget.EditText
+import androidx.appcompat.app.AlertDialog
+import androidx.fragment.app.FragmentActivity
typealias AlertTextListener = (EditText) -> Unit
diff --git a/example/src/main/res/layout/dialog_custom_stats.xml b/example/src/main/res/layout/dialog_custom_stats.xml
index 7160737a8a..2101ae7173 100644
--- a/example/src/main/res/layout/dialog_custom_stats.xml
+++ b/example/src/main/res/layout/dialog_custom_stats.xml
@@ -7,7 +7,7 @@
android:layout_height="match_parent"
tools:context="org.wordpress.android.fluxc.example.CustomStatsDialog">
-
-
+
diff --git a/example/src/main/res/layout/dialog_notification_type_subtype.xml b/example/src/main/res/layout/dialog_notification_type_subtype.xml
index ba8ddfcd27..82d447256b 100644
--- a/example/src/main/res/layout/dialog_notification_type_subtype.xml
+++ b/example/src/main/res/layout/dialog_notification_type_subtype.xml
@@ -1,5 +1,5 @@
-
-
+
diff --git a/example/src/main/res/layout/dialog_wc_add_order_shipment_tracking.xml b/example/src/main/res/layout/dialog_wc_add_order_shipment_tracking.xml
index 552bea8983..835be6c996 100644
--- a/example/src/main/res/layout/dialog_wc_add_order_shipment_tracking.xml
+++ b/example/src/main/res/layout/dialog_wc_add_order_shipment_tracking.xml
@@ -6,7 +6,7 @@
android:layout_height="match_parent"
tools:context="org.wordpress.android.fluxc.example.WCAddOrderShipmentTrackingDialog">
-
@@ -177,5 +177,5 @@
android:text="CANCEL"
app:layout_constraintEnd_toStartOf="@+id/tracking_ok"
app:layout_constraintTop_toBottomOf="@+id/tracking_dateShipped"/>
-
+
diff --git a/example/src/test/java/org/wordpress/android/fluxc/list/PagedListFactoryTest.kt b/example/src/test/java/org/wordpress/android/fluxc/list/PagedListFactoryTest.kt
index 887d16a33c..ecff9b2dc0 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/list/PagedListFactoryTest.kt
+++ b/example/src/test/java/org/wordpress/android/fluxc/list/PagedListFactoryTest.kt
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.list
-import android.arch.paging.DataSource.InvalidatedCallback
+import androidx.paging.DataSource.InvalidatedCallback
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.times
import com.nhaarman.mockitokotlin2.verify
diff --git a/example/src/test/java/org/wordpress/android/fluxc/list/PagedListWrapperTest.kt b/example/src/test/java/org/wordpress/android/fluxc/list/PagedListWrapperTest.kt
index 7e8d3e8d13..d7c5f176b5 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/list/PagedListWrapperTest.kt
+++ b/example/src/test/java/org/wordpress/android/fluxc/list/PagedListWrapperTest.kt
@@ -1,11 +1,11 @@
package org.wordpress.android.fluxc.list
-import android.arch.core.executor.testing.InstantTaskExecutorRule
-import android.arch.lifecycle.Lifecycle
-import android.arch.lifecycle.LifecycleRegistry
-import android.arch.lifecycle.MutableLiveData
-import android.arch.lifecycle.Observer
-import android.arch.paging.PagedList
+import androidx.arch.core.executor.testing.InstantTaskExecutorRule
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.LifecycleRegistry
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.Observer
+import androidx.paging.PagedList
import com.nhaarman.mockitokotlin2.firstValue
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.verify
diff --git a/example/src/test/java/org/wordpress/android/fluxc/page/PageStoreLocalDraftTest.kt b/example/src/test/java/org/wordpress/android/fluxc/page/PageStoreLocalDraftTest.kt
index 9eec26f83f..45a94c49da 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/page/PageStoreLocalDraftTest.kt
+++ b/example/src/test/java/org/wordpress/android/fluxc/page/PageStoreLocalDraftTest.kt
@@ -21,7 +21,13 @@ import java.util.UUID
@RunWith(RobolectricTestRunner::class)
class PageStoreLocalDraftTest {
- private val pageStore = PageStore(postStore = mock(), dispatcher = mock(), coroutineContext = Dispatchers.Default)
+ private val postSqlUtils = PostSqlUtils()
+ private val pageStore = PageStore(
+ postStore = mock(),
+ dispatcher = mock(),
+ coroutineContext = Dispatchers.Default,
+ postSqlUtils = postSqlUtils
+ )
@Before
fun setUp() {
@@ -62,7 +68,7 @@ class PageStoreLocalDraftTest {
}
)
- expectedPages.plus(unexpectedPosts).forEach { PostSqlUtils.insertPostForResult(it) }
+ expectedPages.plus(unexpectedPosts).forEach { postSqlUtils.insertPostForResult(it) }
// Act
val localDraftPages = pageStore.getLocalDraftPages(site)
@@ -70,7 +76,7 @@ class PageStoreLocalDraftTest {
// Assert
assertThat(localDraftPages).hasSize(3)
assertThat(localDraftPages).allMatch { it.title.startsWith(baseTitle) }
- assertThat(localDraftPages.map { it.pageId }).isEqualTo(expectedPages.map { it.id })
+ assertThat(localDraftPages.map { it.id }).isEqualTo(expectedPages.map { it.id })
}
private fun createLocalDraft(localSiteId: Int, baseTitle: String = "Title") = PostModel().apply {
diff --git a/example/src/test/java/org/wordpress/android/fluxc/page/PageStoreTest.kt b/example/src/test/java/org/wordpress/android/fluxc/page/PageStoreTest.kt
index d4f80f83ab..8551b6eac9 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/page/PageStoreTest.kt
+++ b/example/src/test/java/org/wordpress/android/fluxc/page/PageStoreTest.kt
@@ -31,6 +31,7 @@ import org.wordpress.android.fluxc.model.page.PageStatus.PUBLISHED
import org.wordpress.android.fluxc.model.page.PageStatus.SCHEDULED
import org.wordpress.android.fluxc.model.page.PageStatus.TRASHED
import org.wordpress.android.fluxc.model.post.PostStatus
+import org.wordpress.android.fluxc.persistence.PostSqlUtils
import org.wordpress.android.fluxc.store.PageStore
import org.wordpress.android.fluxc.store.PostStore
import org.wordpress.android.fluxc.store.PostStore.FetchPostsPayload
@@ -81,7 +82,7 @@ class PageStoreTest {
actionCaptor = argumentCaptor()
val pages = listOf(pageWithoutQuery, pageWithQuery, pageWithoutTitle)
whenever(postStore.getPagesForSite(site)).thenReturn(pages)
- store = PageStore(postStore, dispatcher, Dispatchers.Unconfined)
+ store = PageStore(postStore, PostSqlUtils(), dispatcher, Dispatchers.Unconfined)
}
@Test
diff --git a/example/src/test/java/org/wordpress/android/fluxc/persistence/PostSqlUtilsTest.kt b/example/src/test/java/org/wordpress/android/fluxc/persistence/PostSqlUtilsTest.kt
index 86013ea727..0358a7c4fc 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/persistence/PostSqlUtilsTest.kt
+++ b/example/src/test/java/org/wordpress/android/fluxc/persistence/PostSqlUtilsTest.kt
@@ -16,6 +16,8 @@ import kotlin.test.assertNull
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner::class)
class PostSqlUtilsTest {
+ private val postSqlUtils = PostSqlUtils()
+
@Before
fun setUp() {
val appContext = RuntimeEnvironment.application.applicationContext
@@ -39,18 +41,18 @@ class PostSqlUtilsTest {
post.localSiteId = site.id
post.remotePostId = remotePostId
- post = PostSqlUtils.insertPostForResult(post)
+ post = postSqlUtils.insertPostForResult(post)
assertNull(post.autoSaveModified)
assertNull(post.autoSavePreviewUrl)
assertEquals(0, post.autoSaveRevisionId)
- PostSqlUtils.updatePostsAutoSave(
+ postSqlUtils.updatePostsAutoSave(
site,
PostRemoteAutoSaveModel(revisionId, remotePostId, modifiedDate, previewUrl)
)
- val postsForSite = PostSqlUtils.getPostsForSite(site, false)
+ val postsForSite = postSqlUtils.getPostsForSite(site, false)
assertEquals(1, postsForSite.size)
assertEquals(revisionId, postsForSite.first().autoSaveRevisionId)
diff --git a/example/src/test/java/org/wordpress/android/fluxc/post/PostStoreUnitTest.java b/example/src/test/java/org/wordpress/android/fluxc/post/PostStoreDbIntegrationTest.java
similarity index 84%
rename from example/src/test/java/org/wordpress/android/fluxc/post/PostStoreUnitTest.java
rename to example/src/test/java/org/wordpress/android/fluxc/post/PostStoreDbIntegrationTest.java
index 60dd7cc41f..b1cccac32c 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/post/PostStoreUnitTest.java
+++ b/example/src/test/java/org/wordpress/android/fluxc/post/PostStoreDbIntegrationTest.java
@@ -43,9 +43,10 @@
import static org.junit.Assert.assertNotEquals;
@RunWith(RobolectricTestRunner.class)
-public class PostStoreUnitTest {
+public class PostStoreDbIntegrationTest {
+ private PostSqlUtils mPostSqlUtils = new PostSqlUtils();
private PostStore mPostStore = new PostStore(new Dispatcher(), Mockito.mock(PostRestClient.class),
- Mockito.mock(PostXMLRPCClient.class));
+ Mockito.mock(PostXMLRPCClient.class), mPostSqlUtils);
@Before
public void setUp() {
@@ -63,7 +64,7 @@ public void setUp() {
@Test
public void testInsertNullPost() {
- assertEquals(0, PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(null));
+ assertEquals(0, mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(null));
assertEquals(0, PostTestUtils.getPostsCount());
}
@@ -72,7 +73,7 @@ public void testInsertNullPost() {
public void testSimpleInsertionAndRetrieval() {
PostModel postModel = new PostModel();
postModel.setRemotePostId(42);
- PostModel result = PostSqlUtils.insertPostForResult(postModel);
+ PostModel result = mPostSqlUtils.insertPostForResult(postModel);
assertEquals(1, PostTestUtils.getPostsCount());
assertEquals(42, PostTestUtils.getPosts().get(0).getRemotePostId());
@@ -83,15 +84,15 @@ public void testSimpleInsertionAndRetrieval() {
public void testInsertWithLocalChanges() {
PostModel postModel = PostTestUtils.generateSampleUploadedPost();
postModel.setIsLocallyChanged(true);
- PostSqlUtils.insertPostForResult(postModel);
+ mPostSqlUtils.insertPostForResult(postModel);
String newTitle = "A different title";
postModel.setTitle(newTitle);
- assertEquals(0, PostSqlUtils.insertOrUpdatePostKeepingLocalChanges(postModel));
+ assertEquals(0, mPostSqlUtils.insertOrUpdatePostKeepingLocalChanges(postModel));
assertEquals("A test post", PostTestUtils.getPosts().get(0).getTitle());
- assertEquals(1, PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postModel));
+ assertEquals(1, mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postModel));
assertEquals(newTitle, PostTestUtils.getPosts().get(0).getTitle());
}
@@ -100,7 +101,7 @@ public void testPushAndFetchCollision() throws InterruptedException {
// Test uploading a post, fetching remote posts and updating the db from the fetch first
PostModel postModel = PostTestUtils.generateSampleLocalDraftPost();
- PostSqlUtils.insertPostForResult(postModel);
+ mPostSqlUtils.insertPostForResult(postModel);
// The post after uploading, updated with the remote post ID, about to be saved locally
PostModel postFromUploadResponse = PostTestUtils.getPosts().get(0);
@@ -111,8 +112,8 @@ public void testPushAndFetchCollision() throws InterruptedException {
final PostModel postFromPostListFetch = postFromUploadResponse.clone();
postFromPostListFetch.setId(0);
- PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postFromPostListFetch);
- PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postFromUploadResponse);
+ mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postFromPostListFetch);
+ mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postFromUploadResponse);
assertEquals(1, PostTestUtils.getPosts().size());
@@ -124,29 +125,29 @@ public void testPushAndFetchCollision() throws InterruptedException {
@Test
public void testInsertWithoutLocalChanges() {
PostModel postModel = PostTestUtils.generateSampleUploadedPost();
- PostSqlUtils.insertPostForResult(postModel);
+ mPostSqlUtils.insertPostForResult(postModel);
String newTitle = "A different title";
postModel.setTitle(newTitle);
- assertEquals(1, PostSqlUtils.insertOrUpdatePostKeepingLocalChanges(postModel));
+ assertEquals(1, mPostSqlUtils.insertOrUpdatePostKeepingLocalChanges(postModel));
assertEquals(newTitle, PostTestUtils.getPosts().get(0).getTitle());
newTitle = "Another different title";
postModel.setTitle(newTitle);
- assertEquals(1, PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postModel));
+ assertEquals(1, mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postModel));
assertEquals(newTitle, PostTestUtils.getPosts().get(0).getTitle());
}
@Test
public void testGetPostsForSite() {
PostModel uploadedPost1 = PostTestUtils.generateSampleUploadedPost();
- PostSqlUtils.insertPostForResult(uploadedPost1);
+ mPostSqlUtils.insertPostForResult(uploadedPost1);
PostModel uploadedPost2 = PostTestUtils.generateSampleUploadedPost();
uploadedPost2.setLocalSiteId(8);
- PostSqlUtils.insertPostForResult(uploadedPost2);
+ mPostSqlUtils.insertPostForResult(uploadedPost2);
SiteModel site1 = new SiteModel();
site1.setId(uploadedPost1.getLocalSiteId());
@@ -165,9 +166,9 @@ public void testGetPostsWithFormatForSite() {
PostModel textPost = PostTestUtils.generateSampleUploadedPost();
PostModel imagePost = PostTestUtils.generateSampleUploadedPost("image");
PostModel videoPost = PostTestUtils.generateSampleUploadedPost("video");
- PostSqlUtils.insertPostForResult(textPost);
- PostSqlUtils.insertPostForResult(imagePost);
- PostSqlUtils.insertPostForResult(videoPost);
+ mPostSqlUtils.insertPostForResult(textPost);
+ mPostSqlUtils.insertPostForResult(imagePost);
+ mPostSqlUtils.insertPostForResult(videoPost);
SiteModel site = new SiteModel();
site.setId(textPost.getLocalSiteId());
@@ -189,10 +190,10 @@ public void testGetPublishedPosts() {
site.setId(6);
PostModel uploadedPost = PostTestUtils.generateSampleUploadedPost();
- PostSqlUtils.insertPostForResult(uploadedPost);
+ mPostSqlUtils.insertPostForResult(uploadedPost);
PostModel localDraft = PostTestUtils.generateSampleLocalDraftPost();
- PostSqlUtils.insertPostForResult(localDraft);
+ mPostSqlUtils.insertPostForResult(localDraft);
assertEquals(2, PostTestUtils.getPostsCount());
assertEquals(2, mPostStore.getPostsCountForSite(site));
@@ -203,7 +204,7 @@ public void testGetPublishedPosts() {
@Test
public void testGetPostByLocalId() {
PostModel post = PostTestUtils.generateSampleLocalDraftPost();
- PostSqlUtils.insertPostForResult(post);
+ mPostSqlUtils.insertPostForResult(post);
assertEquals(post, mPostStore.getPostByLocalPostId(post.getId()));
}
@@ -211,7 +212,7 @@ public void testGetPostByLocalId() {
@Test
public void testGetPostByRemoteId() {
PostModel post = PostTestUtils.generateSampleUploadedPost();
- PostSqlUtils.insertPostForResult(post);
+ mPostSqlUtils.insertPostForResult(post);
SiteModel site = new SiteModel();
site.setId(6);
@@ -225,21 +226,21 @@ public void testDeleteUploadedPosts() {
site.setId(6);
PostModel uploadedPost1 = PostTestUtils.generateSampleUploadedPost();
- PostSqlUtils.insertPostForResult(uploadedPost1);
+ mPostSqlUtils.insertPostForResult(uploadedPost1);
PostModel uploadedPost2 = PostTestUtils.generateSampleUploadedPost();
uploadedPost2.setRemotePostId(9);
- PostSqlUtils.insertPostForResult(uploadedPost2);
+ mPostSqlUtils.insertPostForResult(uploadedPost2);
PostModel localDraft = PostTestUtils.generateSampleLocalDraftPost();
- PostSqlUtils.insertPostForResult(localDraft);
+ mPostSqlUtils.insertPostForResult(localDraft);
PostModel locallyChangedPost = PostTestUtils.generateSampleLocallyChangedPost();
- PostSqlUtils.insertPostForResult(locallyChangedPost);
+ mPostSqlUtils.insertPostForResult(locallyChangedPost);
assertEquals(4, mPostStore.getPostsCountForSite(site));
- PostSqlUtils.deleteUploadedPostsForSite(site, false);
+ mPostSqlUtils.deleteUploadedPostsForSite(site, false);
assertEquals(2, mPostStore.getPostsCountForSite(site));
}
@@ -250,32 +251,32 @@ public void testDeletePost() {
site.setId(6);
PostModel uploadedPost1 = PostTestUtils.generateSampleUploadedPost();
- PostSqlUtils.insertPostForResult(uploadedPost1);
+ mPostSqlUtils.insertPostForResult(uploadedPost1);
PostModel uploadedPost2 = PostTestUtils.generateSampleUploadedPost();
uploadedPost2.setRemotePostId(9);
- PostSqlUtils.insertPostForResult(uploadedPost2);
+ mPostSqlUtils.insertPostForResult(uploadedPost2);
PostModel localDraft = PostTestUtils.generateSampleLocalDraftPost();
- PostSqlUtils.insertPostForResult(localDraft);
+ mPostSqlUtils.insertPostForResult(localDraft);
PostModel locallyChangedPost = PostTestUtils.generateSampleLocallyChangedPost();
- PostSqlUtils.insertPostForResult(locallyChangedPost);
+ mPostSqlUtils.insertPostForResult(locallyChangedPost);
assertEquals(4, mPostStore.getPostsCountForSite(site));
- PostSqlUtils.deletePost(uploadedPost1);
+ mPostSqlUtils.deletePost(uploadedPost1);
assertEquals(null, mPostStore.getPostByLocalPostId(uploadedPost1.getId()));
assertEquals(3, mPostStore.getPostsCountForSite(site));
- PostSqlUtils.deletePost(uploadedPost2);
- PostSqlUtils.deletePost(localDraft);
+ mPostSqlUtils.deletePost(uploadedPost2);
+ mPostSqlUtils.deletePost(localDraft);
assertNotEquals(null, mPostStore.getPostByLocalPostId(locallyChangedPost.getId()));
assertEquals(1, mPostStore.getPostsCountForSite(site));
- PostSqlUtils.deletePost(locallyChangedPost);
+ mPostSqlUtils.deletePost(locallyChangedPost);
assertEquals(null, mPostStore.getPostByLocalPostId(locallyChangedPost.getId()));
assertEquals(0, mPostStore.getPostsCountForSite(site));
@@ -290,13 +291,13 @@ public void testPostAndPageSeparation() {
PostModel post = new PostModel();
post.setLocalSiteId(6);
post.setRemotePostId(42);
- PostSqlUtils.insertPostForResult(post);
+ mPostSqlUtils.insertPostForResult(post);
PostModel page = new PostModel();
page.setIsPage(true);
page.setLocalSiteId(6);
page.setRemotePostId(43);
- PostSqlUtils.insertPostForResult(page);
+ mPostSqlUtils.insertPostForResult(page);
assertEquals(2, PostTestUtils.getPostsCount());
@@ -319,21 +320,21 @@ public void testPostOrder() {
post.setLocalSiteId(6);
post.setRemotePostId(42);
post.setDateCreated(DateTimeUtils.iso8601UTCFromDate(new Date()));
- PostSqlUtils.insertPostForResult(post);
+ mPostSqlUtils.insertPostForResult(post);
PostModel localDraft = new PostModel();
localDraft.setLocalSiteId(6);
localDraft.setIsLocalDraft(true);
localDraft.setDateCreated("2016-01-01T07:00:00+00:00");
- PostSqlUtils.insertPostForResult(localDraft);
+ mPostSqlUtils.insertPostForResult(localDraft);
PostModel scheduledPost = new PostModel();
scheduledPost.setLocalSiteId(6);
scheduledPost.setRemotePostId(23);
scheduledPost.setDateCreated("2056-01-01T07:00:00+00:00");
- PostSqlUtils.insertPostForResult(scheduledPost);
+ mPostSqlUtils.insertPostForResult(scheduledPost);
- List posts = PostSqlUtils.getPostsForSite(site, false);
+ List posts = mPostSqlUtils.getPostsForSite(site, false);
// Expect order draft > scheduled > published
assertTrue(posts.get(0).isLocalDraft());
@@ -344,15 +345,15 @@ public void testPostOrder() {
@Test
public void testRemoveAllPosts() {
PostModel uploadedPost1 = PostTestUtils.generateSampleUploadedPost();
- PostSqlUtils.insertPostForResult(uploadedPost1);
+ mPostSqlUtils.insertPostForResult(uploadedPost1);
PostModel uploadedPost2 = PostTestUtils.generateSampleUploadedPost();
uploadedPost2.setLocalSiteId(8);
- PostSqlUtils.insertPostForResult(uploadedPost2);
+ mPostSqlUtils.insertPostForResult(uploadedPost2);
assertEquals(2, PostTestUtils.getPostsCount());
- PostSqlUtils.deleteAllPosts();
+ mPostSqlUtils.deleteAllPosts();
assertEquals(0, PostTestUtils.getPostsCount());
}
@@ -360,17 +361,17 @@ public void testRemoveAllPosts() {
@Test
public void testNumLocalChanges() {
// first make sure there aren't any local changes
- assertEquals(PostStore.getNumLocalChanges(), 0);
+ assertEquals(mPostStore.getNumLocalChanges(), 0);
// then add a post with local changes and ensure we get the correct count
PostModel testPost = PostTestUtils.generateSampleLocalDraftPost();
testPost.setIsLocallyChanged(true);
- PostSqlUtils.insertOrUpdatePost(testPost, true);
- assertEquals(PostStore.getNumLocalChanges(), 1);
+ mPostSqlUtils.insertOrUpdatePost(testPost, true);
+ assertEquals(mPostStore.getNumLocalChanges(), 1);
// delete the post and again check the count
- PostSqlUtils.deletePost(testPost);
- assertEquals(PostStore.getNumLocalChanges(), 0);
+ mPostSqlUtils.deletePost(testPost);
+ assertEquals(mPostStore.getNumLocalChanges(), 0);
}
@Test
@@ -443,15 +444,15 @@ public void testGetLocalDraftPostsMethodOnlyReturnsLocalDrafts() {
for (int i = 0; i < 3; i++) {
final String compoundTitle = baseTitle.concat(":").concat(UUID.randomUUID().toString());
final PostModel post = PostTestUtils.generateSampleLocalDraftPost(compoundTitle);
- PostSqlUtils.insertPostForResult(post);
+ mPostSqlUtils.insertPostForResult(post);
}
final PostModel localDraftPage = PostTestUtils.generateSampleLocalDraftPost();
localDraftPage.setIsPage(true);
- PostSqlUtils.insertPostForResult(localDraftPage);
+ mPostSqlUtils.insertPostForResult(localDraftPage);
final PostModel uploadedPost = PostTestUtils.generateSampleUploadedPost();
- PostSqlUtils.insertPostForResult(uploadedPost);
+ mPostSqlUtils.insertPostForResult(uploadedPost);
final SiteModel site = new SiteModel();
site.setId(PostTestUtils.DEFAULT_LOCAL_SITE_ID);
@@ -524,14 +525,14 @@ private void generateAndInsertPosts(int localSiteId, List localIds, Lis
for (int i = 1; i <= localIds.size(); i++) {
PostModel post = PostTestUtils.generateSampleLocalDraftPost();
post.setLocalSiteId(localSiteId);
- PostSqlUtils.insertOrUpdatePost(post, false);
+ mPostSqlUtils.insertOrUpdatePost(post, false);
}
for (RemoteId remoteId : remoteIds) {
PostModel post = PostTestUtils.generateSampleUploadedPost();
post.setLocalSiteId(localSiteId);
post.setRemotePostId(remoteId.getValue());
- PostSqlUtils.insertOrUpdatePost(post, false);
+ mPostSqlUtils.insertOrUpdatePost(post, false);
}
}
}
diff --git a/example/src/test/java/org/wordpress/android/fluxc/post/PostStoreTest.kt b/example/src/test/java/org/wordpress/android/fluxc/post/PostStoreTest.kt
new file mode 100644
index 0000000000..e610c09dfb
--- /dev/null
+++ b/example/src/test/java/org/wordpress/android/fluxc/post/PostStoreTest.kt
@@ -0,0 +1,246 @@
+package org.wordpress.android.fluxc.post
+
+import com.nhaarman.mockitokotlin2.any
+import com.nhaarman.mockitokotlin2.argThat
+import com.nhaarman.mockitokotlin2.mock
+import com.nhaarman.mockitokotlin2.verify
+import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
+import com.nhaarman.mockitokotlin2.whenever
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mock
+import org.mockito.junit.MockitoJUnitRunner
+import org.wordpress.android.fluxc.Dispatcher
+import org.wordpress.android.fluxc.action.ListAction
+import org.wordpress.android.fluxc.action.PostAction
+import org.wordpress.android.fluxc.generated.PostActionBuilder
+import org.wordpress.android.fluxc.model.PostModel
+import org.wordpress.android.fluxc.model.SiteModel
+import org.wordpress.android.fluxc.model.list.PostListDescriptor
+import org.wordpress.android.fluxc.model.post.PostStatus
+import org.wordpress.android.fluxc.model.post.PostStatus.PUBLISHED
+import org.wordpress.android.fluxc.persistence.PostSqlUtils
+import org.wordpress.android.fluxc.store.ListStore.FetchedListItemsPayload
+import org.wordpress.android.fluxc.store.PostStore
+import org.wordpress.android.fluxc.store.PostStore.FetchPostListResponsePayload
+import org.wordpress.android.fluxc.store.PostStore.PostError
+import org.wordpress.android.fluxc.store.PostStore.PostErrorType.GENERIC_ERROR
+import org.wordpress.android.fluxc.store.PostStore.PostListItem
+
+@RunWith(MockitoJUnitRunner::class)
+class PostStoreTest {
+ @Mock lateinit var site: SiteModel
+ @Mock lateinit var postSqlUtils: PostSqlUtils
+ @Mock lateinit var dispatcher: Dispatcher
+ private lateinit var store: PostStore
+ @Mock lateinit var mockedListDescriptor: PostListDescriptor
+
+ @Before
+ fun setUp() {
+ store = PostStore(dispatcher, mock(), mock(), postSqlUtils)
+ whenever(mockedListDescriptor.site).thenReturn(mock())
+ // verify "register" so we can use verifyNoMoreInteractions in all the test methods
+ verify(dispatcher).register(any())
+ }
+
+ @Test
+ fun `handleFetchedPostList emits FetchedListItemsAction on success`() {
+ // Arrange
+ val action = createFetchedPostListAction()
+
+ // Act
+ store.onAction(action)
+
+ // Assert
+ verify(dispatcher).dispatch(argThat {
+ (this.type == ListAction.FETCHED_LIST_ITEMS)
+ })
+ verifyNoMoreInteractions(dispatcher)
+ }
+
+ @Test
+ fun `handleFetchedPostList emits FetchedListItemsAction on error`() {
+ // Arrange
+ val action = createFetchedPostListAction(postError = PostError(GENERIC_ERROR))
+
+ // Act
+ store.onAction(action)
+
+ // Assert
+ verify(dispatcher).dispatch(argThat {
+ (this.type == ListAction.FETCHED_LIST_ITEMS)
+ })
+ verifyNoMoreInteractions(dispatcher)
+ }
+
+ @Test
+ fun `handleFetchedPostList emits FetchedListItemsAction with an error field set on error`() {
+ // Arrange
+ val action = createFetchedPostListAction(postError = PostError(GENERIC_ERROR))
+
+ // Act
+ store.onAction(action)
+
+ // Assert
+ verify(dispatcher).dispatch(argThat {
+ (this.payload as FetchedListItemsPayload).isError
+ })
+ verifyNoMoreInteractions(dispatcher)
+ }
+
+ @Test
+ fun `handleFetchedPostList emits just FetchedListItemsAction when post not changed`() {
+ // Arrange
+ val postInLocalDb = createPostModel()
+ whenever(postSqlUtils.getPostsByRemoteIds(any(), any())).thenReturn(listOf(postInLocalDb))
+
+ val remotePostListItem = createRemotePostListItem(postInLocalDb)
+ val action = createFetchedPostListAction(postListItems = listOf(remotePostListItem))
+
+ // Act
+ store.onAction(action)
+
+ // Assert
+ verify(dispatcher).dispatch(argThat {
+ (this.type == ListAction.FETCHED_LIST_ITEMS)
+ })
+ verifyNoMoreInteractions(dispatcher)
+ }
+
+ @Test
+ fun `handleFetchedPostList emits FetchPostAction when post changed in remote`() {
+ // Arrange
+ val postInLocalDb = createPostModel()
+ whenever(postSqlUtils.getPostsByRemoteIds(any(), any())).thenReturn(listOf(postInLocalDb))
+
+ val remotePostListItem = createRemotePostListItem(postInLocalDb, lastModified = "modified in remote")
+ val action = createFetchedPostListAction(postListItems = listOf(remotePostListItem))
+
+ // Act
+ store.onAction(action)
+
+ // Assert
+ verify(dispatcher).dispatch(argThat {
+ (this.type == PostAction.FETCH_POST)
+ })
+ verify(dispatcher).dispatch(argThat {
+ (this.type == ListAction.FETCHED_LIST_ITEMS)
+ })
+ verifyNoMoreInteractions(dispatcher)
+ }
+
+ @Test
+ fun `handleFetchedPostList emits UpdatePostAction when post changed in both remote and local`() {
+ // Arrange
+ val postInLocalDb = createPostModel(isLocallyChanged = true)
+ whenever(postSqlUtils.getPostsByRemoteIds(any(), any())).thenReturn(listOf(postInLocalDb))
+
+ val remotePostListItem = createRemotePostListItem(postInLocalDb, lastModified = "modified in remote")
+ val action = createFetchedPostListAction(postListItems = listOf(remotePostListItem))
+
+ // Act
+ store.onAction(action)
+
+ // Assert
+ verify(dispatcher).dispatch(argThat {
+ (this.type == PostAction.UPDATE_POST)
+ })
+ verify(dispatcher).dispatch(argThat {
+ (this.type == ListAction.FETCHED_LIST_ITEMS)
+ })
+ verifyNoMoreInteractions(dispatcher)
+ }
+
+ @Test
+ fun `handleFetchedPostList emits UpdatePostAction when post changed locally and post status changed in remote`() {
+ // Arrange
+ val postInLocalDb = createPostModel(isLocallyChanged = true)
+ whenever(postSqlUtils.getPostsByRemoteIds(any(), any())).thenReturn(listOf(postInLocalDb))
+
+ val remotePostListItem = createRemotePostListItem(postInLocalDb, status = PostStatus.TRASHED.toString())
+ val action = createFetchedPostListAction(postListItems = listOf(remotePostListItem))
+
+ // Act
+ store.onAction(action)
+
+ // Assert
+ verify(dispatcher).dispatch(argThat {
+ (this.type == PostAction.UPDATE_POST)
+ })
+ verify(dispatcher).dispatch(argThat {
+ (this.type == ListAction.FETCHED_LIST_ITEMS)
+ })
+ verifyNoMoreInteractions(dispatcher)
+ }
+
+ @Test
+ fun `handleFetchedPostList sets remoteLastModified field when post changed in both remote and local`() {
+ // Arrange
+ val postInLocalDb = createPostModel(isLocallyChanged = true)
+ whenever(postSqlUtils.getPostsByRemoteIds(any(), any())).thenReturn(listOf(postInLocalDb))
+
+ val remotePostListItem = createRemotePostListItem(postInLocalDb, lastModified = "modified in remote")
+ val action = createFetchedPostListAction(postListItems = listOf(remotePostListItem))
+
+ // Act
+ store.onAction(action)
+
+ // Assert
+ verify(dispatcher).dispatch(argThat {
+ ((this.payload as? PostModel)?.remoteLastModified == remotePostListItem.lastModified)
+ })
+ }
+
+ @Test
+ fun `handleFetchedPostList emits FetchPostAction when post status changed in remote`() {
+ // Arrange
+ val postInLocalDb = createPostModel()
+ whenever(postSqlUtils.getPostsByRemoteIds(any(), any())).thenReturn(listOf(postInLocalDb))
+
+ val remotePostListItem = createRemotePostListItem(postInLocalDb, status = PostStatus.TRASHED.toString())
+ val action = createFetchedPostListAction(postListItems = listOf(remotePostListItem))
+
+ // Act
+ store.onAction(action)
+
+ // Assert
+ verify(dispatcher).dispatch(argThat {
+ (this.type == PostAction.FETCH_POST)
+ })
+ verify(dispatcher).dispatch(argThat {
+ (this.type == ListAction.FETCHED_LIST_ITEMS)
+ })
+ verifyNoMoreInteractions(dispatcher)
+ }
+
+ private fun createFetchedPostListAction(
+ postListItems: List = listOf(),
+ listDescriptor: PostListDescriptor = mockedListDescriptor,
+ postError: PostError? = null
+ ) = PostActionBuilder.newFetchedPostListAction(
+ FetchPostListResponsePayload(
+ listDescriptor,
+ postListItems,
+ false,
+ false,
+ postError
+ )
+ )
+
+ private fun createPostModel(isLocallyChanged: Boolean = false, postStatus: PostStatus = PUBLISHED): PostModel {
+ val post = PostModel()
+ post.remotePostId = 1
+ post.status = postStatus.toString()
+ post.setIsLocallyChanged(isLocallyChanged)
+ post.autoSaveModified = "1955-11-05T14:15:00Z"
+ return post
+ }
+
+ private fun createRemotePostListItem(
+ post: PostModel,
+ status: String = post.status,
+ lastModified: String = post.lastModified,
+ autoSaveModified: String = post.autoSaveModified
+ ) = PostListItem(post.remotePostId, lastModified, status, autoSaveModified)
+}
diff --git a/example/src/test/java/org/wordpress/android/fluxc/post/PostTestUtils.java b/example/src/test/java/org/wordpress/android/fluxc/post/PostTestUtils.java
index b246fad476..c0ccb162c6 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/post/PostTestUtils.java
+++ b/example/src/test/java/org/wordpress/android/fluxc/post/PostTestUtils.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.post;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.yarolegovich.wellsql.WellSql;
diff --git a/example/src/test/java/org/wordpress/android/fluxc/site/SiteStoreUnitTest.java b/example/src/test/java/org/wordpress/android/fluxc/site/SiteStoreUnitTest.java
index ba5967b960..54fed66be6 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/site/SiteStoreUnitTest.java
+++ b/example/src/test/java/org/wordpress/android/fluxc/site/SiteStoreUnitTest.java
@@ -18,6 +18,7 @@
import org.wordpress.android.fluxc.model.SitesModel;
import org.wordpress.android.fluxc.network.rest.wpcom.site.SiteRestClient;
import org.wordpress.android.fluxc.network.xmlrpc.site.SiteXMLRPCClient;
+import org.wordpress.android.fluxc.persistence.PostSqlUtils;
import org.wordpress.android.fluxc.persistence.SiteSqlUtils;
import org.wordpress.android.fluxc.persistence.SiteSqlUtils.DuplicateSiteException;
import org.wordpress.android.fluxc.persistence.WellSqlConfig;
@@ -45,7 +46,8 @@
@RunWith(RobolectricTestRunner.class)
public class SiteStoreUnitTest {
- private SiteStore mSiteStore = new SiteStore(new Dispatcher(), Mockito.mock(SiteRestClient.class),
+ private PostSqlUtils mPostSqlUtils = new PostSqlUtils();
+ private SiteStore mSiteStore = new SiteStore(new Dispatcher(), mPostSqlUtils, Mockito.mock(SiteRestClient.class),
Mockito.mock(SiteXMLRPCClient.class));
@Before
@@ -811,7 +813,7 @@ public void testRemoveWPComRestSitesAbsentFromList()
sitesToKeep.addAll(allSites.subList(0, 6));
// remove six sites (2/3 * (15 - 6))
- SiteSqlUtils.removeWPComRestSitesAbsentFromList(sitesToKeep);
+ SiteSqlUtils.removeWPComRestSitesAbsentFromList(mPostSqlUtils, sitesToKeep);
assertTrue(mSiteStore.getSitesCount() == 9);
diff --git a/example/src/test/java/org/wordpress/android/fluxc/store/StatsStoreTest.kt b/example/src/test/java/org/wordpress/android/fluxc/store/StatsStoreTest.kt
index 9b6f58c10d..3ae81e4d9f 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/store/StatsStoreTest.kt
+++ b/example/src/test/java/org/wordpress/android/fluxc/store/StatsStoreTest.kt
@@ -1,5 +1,6 @@
package org.wordpress.android.fluxc.store
+import android.content.SharedPreferences
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.never
@@ -12,6 +13,7 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
+import org.mockito.Mockito
import org.mockito.junit.MockitoJUnitRunner
import org.wordpress.android.fluxc.model.SiteModel
import org.wordpress.android.fluxc.persistence.InsightTypeSqlUtils
@@ -19,12 +21,17 @@ import org.wordpress.android.fluxc.store.StatsStore.InsightType.COMMENTS
import org.wordpress.android.fluxc.store.StatsStore.InsightType.FOLLOWERS
import org.wordpress.android.fluxc.store.StatsStore.InsightType.LATEST_POST_SUMMARY
import org.wordpress.android.fluxc.store.StatsStore.InsightType.POSTING_ACTIVITY
+import org.wordpress.android.fluxc.store.StatsStore.ManagementType
import org.wordpress.android.fluxc.test
+import org.wordpress.android.fluxc.utils.PreferenceUtils.PreferenceUtilsWrapper
@RunWith(MockitoJUnitRunner::class)
class StatsStoreTest {
@Mock lateinit var site: SiteModel
@Mock lateinit var insightTypesSqlUtils: InsightTypeSqlUtils
+ @Mock lateinit var preferenceUtilsWrapper: PreferenceUtilsWrapper
+ @Mock lateinit var sharedPreferences: SharedPreferences
+ @Mock lateinit var sharedPreferencesEditor: SharedPreferences.Editor
private lateinit var store: StatsStore
@ExperimentalCoroutinesApi
@@ -32,8 +39,11 @@ class StatsStoreTest {
fun setUp() {
store = StatsStore(
Unconfined,
- insightTypesSqlUtils
+ insightTypesSqlUtils,
+ preferenceUtilsWrapper
)
+ whenever(preferenceUtilsWrapper.getFluxCPreferences()).thenReturn(sharedPreferences)
+ whenever(sharedPreferences.edit()).thenReturn(sharedPreferencesEditor)
}
@Test
@@ -150,4 +160,52 @@ class StatsStoreTest {
store.getRemovedInsights(addedTypes - POSTING_ACTIVITY)
)
}
+
+ @Test
+ fun `insight types starts with news type and ends with control type when news card was not shown`() = test {
+ whenever(insightTypesSqlUtils.selectAddedItemsOrderedByStatus(site)).thenReturn(listOf(COMMENTS))
+ whenever(sharedPreferences.getBoolean(INSIGHTS_MANAGEMENT_NEWS_CARD_SHOWN, false)).thenReturn(false)
+
+ val insightTypes = store.getInsightTypes(site)
+
+ assertThat(insightTypes).hasSize(3)
+ assertThat(insightTypes[0]).isEqualTo(ManagementType.NEWS_CARD)
+ assertThat(insightTypes[1]).isEqualTo(COMMENTS)
+ assertThat(insightTypes[2]).isEqualTo(ManagementType.CONTROL)
+ }
+
+ @Test
+ fun `insight types does not start with news type when news card was shown`() = test {
+ whenever(insightTypesSqlUtils.selectAddedItemsOrderedByStatus(site)).thenReturn(listOf(COMMENTS))
+ whenever(sharedPreferences.getBoolean(INSIGHTS_MANAGEMENT_NEWS_CARD_SHOWN, false)).thenReturn(true)
+
+ val insightTypes = store.getInsightTypes(site)
+
+ assertThat(insightTypes).hasSize(2)
+ assertThat(insightTypes[0]).isEqualTo(COMMENTS)
+ assertThat(insightTypes[1]).isEqualTo(ManagementType.CONTROL)
+ }
+
+ @Test
+ fun `hide news card sets shared prefs`() {
+ whenever(sharedPreferencesEditor.putBoolean(any(), any())).thenReturn(sharedPreferencesEditor)
+
+ store.hideInsightsManagementNewsCard()
+
+ verify(sharedPreferences).edit()
+ Mockito.inOrder(sharedPreferencesEditor).apply {
+ this.verify(sharedPreferencesEditor).putBoolean(INSIGHTS_MANAGEMENT_NEWS_CARD_SHOWN, true)
+ this.verify(sharedPreferencesEditor).apply()
+ }
+ }
+
+ @Test
+ fun `is news card showing returns from shared prefs`() {
+ val prefsValue = true
+ whenever(sharedPreferences.getBoolean(INSIGHTS_MANAGEMENT_NEWS_CARD_SHOWN, true)).thenReturn(prefsValue)
+
+ val insightsManagementNewsCardShowing = store.isInsightsManagementNewsCardShowing()
+
+ assertThat(insightsManagementNewsCardShowing).isEqualTo(prefsValue)
+ }
}
diff --git a/example/src/test/java/org/wordpress/android/fluxc/upload/UploadSqlUtilsTest.java b/example/src/test/java/org/wordpress/android/fluxc/upload/UploadSqlUtilsTest.java
index 3ef0d848dd..e4b751e1da 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/upload/UploadSqlUtilsTest.java
+++ b/example/src/test/java/org/wordpress/android/fluxc/upload/UploadSqlUtilsTest.java
@@ -33,6 +33,7 @@
@RunWith(RobolectricTestRunner.class)
public class UploadSqlUtilsTest {
private Random mRandom = new Random(System.currentTimeMillis());
+ private PostSqlUtils mPostSqlUtils = new PostSqlUtils();
@Before
public void setUp() {
@@ -173,7 +174,7 @@ public void testInsertNullPost() {
@Test
public void testInsertPost() {
PostModel testPost = UploadTestUtils.getTestPost();
- assertEquals(1, PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(testPost));
+ assertEquals(1, mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(testPost));
List postList = PostTestUtils.getPosts();
assertEquals(1, postList.size());
assertNotNull(postList.get(0));
@@ -189,7 +190,7 @@ public void testInsertPost() {
assertEquals(PostUploadModel.PENDING, postUploadModel.getUploadState());
// Deleting the PostModel should cause the corresponding PostUploadModel to be deleted also
- PostSqlUtils.deletePost(testPost);
+ mPostSqlUtils.deletePost(testPost);
postList = PostTestUtils.getPosts();
assertTrue(postList.isEmpty());
@@ -202,10 +203,10 @@ public void testInsertPost() {
public void testGetPostModelsByState() {
PostModel testPost1 = UploadTestUtils.getTestPost();
testPost1.setIsLocalDraft(true);
- assertEquals(1, PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(testPost1));
+ assertEquals(1, mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(testPost1));
PostModel testPost2 = UploadTestUtils.getTestPost();
testPost2.setIsLocalDraft(true);
- assertEquals(1, PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(testPost2));
+ assertEquals(1, mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(testPost2));
List postList = PostTestUtils.getPosts();
assertEquals(2, postList.size());
@@ -255,8 +256,8 @@ public void testDeletePostUploadModel() {
testPost1.setIsLocalDraft(true);
PostModel testPost2 = UploadTestUtils.getTestPost();
testPost2.setIsLocalDraft(true);
- assertEquals(1, PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(testPost1));
- assertEquals(1, PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(testPost2));
+ assertEquals(1, mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(testPost1));
+ assertEquals(1, mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(testPost2));
List postModels = PostTestUtils.getPosts();
assertEquals(2, postModels.size());
diff --git a/example/src/test/java/org/wordpress/android/fluxc/upload/UploadStoreUnitTest.java b/example/src/test/java/org/wordpress/android/fluxc/upload/UploadStoreUnitTest.java
index 4a1bfe55ed..5048ae744d 100644
--- a/example/src/test/java/org/wordpress/android/fluxc/upload/UploadStoreUnitTest.java
+++ b/example/src/test/java/org/wordpress/android/fluxc/upload/UploadStoreUnitTest.java
@@ -41,8 +41,9 @@
public class UploadStoreUnitTest {
private Dispatcher mDispatcher = new Dispatcher();
private UploadStore mUploadStore = new UploadStore(mDispatcher);
+ private PostSqlUtils mPostSqlUtils = new PostSqlUtils();
private PostStore mPostStore = new PostStore(mDispatcher, Mockito.mock(PostRestClient.class),
- Mockito.mock(PostXMLRPCClient.class));
+ Mockito.mock(PostXMLRPCClient.class), mPostSqlUtils);
@Before
public void setUp() {
@@ -78,7 +79,7 @@ public void testPostModelRegistration() {
// Create a PostModel and add it to the PostStore
PostModel postModel = UploadTestUtils.getTestPost();
postModel.setId(55);
- PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postModel);
+ mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postModel);
postModel = mPostStore.getPostByLocalPostId(postModel.getId());
assertNotNull(postModel);
@@ -126,7 +127,7 @@ public void testGetUploadErrorForPost() {
// Create a PostModel and add it to the PostStore
PostModel postModel = UploadTestUtils.getTestPost();
postModel.setId(55);
- PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postModel);
+ mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(postModel);
postModel = mPostStore.getPostByLocalPostId(postModel.getId());
assertNotNull(postModel);
@@ -187,7 +188,7 @@ public void testGetUploadErrorForPost() {
// Create another PostModel and add it to the PostStore - this time, without registering it with the UploadStore
PostModel unregisteredPostModel = UploadTestUtils.getTestPost();
unregisteredPostModel.setId(55);
- PostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(unregisteredPostModel);
+ mPostSqlUtils.insertOrUpdatePostOverwritingLocalChanges(unregisteredPostModel);
// Create a MediaModel attached to the above post
MediaModel mediaLinkedToPost = UploadTestUtils.getLocalTestMedia();
diff --git a/fluxc/build.gradle b/fluxc/build.gradle
index d67985244b..447fc256f4 100644
--- a/fluxc/build.gradle
+++ b/fluxc/build.gradle
@@ -21,7 +21,7 @@ repositories {
android {
useLibrary 'org.apache.http.legacy'
- compileSdkVersion 27
+ compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
@@ -66,10 +66,10 @@ android.buildTypes.all { buildType ->
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
- implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
- implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
+ implementation "androidx.appcompat:appcompat:$appcompat_version"
+ implementation "androidx.recyclerview:recyclerview:1.0.0"
- implementation "com.android.support:exifinterface:$supportLibraryVersion"
+ implementation "androidx.exifinterface:exifinterface:1.0.0"
// WordPress libs
implementation ('org.wordpress:utils:1.20.0') {
@@ -87,13 +87,13 @@ dependencies {
kapt project(':fluxc-processor')
// External libs
- api 'org.greenrobot:eventbus:3.0.0'
+ api 'org.greenrobot:eventbus:3.1.1'
api 'com.squareup.okhttp3:okhttp:3.9.0'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.9.0'
api 'com.android.volley:volley:1.1.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.apache.commons:commons-text:1.1'
- api "android.arch.paging:runtime:$arch_paging_version"
+ api "androidx.paging:paging-runtime:2.1.0"
// Dagger
implementation "com.google.dagger:dagger:$daggerVersion"
diff --git a/fluxc/gradle.properties-example b/fluxc/gradle.properties-example
index 96f330dc0c..720168df99 100644
--- a/fluxc/gradle.properties-example
+++ b/fluxc/gradle.properties-example
@@ -1 +1,3 @@
-fluxc.ENABLE_WPAPI = false
\ No newline at end of file
+fluxc.ENABLE_WPAPI = false
+android.useAndroidX=true
+android.enableJetifier=true
\ No newline at end of file
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/MediaUploadModel.java b/fluxc/src/main/java/org/wordpress/android/fluxc/model/MediaUploadModel.java
index 26d8fa852d..a4b6ef9363 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/MediaUploadModel.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/MediaUploadModel.java
@@ -1,9 +1,10 @@
package org.wordpress.android.fluxc.model;
-import android.support.annotation.IntDef;
-import android.support.annotation.Nullable;
import android.text.TextUtils;
+import androidx.annotation.IntDef;
+import androidx.annotation.Nullable;
+
import com.yarolegovich.wellsql.core.Identifiable;
import com.yarolegovich.wellsql.core.annotation.Column;
import com.yarolegovich.wellsql.core.annotation.PrimaryKey;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostModel.java b/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostModel.java
index f461e016b0..f51f95f0a3 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostModel.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostModel.java
@@ -1,9 +1,10 @@
package org.wordpress.android.fluxc.model;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import com.yarolegovich.wellsql.core.Identifiable;
import com.yarolegovich.wellsql.core.annotation.Column;
import com.yarolegovich.wellsql.core.annotation.PrimaryKey;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostUploadModel.java b/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostUploadModel.java
index 3e21d2fd8c..7538a9d463 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostUploadModel.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostUploadModel.java
@@ -1,10 +1,11 @@
package org.wordpress.android.fluxc.model;
-import android.support.annotation.IntDef;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
import android.text.TextUtils;
+import androidx.annotation.IntDef;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import com.yarolegovich.wellsql.core.Identifiable;
import com.yarolegovich.wellsql.core.annotation.Column;
import com.yarolegovich.wellsql.core.annotation.PrimaryKey;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostsModel.java b/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostsModel.java
index 05f42c4b5a..27a05abd73 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostsModel.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/PostsModel.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.model;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import org.wordpress.android.fluxc.Payload;
import org.wordpress.android.fluxc.network.BaseRequest.BaseNetworkError;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/SiteModel.java b/fluxc/src/main/java/org/wordpress/android/fluxc/model/SiteModel.java
index c80366502a..881e621c99 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/SiteModel.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/SiteModel.java
@@ -1,7 +1,7 @@
package org.wordpress.android.fluxc.model;
-import android.support.annotation.IntDef;
-import android.support.annotation.NonNull;
+import androidx.annotation.IntDef;
+import androidx.annotation.NonNull;
import com.yarolegovich.wellsql.core.Identifiable;
import com.yarolegovich.wellsql.core.annotation.Column;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/SitesModel.java b/fluxc/src/main/java/org/wordpress/android/fluxc/model/SitesModel.java
index f097b86c1b..0c7a5afb31 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/SitesModel.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/SitesModel.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.model;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import org.wordpress.android.fluxc.Payload;
import org.wordpress.android.fluxc.network.BaseRequest.BaseNetworkError;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/SubscriptionModel.java b/fluxc/src/main/java/org/wordpress/android/fluxc/model/SubscriptionModel.java
index 124908e86d..61b086719b 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/SubscriptionModel.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/SubscriptionModel.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.model;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.yarolegovich.wellsql.core.Identifiable;
import com.yarolegovich.wellsql.core.annotation.Column;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/SubscriptionsModel.java b/fluxc/src/main/java/org/wordpress/android/fluxc/model/SubscriptionsModel.java
index dae4fbae7b..be012b1dd0 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/SubscriptionsModel.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/SubscriptionsModel.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.model;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import org.wordpress.android.fluxc.Payload;
import org.wordpress.android.fluxc.network.BaseRequest.BaseNetworkError;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/TermsModel.java b/fluxc/src/main/java/org/wordpress/android/fluxc/model/TermsModel.java
index aef6b469b1..88fdeec939 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/TermsModel.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/TermsModel.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.model;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import org.wordpress.android.fluxc.Payload;
import org.wordpress.android.fluxc.network.BaseRequest.BaseNetworkError;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PagedListFactory.kt b/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PagedListFactory.kt
index d341a4485c..cc4062de80 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PagedListFactory.kt
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PagedListFactory.kt
@@ -1,7 +1,7 @@
package org.wordpress.android.fluxc.model.list
-import android.arch.paging.DataSource
-import android.arch.paging.PositionalDataSource
+import androidx.paging.DataSource
+import androidx.paging.PositionalDataSource
import org.wordpress.android.fluxc.model.list.datasource.InternalPagedListDataSource
/**
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PagedListWrapper.kt b/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PagedListWrapper.kt
index ac4586ef89..85743eb72e 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PagedListWrapper.kt
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PagedListWrapper.kt
@@ -1,12 +1,12 @@
package org.wordpress.android.fluxc.model.list
-import android.arch.lifecycle.Lifecycle
-import android.arch.lifecycle.LifecycleObserver
-import android.arch.lifecycle.LiveData
-import android.arch.lifecycle.MediatorLiveData
-import android.arch.lifecycle.MutableLiveData
-import android.arch.lifecycle.OnLifecycleEvent
-import android.arch.paging.PagedList
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.LifecycleObserver
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MediatorLiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.OnLifecycleEvent
+import androidx.paging.PagedList
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/model/plugin/ImmutablePluginModel.java b/fluxc/src/main/java/org/wordpress/android/fluxc/model/plugin/ImmutablePluginModel.java
index f9ab19a6c3..78493b49c5 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/model/plugin/ImmutablePluginModel.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/model/plugin/ImmutablePluginModel.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.model.plugin;
-import android.support.annotation.Nullable;
+import androidx.annotation.Nullable;
import org.wordpress.android.util.StringUtils;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseRequest.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseRequest.java
index 09d881b8e9..3ad656bd3f 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseRequest.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseRequest.java
@@ -2,9 +2,10 @@
import android.net.Uri;
import android.net.Uri.Builder;
-import android.support.annotation.NonNull;
import android.util.Base64;
+import androidx.annotation.NonNull;
+
import com.android.volley.AuthFailureError;
import com.android.volley.Cache;
import com.android.volley.DefaultRetryPolicy;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseRequestFuture.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseRequestFuture.java
index 6ec9e24fe7..2102c0f4d0 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseRequestFuture.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseRequestFuture.java
@@ -18,7 +18,7 @@
package org.wordpress.android.fluxc.network;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.android.volley.Request;
import com.android.volley.Response.Listener;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseUploadRequestBody.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseUploadRequestBody.java
index 97d14e1bf6..7d70d18965 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseUploadRequestBody.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/BaseUploadRequestBody.java
@@ -1,8 +1,9 @@
package org.wordpress.android.fluxc.network;
-import android.support.annotation.NonNull;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+
import org.wordpress.android.fluxc.model.MediaModel;
import org.wordpress.android.fluxc.utils.MediaUtils;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/HTTPAuthManager.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/HTTPAuthManager.java
index 205a856b6a..7e512ba884 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/HTTPAuthManager.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/HTTPAuthManager.java
@@ -1,7 +1,7 @@
package org.wordpress.android.fluxc.network;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import com.yarolegovich.wellsql.WellSql;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/MemorizingTrustManager.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/MemorizingTrustManager.java
index 3be297a8e0..b4de95534f 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/MemorizingTrustManager.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/MemorizingTrustManager.java
@@ -1,8 +1,9 @@
package org.wordpress.android.fluxc.network;
import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/DiscoveryRequest.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/DiscoveryRequest.java
index 3ae0afd030..e9c717598a 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/DiscoveryRequest.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/DiscoveryRequest.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.network.discovery;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.android.volley.NetworkResponse;
import com.android.volley.Response;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/DiscoveryXMLRPCRequest.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/DiscoveryXMLRPCRequest.java
index 24eb2e90be..4546c397b0 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/DiscoveryXMLRPCRequest.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/DiscoveryXMLRPCRequest.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.network.discovery;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.android.volley.Response.Listener;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/SelfHostedEndpointFinder.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/SelfHostedEndpointFinder.java
index 4eb8f9bff0..71515f532a 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/SelfHostedEndpointFinder.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/SelfHostedEndpointFinder.java
@@ -1,9 +1,10 @@
package org.wordpress.android.fluxc.network.discovery;
-import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.webkit.URLUtil;
+import androidx.annotation.NonNull;
+
import org.wordpress.android.fluxc.BuildConfig;
import org.wordpress.android.fluxc.Dispatcher;
import org.wordpress.android.fluxc.Payload;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/WPAPIHeadRequest.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/WPAPIHeadRequest.java
index 7e2c5ae239..d09abd5798 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/WPAPIHeadRequest.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/WPAPIHeadRequest.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.network.discovery;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.android.volley.NetworkResponse;
import com.android.volley.Response;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/WPAPIGsonRequest.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/WPAPIGsonRequest.java
index fa9485aade..bbbd7e6bde 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/WPAPIGsonRequest.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/WPAPIGsonRequest.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.network.rest.wpapi;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.android.volley.Response.Listener;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/WPComGsonRequest.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/WPComGsonRequest.java
index 7e37c5e2eb..ba116a30b6 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/WPComGsonRequest.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/WPComGsonRequest.java
@@ -1,8 +1,9 @@
package org.wordpress.android.fluxc.network.rest.wpcom;
-import android.support.annotation.NonNull;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+
import com.android.volley.Response.Listener;
import com.android.volley.toolbox.HttpHeaderParser;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/account/AccountRestClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/account/AccountRestClient.java
index 24bbc66256..a3907173ac 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/account/AccountRestClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/account/AccountRestClient.java
@@ -1,10 +1,11 @@
package org.wordpress.android.fluxc.network.rest.wpcom.account;
import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import com.android.volley.RequestQueue;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyError;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/account/AccountSocialRequest.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/account/AccountSocialRequest.java
index abf06066f6..e268fa2683 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/account/AccountSocialRequest.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/account/AccountSocialRequest.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.network.rest.wpcom.account;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/auth/Authenticator.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/auth/Authenticator.java
index 69058151f0..0ab09d3356 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/auth/Authenticator.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/auth/Authenticator.java
@@ -1,9 +1,10 @@
package org.wordpress.android.fluxc.network.rest.wpcom.auth;
import android.content.Context;
-import android.support.annotation.NonNull;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/comment/CommentRestClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/comment/CommentRestClient.java
index b1e672384d..ade16f03ad 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/comment/CommentRestClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/comment/CommentRestClient.java
@@ -1,8 +1,9 @@
package org.wordpress.android.fluxc.network.rest.wpcom.comment;
import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import com.android.volley.RequestQueue;
import com.android.volley.Response.Listener;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/media/MediaRestClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/media/MediaRestClient.java
index 6a3c717283..0f33369671 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/media/MediaRestClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/media/MediaRestClient.java
@@ -1,9 +1,10 @@
package org.wordpress.android.fluxc.network.rest.wpcom.media;
import android.content.Context;
-import android.support.annotation.NonNull;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+
import com.android.volley.RequestQueue;
import com.android.volley.Response.Listener;
import com.google.gson.Gson;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/media/RestUploadRequestBody.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/media/RestUploadRequestBody.java
index e456318f28..4e09f0a3ca 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/media/RestUploadRequestBody.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/media/RestUploadRequestBody.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.network.rest.wpcom.media;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import org.wordpress.android.fluxc.model.MediaModel;
import org.wordpress.android.fluxc.network.BaseUploadRequestBody;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/notifications/NotificationRestClient.kt b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/notifications/NotificationRestClient.kt
index 229ad67167..4db934dab0 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/notifications/NotificationRestClient.kt
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/notifications/NotificationRestClient.kt
@@ -28,6 +28,8 @@ import org.wordpress.android.fluxc.store.NotificationStore.NotificationErrorType
import org.wordpress.android.fluxc.store.NotificationStore.RegisterDeviceResponsePayload
import org.wordpress.android.fluxc.store.NotificationStore.UnregisterDeviceResponsePayload
import org.wordpress.android.fluxc.store.SiteStore
+import org.wordpress.android.util.AppLog
+import org.wordpress.android.util.AppLog.T
import org.wordpress.android.util.DeviceUtils
import org.wordpress.android.util.PackageUtils
import java.util.Date
@@ -72,12 +74,20 @@ class NotificationRestClient constructor(
val url = WPCOMREST.devices.new_.urlV1
val request = WPComGsonRequest.buildPostRequest(
url, params, RegisterDeviceRestResponse::class.java,
- { response ->
- response.id?.takeIf { it.isNotEmpty() }?.let {
- val payload = RegisterDeviceResponsePayload(it)
- dispatcher.dispatch(NotificationActionBuilder.newRegisteredDeviceAction(payload))
+ { response: RegisterDeviceRestResponse? ->
+ response?.let {
+ if (!it.id.isNullOrEmpty()) {
+ val payload = RegisterDeviceResponsePayload(it.id)
+ dispatcher.dispatch(NotificationActionBuilder.newRegisteredDeviceAction(payload))
+ } else {
+ val registrationError =
+ DeviceRegistrationError(DeviceRegistrationErrorType.MISSING_DEVICE_ID)
+ val payload = RegisterDeviceResponsePayload(registrationError)
+ dispatcher.dispatch(NotificationActionBuilder.newRegisteredDeviceAction(payload))
+ }
} ?: run {
- val registrationError = DeviceRegistrationError(DeviceRegistrationErrorType.MISSING_DEVICE_ID)
+ AppLog.e(T.API, "Response for url $url with param $params is null: $response")
+ val registrationError = DeviceRegistrationError(DeviceRegistrationErrorType.INVALID_RESPONSE)
val payload = RegisterDeviceResponsePayload(registrationError)
dispatcher.dispatch(NotificationActionBuilder.newRegisteredDeviceAction(payload))
}
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/plugin/PluginRestClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/plugin/PluginRestClient.java
index 281ed1b5de..6b3d2ba186 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/plugin/PluginRestClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/plugin/PluginRestClient.java
@@ -1,7 +1,8 @@
package org.wordpress.android.fluxc.network.rest.wpcom.plugin;
import android.content.Context;
-import android.support.annotation.NonNull;
+
+import androidx.annotation.NonNull;
import com.android.volley.RequestQueue;
import com.android.volley.Response.Listener;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/post/PostRestClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/post/PostRestClient.java
index c1bb61dda9..d02bed6cee 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/post/PostRestClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/post/PostRestClient.java
@@ -1,10 +1,11 @@
package org.wordpress.android.fluxc.network.rest.wpcom.post;
import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import com.android.volley.RequestQueue;
import com.android.volley.Response.Listener;
import com.google.gson.JsonArray;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/reader/ReaderRestClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/reader/ReaderRestClient.java
index 0fa3281e2a..ec4909b610 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/reader/ReaderRestClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/reader/ReaderRestClient.java
@@ -1,7 +1,8 @@
package org.wordpress.android.fluxc.network.rest.wpcom.reader;
import android.content.Context;
-import android.support.annotation.NonNull;
+
+import androidx.annotation.NonNull;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/site/SiteRestClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/site/SiteRestClient.java
index 43fe1631d2..2f834e75f8 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/site/SiteRestClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/site/SiteRestClient.java
@@ -1,8 +1,9 @@
package org.wordpress.android.fluxc.network.rest.wpcom.site;
import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.RequestQueue;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/stockmedia/StockMediaRestClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/stockmedia/StockMediaRestClient.java
index e99493020b..793f770feb 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/stockmedia/StockMediaRestClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/stockmedia/StockMediaRestClient.java
@@ -1,7 +1,8 @@
package org.wordpress.android.fluxc.network.rest.wpcom.stockmedia;
import android.content.Context;
-import android.support.annotation.NonNull;
+
+import androidx.annotation.NonNull;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/taxonomy/TaxonomyRestClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/taxonomy/TaxonomyRestClient.java
index 5b22afbfc7..5680906249 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/taxonomy/TaxonomyRestClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/taxonomy/TaxonomyRestClient.java
@@ -1,7 +1,8 @@
package org.wordpress.android.fluxc.network.rest.wpcom.taxonomy;
import android.content.Context;
-import android.support.annotation.NonNull;
+
+import androidx.annotation.NonNull;
import com.android.volley.RequestQueue;
import com.android.volley.Response.Listener;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/theme/ThemeRestClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/theme/ThemeRestClient.java
index 05def24a89..3d7d09a762 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/theme/ThemeRestClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/theme/ThemeRestClient.java
@@ -1,9 +1,10 @@
package org.wordpress.android.fluxc.network.rest.wpcom.theme;
import android.content.Context;
-import android.support.annotation.NonNull;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+
import com.android.volley.RequestQueue;
import com.android.volley.Response;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/wporg/WPOrgAPIGsonRequest.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/wporg/WPOrgAPIGsonRequest.java
index f2927388b2..0404ba0643 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/wporg/WPOrgAPIGsonRequest.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/wporg/WPOrgAPIGsonRequest.java
@@ -1,6 +1,6 @@
package org.wordpress.android.fluxc.network.wporg;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.android.volley.Response.Listener;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/wporg/plugin/PluginWPOrgClient.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/wporg/plugin/PluginWPOrgClient.java
index 65a8350038..a279412ec6 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/wporg/plugin/PluginWPOrgClient.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/wporg/plugin/PluginWPOrgClient.java
@@ -1,9 +1,10 @@
package org.wordpress.android.fluxc.network.wporg.plugin;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import com.android.volley.Request.Method;
import com.android.volley.RequestQueue;
import com.android.volley.Response.Listener;
diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/xmlrpc/XMLRPCRequest.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/xmlrpc/XMLRPCRequest.java
index 31019225d1..de3ca005ef 100644
--- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/xmlrpc/XMLRPCRequest.java
+++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/xmlrpc/XMLRPCRequest.java
@@ -1,8 +1,9 @@
package org.wordpress.android.fluxc.network.xmlrpc;
-import android.support.annotation.NonNull;
import android.util.Xml;
+import androidx.annotation.NonNull;
+
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
@@ -29,6 +30,7 @@
import java.nio.charset.Charset;
import java.util.List;
+
// TODO: Would be great to use generics / return POJO or model direclty (see GSON code?)
public class XMLRPCRequest extends BaseRequest