Skip to content
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

#784 - Introduce UBER+JSON mediatype. #785

Closed
wants to merge 7 commits into from
Closed

Conversation

gregturn
Copy link
Contributor

@gregturn gregturn commented Jan 9, 2019

Formatting.
Extracted conversion methods.
Tested and fixed NPE with empty pojo.
Tested and fixed NPE with empty pojo.
Tested and fixed NPE with empty pojo.
Tested and fixed NPE with empty page meta data.
Copy link
Contributor

@schauder schauder left a comment

Choose a reason for hiding this comment

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

I have couple of complains:

  1. the copyright headers need updating.

  2. empty data elements can trigger various NPEs. I added tests and fixes in extra commits, but aren't sure at all if the behavior is intended. But I think the JSON is legit according to the spec so we at least shouldn't fail with an NPE. See also my comment below about an alternative handling of the null values.

  3. There isn't any handling of error values which is part of the UBER+JSON spec. I wonder if we should add something for that too.

.orElse(null);
}

public void setTemplated(boolean __) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I tried removing this and the tests still worked, so this is either superfluous or we are missing a test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test case and applied similar patch as 8bf01c3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed copyright headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #786 to track a comprehensive approach to error handling and hypermedia.

* @param object
* @return
*/
static UberDocument toUberDocument(final Object object) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a leftover and it hasn't any usage. Can we remove it?

*/
public List<UberData> getData() {

if (this.data == null || this.data.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the reason for a couple of null-checks we need in the deserializer. I wonder if we can achieve the same by some Jackson annotation (https://stackoverflow.com/a/29928205/66686)

The same is true for other properties that return null in special cases.

I removed the logic and no test failed, so I think we at least need some additional tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have commented out both the getData() and the getRel() methods, and verified that everything works. This was after adding another test case and verifying it hits this. Conclusion: we must be covering the "null" situation properly elsewhere, making this rendundant.

@gregturn gregturn closed this Jan 15, 2019
@gregturn gregturn deleted the feature/uber4 branch January 15, 2019 18:13
@gregturn gregturn added this to the 1.0 M1 milestone Jan 15, 2019
@gregturn
Copy link
Contributor Author

Resolved via 8da3a85, b7a1c06, and e9074c5.

@gregturn
Copy link
Contributor Author

Thanks @schauder and @dschulten for the time and effort it has taken to land this feature on the master branch.

@gregturn
Copy link
Contributor Author

And of course @odrotbohm. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants