Skip to content

Instantly share code, notes, and snippets.

@MarkRBM
Last active March 28, 2019 20:09
Show Gist options
  • Save MarkRBM/8cab448eb24816a7a31875603dad7f04 to your computer and use it in GitHub Desktop.
Save MarkRBM/8cab448eb24816a7a31875603dad7f04 to your computer and use it in GitHub Desktop.
Test Project

We have two customers McDonalds and BurgerKing who both use our Reservation and Service Request modules. They have the requirement that they have their own html endpoints that they want to be hit when reservations or service requests are created, updated or deleted.

Given a Json file that represents these customers preferences in the following format

[
{
"appCode": "Mcdonalds", "webhookSettings" : [
{"entity": "RESERVATIONS", "event": CREATED, "endpoint":  "http://httpbin.org/mcdonalds/res/created"},
{"entity": "RESERVATIONS", "event": DELETED, "endpoint":  "http://httpbin.org/mcdonalds/res/deleted"},
{"entity": "SERVICEREQUEST", "event": DELETED, "endpoint":  "http://httpbin.org/mcdonalds/sr/deleted"}
]
},
{
"appCode": "BurgerKing", "webhookSettings" : [
{"entity": "RESERVATIONS", "event": "CREATED", "endpoint":  "http://httpbin.org/mcdonalds/res/created"},
{"entity": "RESERVATIONS", "event": "UPDATED", "endpoint":  "http://httpbin.org/mcdonalds/res/updated"},
{"entity": "RESERVATIONS", "event": "DELETED", "endpoint":  "http://httpbin.org/mcdonalds/res/deleted"},
{"entity": "SERVICEREQUEST", "event": "CREATED", "endpoint":  "http://httpbin.org/bk/sr/create"},
{"entity": "SERVICEREQUEST", "event": "UPDATED", "endpoint":  "http://httpbin.org/bk/sr/updated"},
{"entity": "SERVICEREQUEST", "event": "DELETED", "endpoint":  "http://httpbin.org/bk/sr/deleted"}
]
}
]

and an event stream represented by an Json file in the following format

[
{"appCode": String,  "entity": Either[Reservation, ServiceRequest], "event": String}
]

a reservation object will be in the form

{"id": Long, "userId: Long, "start": DateTimeStamp, "end": DateTimeStamp}

a service request object will be in the form

{"id": Long, "roomId": Long, "operatorId": Long}
  • Implement a Scala program that can take a stream of 20,000 of these events (in the form of a json file) and hit the correct customers endpoints for each event.
  • The program should read both the preferences file and the stream file from a set location and I should be able to run the completed program with sbt, the Scala repl or with Ammonite.
  • The program should perform 20,000 real http requests to the endpoints provided in the preferences file.
  • the body of each response should be the data from the event object
  • Please use logging extensively, just using println is fine for this project.
  • Please createa git repo and provide us with the link and commit regularly so we can follow your progress.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment