-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: MLIBZ-2447 Extending user class with properties of different class cause an exception #167
Merged
yuliya-guseva
merged 6 commits into
indev
from
feature/MLIBZ-2447_Extending_User_class_with_properties_of_different_class_cause_an_exception
Jun 1, 2018
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
104d456
Merge branch 'indev' into feature/MLIBZ-2447_Extending_User_class_wit…
yuliya-guseva 7a669e3
feat: Add test for reproducing the issue
yuliya-guseva 4bbdfaa
feat: Update instrumented test
yuliya-guseva 26344d6
feat: Fix exception if custom user class has field of different class
yuliya-guseva 9ea130d
feat: Fix exception if custom user class has field of different class
yuliya-guseva 503d962
feat: Update user model class default value
yuliya-guseva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
android-lib/src/androidTest/java/com/kinvey/androidTest/model/InternalUserEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.kinvey.androidTest.model; | ||
|
||
import com.google.api.client.json.GenericJson; | ||
import com.google.api.client.util.Key; | ||
|
||
public class InternalUserEntity extends GenericJson { | ||
|
||
@Key | ||
private String street; | ||
|
||
public String getStreet() { | ||
return street; | ||
} | ||
|
||
public void setStreet(String street) { | ||
this.street = street; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,7 +431,7 @@ public Context getContext(){ | |
* <p/> | ||
* This Builder class is not thread-safe. | ||
*/ | ||
public static class Builder extends AbstractClient.Builder { | ||
public static class Builder<T extends User> extends AbstractClient.Builder { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this be a breaking change to the client builder? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, It won't be breaking change. |
||
|
||
private Context context = null; | ||
private KinveyUserCallback<User> retrieveUserCallback = null; | ||
|
@@ -447,7 +447,7 @@ public static class Builder extends AbstractClient.Builder { | |
private String MICVersion; | ||
private String MICBaseURL; | ||
private boolean deltaSetCache = false; | ||
private Class userClass = User.class; | ||
private Class userClass = null; | ||
private byte[] encryptionKey; | ||
|
||
/** | ||
|
@@ -764,7 +764,7 @@ public Builder(Context context) { | |
this(context, newCompatibleTransport()); | ||
} | ||
|
||
public Builder setUserClass(Class userClass){ | ||
public Builder setUserClass(Class<T> userClass){ | ||
this.userClass = userClass; | ||
return this; | ||
} | ||
|
@@ -795,18 +795,18 @@ public Builder setInstanceID(String instanceID) { | |
* which contains factory methods for accessing various functionality. | ||
*/ | ||
@Override | ||
public Client build(){ | ||
public Client<T> build(){ | ||
kinveyHandlerThread = new KinveyHandlerThread("KinveyHandlerThread"); | ||
kinveyHandlerThread.start(); | ||
Realm.init(context); | ||
final Client client = new Client(getTransport(), | ||
final Client<T> client = new Client<>(getTransport(), | ||
getHttpRequestInitializer(), getBaseUrl(), | ||
getServicePath(), this.getObjectParser(), getKinveyClientRequestInitializer(), getCredentialStore(), | ||
getRequestBackoffPolicy(), this.encryptionKey, this.context); | ||
|
||
client.clientUser = AndroidUserStore.getUserStore(this.context); | ||
|
||
client.setUserClass(userClass); | ||
client.setUserClass(userClass != null ? userClass : User.class); | ||
|
||
//GCM explicitly enabled | ||
if (this.GCM_Enabled){ | ||
|
@@ -858,7 +858,7 @@ public Client build(){ | |
* | ||
* </p> | ||
* | ||
* @param buildCallback Instance of {@link: KinveyClientBuilderCallback} | ||
* @param buildCallback Instance of {@link KinveyClientBuilderCallback} | ||
*/ | ||
public void build(KinveyClientBuilderCallback buildCallback) { | ||
new Build(buildCallback).execute(); | ||
|
@@ -868,7 +868,7 @@ public void build(KinveyClientBuilderCallback buildCallback) { | |
/** | ||
* Define how credentials will be stored | ||
* | ||
* @param store something implpemting CredentialStore interface | ||
* @param store something implementing CredentialStore interface | ||
* @return this builder, with the new credential store set | ||
*/ | ||
public Builder setCredentialStore(CredentialStore store) { | ||
|
@@ -894,7 +894,7 @@ public Builder setJsonFactory(JsonFactory factory){ | |
* Sets a callback to be called after a client is intialized and BaseUser attributes is being retrieved. | ||
* | ||
* <p> | ||
* When a client is intialized after an initial login, the user's credentials are cached locally and used for the | ||
* When a client is initialized after an initial login, the user's credentials are cached locally and used for the | ||
* initialization of the client. As part of the initialization process, a background thread is spawned to retrieve | ||
* up-to-date user attributes. This optional callback is called when the retrieval process is complete and passes | ||
* an instance of the logged in user. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a test case where the
User
class is extended?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we have. Previous custom user tests were updated:
https://github.com/Kinvey/java-library/pull/167/files#diff-24be4dde17572f9389b3bbab418535abR378
and
https://github.com/Kinvey/java-library/pull/167/files#diff-24be4dde17572f9389b3bbab418535abR1131