Skip to content

Conversation

lahirumaramba
Copy link
Member

@lahirumaramba lahirumaramba commented Dec 7, 2020

  • Add toJSON() and fromJSON() to Template
  • Add unit tests

Related to: #446

Copy link
Contributor

@hiranya911 hiranya911 left a 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.

Copy link
Contributor

@hiranya911 hiranya911 left a 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.

Copy link
Contributor

@hiranya911 hiranya911 left a 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());
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@hiranya911 hiranya911 left a 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");
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch! Thanks!

@lahirumaramba
Copy link
Member Author

LGTM with a suggestion.

Thanks for the review!! Made the suggested updates.

@lahirumaramba lahirumaramba merged commit 09043e6 into remote-config Dec 10, 2020
@lahirumaramba lahirumaramba deleted the lm-rc-from-json branch December 10, 2020 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants