A few months ago a member of our team, Donald, started building a weather app. The requirements for the app are:
GIVEN a city name and a country code
WHEN the temperature is <temp_op> <temp_value> in that city
AND the humidity is <humidity_op> <humidity_value> in that city
THEN display the following message: "The weather in <city_name>, <country_code> is <temp_word> and <humidity_word>!"
GIVEN a city name
WHEN the temperature is <temp_op> <temp_value> in that city
AND the humidity is <humidity_op> <humidity_value> in that city
THEN display the following message: "The weather in <city_name> is <temp_word> and <humidity_word>!"
temp_op | temp_value | temp_word |
---|---|---|
greater than | 29 | hot |
greater than | 17 | warm |
greater than | 5 | chilly |
less than | 6 | cold |
humidity_op | humidity_value | humidity_word |
---|---|---|
greater than | 79 | humid |
less than | 80 | dry |
Before the project was completed, Donald left the company. The code he wrote compiles but has not been tested.
You are now taking on the project. You have 2 tasks (to be worked on during your interview):
- Review the code to familiarise yourself with what it does and make any improvements you think are necessary.
- Implement an additional feature to get the difference in weather between two cities (see below).
Weather data is obtained from the API defined here: https://openweathermap.org/current#data. An API key is required for this and will be provided to you.
GIVEN a city name C1 and a city name C2
WHEN the temperature is <temp_op> <temp_value> in C1
AND the humidity is <humidity_op> <humidity_value> in C1
AND the temperature in C2 differs by X degrees compared to the temperature in C1
THEN display the following message: "The weather in C1 is <temp_word> and <humidity_word>! It is X degrees [warmer|colder] in C2"
To run the app:
gradlew bootRun
To invoke the app's functionality:
curl http://localhost:8080/weather?city=Copenhagen&country=dk
Or simply hit the endpoint in a browser.
https://brandwatch.atlassian.net/wiki/spaces/NGA/pages/2756313093/Backend+Coding+Exercise.