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

Update isFormRequest condition #209

Merged
merged 5 commits into from
Feb 26, 2018
Merged

Update isFormRequest condition #209

merged 5 commits into from
Feb 26, 2018

Conversation

whiskeysierra
Copy link
Collaborator

Replaces #208

// package private so we can trick code coverage
}

@SneakyThrows(MimeTypeParseException.class)
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure it is a good idea to fail in case of invalid content type. Should it return Optional<MimeType> instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

}

return false;
return contentType != null && MimeTypes.parse(contentType)
Copy link
Member

Choose a reason for hiding this comment

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

You could do Optional.ofNullable(contentType).map(MimeTypes::parse) as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤦‍♂️ right...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


final class MimeTypesTest {

@Test
void shouldFailToParse() {
assertThrows(MimeTypeParseException.class, () -> MimeTypes.parse(""));
assertEquals(MimeTypes.parse(""), Optional.empty());
Copy link
Member

Choose a reason for hiding this comment

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

No happy case test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The happy case is tested within the interceptor test

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@AlexanderYastrebov
Copy link
Member

👍

I guess multipart/form-data would be considered later on once needed

@AlexanderYastrebov
Copy link
Member

👍

@whiskeysierra whiskeysierra merged commit 5d6da03 into master Feb 26, 2018
@whiskeysierra whiskeysierra deleted the bugfix/form-request branch February 26, 2018 10:31
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.

3 participants