Skip to content

Commit

Permalink
[Regression] Yekkanti - login response is no longer sending user_stat…
Browse files Browse the repository at this point in the history
…us. Its called verified. Updated the client code accordingly as it was failing during synchronization
  • Loading branch information
kishoreyekkanti committed Feb 21, 2013
1 parent c62ebd4 commit ae68933
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit ae68933

Please sign in to comment.