Conversation
bbaca89 to
2296d2d
Compare
vboaghe
reviewed
Jun 27, 2019
| @@ -0,0 +1,34 @@ | |||
| public class ApiStructure { | |||
vboaghe
reviewed
Jun 27, 2019
| @@ -0,0 +1,34 @@ | |||
| public class ApiStructure { | |||
| public String login = "rusakov6699"; | |||
| public long id = 16705398; | |||
Collaborator
There was a problem hiding this comment.
all fields -> private (use getters)
vboaghe
reviewed
Jun 27, 2019
| public String login = "rusakov6699"; | ||
| public long id = 16705398; | ||
| public String node_id = "MDQ6VXNlcjE2NzA1Mzk4"; | ||
| public String avatar_url = "https://avatars1.githubusercontent.com/u/16705398?v=4"; |
Collaborator
There was a problem hiding this comment.
no need to assign a value to this fields
vboaghe
reviewed
Jun 27, 2019
| import static org.hamcrest.core.IsNull.notNullValue; | ||
| import static org.junit.jupiter.api.Assertions.assertAll; | ||
|
|
||
| public class ApiTestWithJackson { |
Collaborator
There was a problem hiding this comment.
rename (e.g GetUserJacksonTest)
vboaghe
reviewed
Jun 27, 2019
| @Test | ||
| public void getRequestFromGithubTest() throws IOException { | ||
| ObjectMapper mapper = new ObjectMapper(); | ||
| String stringURL = "https://api.github.com/users/rusakov66"; |
vboaghe
reviewed
Jun 27, 2019
| String stringURL = "https://api.github.com/users/rusakov66"; | ||
| Response response = get(stringURL); | ||
| JSONObject jsonResponse = new JSONObject(response.asString()); | ||
| System.out.println(jsonResponse); |
Collaborator
There was a problem hiding this comment.
we repeated 100 times about system.out
Owner
Author
There was a problem hiding this comment.
Sorry for SOP's - there were my debugging points ....
vboaghe
reviewed
Jun 27, 2019
| System.out.println(jsonResponse); | ||
| ObjectMapper objectMapper = new ObjectMapper(); | ||
| String jsonResponseAsString = jsonResponse.toString(); | ||
| System.out.println(jsonResponseAsString); |
Collaborator
There was a problem hiding this comment.
we repeated 100 times about system.out
vboaghe
reviewed
Jun 27, 2019
| String jsonResponseAsString = jsonResponse.toString(); | ||
| System.out.println(jsonResponseAsString); | ||
| ApiStructure jsonResponseAsObject = objectMapper.readValue(jsonResponseAsString, ApiStructure.class); | ||
| String statusLine = response.getStatusLine(); |
Collaborator
There was a problem hiding this comment.
not statusLine, but StatusCode
vboaghe
reviewed
Jun 27, 2019
| System.out.println(jsonResponseAsString); | ||
| ApiStructure jsonResponseAsObject = objectMapper.readValue(jsonResponseAsString, ApiStructure.class); | ||
| String statusLine = response.getStatusLine(); | ||
| System.out.println("statusLine" + statusLine); |
Collaborator
There was a problem hiding this comment.
we repeated 100 times about system.out
vboaghe
reviewed
Jun 27, 2019
| String statusLine = response.getStatusLine(); | ||
| System.out.println("statusLine" + statusLine); | ||
| assertAll( | ||
| () -> assertThat(jsonResponseAsObject.login, is("rusakov667")), |
Collaborator
There was a problem hiding this comment.
jsonResponseAsObject - it is not json.
rename
vboaghe
reviewed
Jun 27, 2019
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| <version>2.9.8</version> |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
First code with Jackson. Nogami ne beite