-
Notifications
You must be signed in to change notification settings - Fork 300
Add toJSON and fromJSON to Remote Config Template #500
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
Conversation
9fd1355 to
239401d
Compare
239401d to
071940e
Compare
cbcb9b9 to
da32399
Compare
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.
Haven't gone through everything. But I've added some high-level feedback around how the serialization logic can be improved.
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.
Thanks for making the changes. Looks mostly good. Few comments on cleaning up the PR a bit.
src/main/java/com/google/firebase/remoteconfig/internal/TemplateResponse.java
Show resolved
Hide resolved
src/main/java/com/google/firebase/remoteconfig/RemoteConfigUtil.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/remoteconfig/RemoteConfigUtil.java
Outdated
Show resolved
Hide resolved
src/test/java/com/google/firebase/remoteconfig/TemplateTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/google/firebase/remoteconfig/TemplateTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/google/firebase/remoteconfig/TemplateTest.java
Outdated
Show resolved
Hide resolved
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.
Just a few minor nits.
| .setVersion(expectedVersion); | ||
| Template template = Template.fromJSON(originalTemplate.toJSON()); | ||
|
|
||
| assertEquals("etag-0010201", template.getETag()); |
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.
Why not run assertEquals on the template instances?
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.
Condition arrays are not quite the same for a direct equality check. The original template contains a condition that does not have a tag color. After the serialization -> deserialization process that tag color will be set to TagColor.UNSPECIFIED.
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.
Should we fix that so the behavior remains consistent?
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.
I think we should. Updated the code not to serialize the tag color as TagColor.UNSPECIFIED when null or empty.
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.
LGTM with a suggestion.
| if (indexOfPeriod != -1) { | ||
| dateString = dateString.substring(0, indexOfPeriod); | ||
| } | ||
| checkArgument(!Strings.isNullOrEmpty(dateString), "Date string must not be null or empty"); |
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.
This should happen before everything else.
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.
Ah good catch! Thanks!
Thanks for the review!! Made the suggested updates. |
toJSON()andfromJSON()toTemplateRelated to: #446