diff --git a/RapidFTR-Android/src/main/java/com/rapidftr/task/MigrateUnverifiedDataToVerified.java b/RapidFTR-Android/src/main/java/com/rapidftr/task/MigrateUnverifiedDataToVerified.java index 86af9c00..e878a0e3 100644 --- a/RapidFTR-Android/src/main/java/com/rapidftr/task/MigrateUnverifiedDataToVerified.java +++ b/RapidFTR-Android/src/main/java/com/rapidftr/task/MigrateUnverifiedDataToVerified.java @@ -57,7 +57,7 @@ private void migrateChildren(ChildRepository unverifiedChildRepo, ChildRepositor private void setNewCurrentUser(JSONObject userFromResponse, User currentUser) throws JSONException { currentUser.setDbKey(userFromResponse.getString("db_key")); - currentUser.setVerified(userFromResponse.getBoolean("user_status")); + currentUser.setVerified(userFromResponse.optBoolean("verified")); currentUser.setOrganisation(userFromResponse.getString("organisation")); currentUser.setLanguage(userFromResponse.getString("language")); RapidFtrApplication.getApplicationInstance().setCurrentUser(currentUser); @@ -67,7 +67,7 @@ protected User getUserFromResponse() { User user = new User(unVerifiedUser.getUserName()); try { user.setDbKey(responseFromServer.getString("db_key")); - user.setVerified(responseFromServer.getBoolean("user_status")); + user.setVerified(responseFromServer.optBoolean("verified")); } catch (JSONException e) { Log.e("Migrate Data", e.getMessage()); throw new RuntimeException(); diff --git a/RapidFTR-Android/src/main/java/com/rapidftr/task/SyncUnverifiedDataAsyncTask.java b/RapidFTR-Android/src/main/java/com/rapidftr/task/SyncUnverifiedDataAsyncTask.java index ee563b50..54d702c5 100644 --- a/RapidFTR-Android/src/main/java/com/rapidftr/task/SyncUnverifiedDataAsyncTask.java +++ b/RapidFTR-Android/src/main/java/com/rapidftr/task/SyncUnverifiedDataAsyncTask.java @@ -52,7 +52,7 @@ protected void sync() throws JSONException, IOException { sendChildrenToServer(childRepository.currentUsersUnsyncedRecords()); setProgressAndNotify(context.getString(R.string.sync_complete), maxProgress); RapidFtrApplication application = RapidFtrApplication.getApplicationInstance(); - if(response != null && response.getBoolean("user_status") && !application.getCurrentUser().isVerified()){ + if(response != null && response.optBoolean("verified") && !application.getCurrentUser().isVerified()){ startMigrationTask(response, application); } diff --git a/RapidFTR-Android/src/test/java/com/rapidftr/task/LoginAsyncTaskTest.java b/RapidFTR-Android/src/test/java/com/rapidftr/task/LoginAsyncTaskTest.java index 672202d8..300ea22a 100644 --- a/RapidFTR-Android/src/test/java/com/rapidftr/task/LoginAsyncTaskTest.java +++ b/RapidFTR-Android/src/test/java/com/rapidftr/task/LoginAsyncTaskTest.java @@ -137,12 +137,12 @@ public void shouldNotDownloadFormSectionsForUnverifiedUser() throws IOException @Test public void shouldCallMigrateUnverifiedDataTaskIfLoggedInUserIsVerifiedAndHisStausInSharedPrefIsUnVerified() throws IOException, GeneralSecurityException, JSONException { User userFromSharedPreference = mock(User.class); - HttpResponse loginResponse = new TestHttpResponse(201, "{\"user_status\":true, \"db_key\":\"hey_from_server\", \"organisation\":\"tw\",\"language\":\"en\"}"); + HttpResponse loginResponse = new TestHttpResponse(201, "{\"verified\":true, \"db_key\":\"hey_from_server\", \"organisation\":\"tw\",\"language\":\"en\"}"); doReturn(userFromSharedPreference).when(loginAsyncTask).getUserFromPreference(); doReturn(loginResponse).when(loginAsyncTask).getLoginResponse(); doNothing().when(loginAsyncTask).migrateUnverifiedData(anyString(), eq(userFromSharedPreference)); loginAsyncTask.doOnlineLogin(); - verify(loginAsyncTask).migrateUnverifiedData("{\"user_status\":true, \"db_key\":\"hey_from_server\", \"organisation\":\"tw\",\"language\":\"en\"}", userFromSharedPreference); + verify(loginAsyncTask).migrateUnverifiedData("{\"verified\":true, \"db_key\":\"hey_from_server\", \"organisation\":\"tw\",\"language\":\"en\"}", userFromSharedPreference); } } diff --git a/RapidFTR-Android/src/test/java/com/rapidftr/task/MigrateUnverifiedDataToVerifiedTest.java b/RapidFTR-Android/src/test/java/com/rapidftr/task/MigrateUnverifiedDataToVerifiedTest.java index 33eaf5ce..022aa1e6 100644 --- a/RapidFTR-Android/src/test/java/com/rapidftr/task/MigrateUnverifiedDataToVerifiedTest.java +++ b/RapidFTR-Android/src/test/java/com/rapidftr/task/MigrateUnverifiedDataToVerifiedTest.java @@ -49,7 +49,7 @@ public void shouldMoveChildRecordsFromUnVerifiedDBToVerified() throws JSONExcept JSONObject mockJSONObject = mock(JSONObject.class); doReturn(verifiedUser.getDbKey()).when(mockJSONObject).getString("db_key"); - doReturn(verifiedUser.isVerified()).when(mockJSONObject).getBoolean("user_status"); + doReturn(verifiedUser.isVerified()).when(mockJSONObject).optBoolean("verified"); MigrateUnverifiedDataToVerified task = new MigrateUnverifiedDataToVerified(mockJSONObject, unverifiedUser); task = spy(task); @@ -69,7 +69,7 @@ public void shouldMoveChildRecordsFromUnVerifiedDBToVerified() throws JSONExcept public void shouldSetTheResponseDataToCurrentUser() throws JSONException { JSONObject mockJSONObject = mock(JSONObject.class); doReturn("DB_KEY_FROM_SERVER").when(mockJSONObject).getString("db_key"); - doReturn(true).when(mockJSONObject).getBoolean("user_status"); + doReturn(true).when(mockJSONObject).optBoolean("verified"); MigrateUnverifiedDataToVerified task = new MigrateUnverifiedDataToVerified(mockJSONObject, unverifiedUser); task = spy(task);