Welcome to the Vodafone Learn Backend Documentation. This guide provides an in-depth understanding of the backend components that power the Vodafone Learn learning hub application. Here, you will find details about the APIs, endpoints, high-level scenarios, testing procedures, and troubleshooting guidance specific to the backend architecture.
- OpenAPI for clear and comprehensive API documentation
- Spring Boot for rapid application development and management
- H2 Database for efficient testing and development
- JUnit 5 for robust unit and integration testing
Description: Uploads a new post to the platform.
Description: Updates an existing post using the postId.
Scenario: A user uploads a new post to the platform.
Steps:
- User navigates to the "Upload" section.
- User provides post details such as title, description, and tags.
- User submits the post.
- Backend receives the post data.
- Backend validates the input data, including mandatory fields.
- Backend creates a new post record in the database.
- Backend generates a unique post ID.
- Backend responds to the user with a success message and the post ID.
Outcome: The user's post is successfully uploaded to the platform.
Scenario: A user updates an existing post.
Steps:
- User navigates to the "Edit" section.
- User selects the post they want to update.
- User modifies the post content, including title, description, and tags.
- User submits the changes.
- Backend receives the update request along with the modified data.
- Backend fetches the post from the database using the post ID.
- Backend updates the post data with the new content.
- Backend confirms the update and sends a success response to the user.
Outcome: The user's post is successfully updated with the new content.
Scenario: A user reads the details of a specific post.
Steps:
- User selects a post to read.
- User navigates to the "Read" section.
- User requests the details of the selected post.
- Backend receives the read request along with the postId.
- Backend fetches the post details from the database using the postId.
- Backend responds with the post details.
Outcome: The user successfully reads the details of the selected post.
Scenario: A user deletes an existing post.
Steps:
- User selects a post to delete.
- User confirms the deletion.
- Backend receives the delete request along with the postId.
- Backend fetches the post from the database using the postId.
- Backend marks the post as deleted.
- Backend responds to the user with a success message.
Outcome: The user's selected post is successfully deleted from the platform.
Scenario: Successfully create a new post.
Given: A post request with title and description.
When: The createPost method is called with the post request.
Then:
- The post response title matches the input title.
- The post response description matches the input description.
- The post ID is not null.
- Calling
createPostagain does not throw any exceptions.
Scenario: Successfully create a new post with multiple tags.
Given: A post request with title, description, and multiple tags.
When: The createPost method is called with the post request.
Then:
- The post response title matches the input title.
- The post response description matches the input description.
- The post ID is not null.
- Calling
createPostagain does not throw any exceptions.
Scenario: Successfully create a new post with a missing description.
Given: A post request with title but no description.
When: The createPost method is called with the post request.
Then:
- The post response title matches the input title.
- The post response description matches the input description.
- The post ID is not null.
- Calling
createPostagain does not throw any exceptions.
Scenario: Fails to create a post due to missing title.
Given: A post request with description but no title.
When: The createPost method is called with the post request.
Then: An IllegalArgumentException is thrown with the expected error message.
Scenario: Fails to create a post due to missing tags.
Given: A post request with title, description, but no tags.
When: The createPost method is called with the post request.
Then: An IllegalArgumentException is thrown with the expected error message.
Scenario: Fails to create a post due to null tag.
Given: A post request with title, description, and a null tag.
When: The createPost method is called with the post request.
Then: An IllegalArgumentException is thrown with the expected error message.
Scenario: Fails to create a post due to null title.
Given: A post request with description and a null title.
When: The createPost method is called with the post request.
Then: An IllegalArgumentException is thrown with the expected error message.
Scenario: Fails to create a post due to service being unavailable.
Given: A post request with title and description.
When: The createPost method is called with the post request.
Then: A ServiceUnavailableException is thrown.
Scenario: Successfully delete an existing post.
Given: An existing post.
When: The deletePost method is called with the post ID.
Then:
- The post is marked as deleted in the database.
- Calling
deletePostagain for the same post ID throws aNotFoundException.
Scenario: Attempt to delete a nonexistent post.
Given: A nonexistent post ID.
When: The deletePost method is called with the nonexistent post ID.
Then: A NotFoundException is thrown.
Scenario: Attempt to delete an already deleted post.
Given: An already deleted post.
When: The deletePost method is called with the deleted post ID.
Then: A NotFoundException is thrown.
Request:
{
"title": "Spring boot",
"description": "important in backend team",
"tag": [
{
"tagName": "Backend"
}
],
"attachment": [
{
"attachment": "https://example.com/attachment.pdf"
}
]
}Responses:
- Status 201 Created
{
"postId": "unique_post_id",
"title": "Springboot",
"description": "important in backend team",
"tag": [
{
"tagName": "Backend"
}
],
"attachment": [
{
"attachment": "https://example.com/attachment.pdf"
}
]
}- Status 400 Bad Request
{
"message": "Invalid"
}Request:
{
"title": "Updated Spring boot",
"description": "updated description",
"tag": [
{
"tagName": "Backend"
},
{
"tagName": "Update"
}
],
"attachment": [
{
"attachment": "https://example.com/updated_attachment.pdf"
}
]
}Responses:
- Status 202 Accepted
{
"postId": "unique_post_id",
"title": "Updated Spring boot",
"description": "updated description",
"tag": [
{
"tagName": "Backend"
},
{
"tagName": "Update"
}
],
"attachment": [
{
"attachment": "https://example.com/updated_attachment.pdf"
}
]
}- Status 404 Not Found
{
"message": "Not Found"
}Responses
- Status 202 Accepted
{
"message": "Deleted Successfully"
}- Status 404 Not Found
{
"message": "Not Found"
}Request
{
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}Responses
- Status 200 Successful Response
{
"posts": [
{
"postId": 0,
"title": "Springboot",
"description": "important in backend team",
"tag": [
{
"tagName": "string"
}
],
"attachment": [
{
"attachment": "string"
}
]
}
]
}- Status 404 Not Found
{
"message": "Post Not Found"
}