javserlah / qforce

QForce
0 stars 0 forks source link

Api returns invalid id, gender, weight and movies data #2

Open marceloverdijk opened 6 years ago

marceloverdijk commented 6 years ago

http://localhost:8080/api/persons?q=luke returns

[
  {
    "id": 0,
    "name": "Luke Skywalker",
    "gender": "male",
    "height": 172,
    "weight": null,
    "movies": null,
    "birth_year": "19BBY"
  }
]

but the following is expected as described in https://github.com/Q24/qforce/blob/master/README.md:

[
  {
    "id": 1,
    "name": "Luke Skywalker",
    "birth_year": "19BBY",
    "gender": "MALE",
    "height": 172,
    "weight": 77,
    "movies": [
      {
        "title": "The Empire Strikes Back",
        "episode": 5,
        "director": "Irvin Kershner",
        "release_date": "1980-05-17"
      },
      ..
    ]
  }
]

To be precise, the following fields contain invalid data:

Additionally, the unit/integration tests seem not be testing this which makes the tests incomplete.

javserlah commented 6 years ago

Yes, you are right, I found that mappings tricky and I know that the response is not complete. I just tried to implement the parts that I know. Maybe is a matter of knowing more about the jackson library.

marceloverdijk commented 6 years ago

Yes mapping is tricky and on purpose we have different names of fields in our api and the SW api. That is part of the test case to see if this implemented correctly. This is a common ‘problem’ in our daily user stories that we need to solve.

Can you update the code to make it work as expected?

javserlah commented 6 years ago

I can try to make it work but to be honest I would need to study more about it. I do not currently know to do it. I think there is an annotation in Jackson that lets you map the property to a custom implementation in the code. I can try and find a solution based on that if you want me to.

javserlah commented 6 years ago

I also added the "HowToUse.md" file just to try and explain all the decisions that i took regarding the project.