Solution to the code challange as part of the recruiting process for HSBC by Milena Sapunova.
Requires: java 8, maven
Technologies used: java 8, maven, Spring Boot, mockito, checkstyle
Run application: mvn spring-boot:run
Base url: http://localhost:8080
A simple social networking application, similar to Twitter, exposed through a web API.
Supported scenarios:
A user should be able to post a 140 character message.
To add a message to user's wall: POST /user/{username}
{
"message": "Your message here."
}Note:
- If the message is empty or contains more than 140 characters a 400 Bad Request error is returned.
- If no user exists with given
{username}, user is created and the post is added to their wall.
A user should be able to see a list of the messages they've posted, in reverse chronological order.
To see all messages posted by user: GET /user/{username}
The output:
[
{
"postedOn": "26-09-2018 07:09:54",
"author": "alice",
"message": "My second message here"
},
{
"postedOn": "26-09-2018 07:09:50",
"author": "alice",
"message": "My first message here"
}
]A user should be able to follow another user. Following does not have to be reciprocal: Alice can follow Bob without Bob having to follow Alice.
To follow another user: POST /user/{username}/follow
{
"username" : "bob"
}Note:
- If user tries to follow himself a 400 Bad Request error is returned.
A user should be able to see a list of the messages posted by all the people they follow, in reverse chronological order.
To see user's timeline: GET /user/{username}/timeline
[
{
"postedOn": "26-09-2018 03:06:12",
"author": "bob",
"message": "Bob's second message here."
},
{
"postedOn": "26-09-2018 03:05:40",
"author": "bob",
"message": "Bob's first message here."
}
]-
Alice posts few messages:
POST /user/alice{ "message": "Alice's message here." }{ "message": "Alice's second message here." } -
Alice wants to see her wall:
GET /user/alice[ { "postedOn": "26-09-2018 10:42:38", "author": "alice", "message": "Alice's second message here." }, { "postedOn": "26-09-2018 10:42:31", "author": "alice", "message": "Alice's message here." } ] -
Bob posts a message:
POST /user/bob{ "message": "Bob has a message." } -
Megan posts a message:
POST /user/megan{ "message": "Megan's post." } -
Megan follows Alice and Bob:
POST /user/megan/follow{ "username" : "alice" }{ "username" : "bob" } -
Megan wants to see her timeline:
GET /user/megan/timeline[ { "postedOn": "26-09-2018 10:43:33", "author": "bob", "message": "Bob has a message." }, { "postedOn": "26-09-2018 10:42:38", "author": "alice", "message": "Alice's second message here." }, { "postedOn": "26-09-2018 10:42:31", "author": "alice", "message": "Alice's message here." } ]