-
Notifications
You must be signed in to change notification settings - Fork 0
3.1.5 SUBMOD.001.005 : Delete AML File
- Changelog
- 1. Scope
- 2. Definitions
- 3. Module Requirements
- 4. Analysis
- 5. Design
- 6. Implementation
- 7. Module Test
- 8. Summary
- 9. Appendix
Version | Date | Author | Comment |
---|---|---|---|
0.1 | 17.01.2021 | Namid Marxen und Nils-Christopher Wiesenauer | created |
1.0 | 14.05.2021 | Namid Marxen und Nils-Christopher Wiesenauer | finished |
The Module Documentations (MODs) describes the architecture, the interfaces and the main features of the module. It also describes the module/component test including the results. It can also serve as a programming or integration manual for the module. If there are some risks related to the module itself, they shall be noted and commented within this document.
AML: Automation Markup Language
CRUD: Create Read Update Delete
GUI: Graphical User Interface
JSend: A specification that lays down some rules for how JSON responses from web servers should be formatted
SAS: System Architecture Specification
SRS: System Requirements Specification
This submodule contains the endpoint for deleting stored AML files.
This REST API is the most important module because it contains the logic for converting the AML file to JSON. It also includes the authorization to the database. When a file is uploaded to the server it is converted from an AML format to a JSON format so that it can be saved in the MongoDB database. The content of the files are saved as a string and then converted into one JSON object, so that each file has their own database entry, with the JSON object as the content.
The user has the ability to delete files stored in the database. He can click a button in the list of files to delete a file.
The submodule contains the requirement LF80
which describes that the user can delete files. With this feature the user can click on a button to delete a file which sends a DELETE request to the REST API. The REST API then sends a delete request to the MongoDB database.
The submodule to delete AML files gives the user the ability to delete saved files. The user sends a DELETE request from the GUI and the REST API sends a request to the database to delete a specific file.
This feature is important, because the user has to have the ability to delete files.
We included all /file
routes into our server.js
where the FILE
schema is imported to have every endpoint together and clear.
When the user cannot delete AML files anymore, the files cannot be removed from the database.
Link to sourcecode: server.js
The needed /file/:id
DELETE endpoint is defined below. Here we are using the created FILE model to delete a file document by _id from MongoDB by using FILE.deleteFile(_id, callback)
.
const FILE = require('./models/file');
...
app.delete('/file/:id', (req, res) => {
FILE.deleteFile(req.params.id, (err, file) => {
>> 6.2 Response
});
});
...
After saying we want to delete a document with the provided _id we have different callback. If an error ocurred, we are sending a JSend with status 'error' and a defined message back. If everything was correct and the file was deleted, and we are sending a JSend with status 'success' back.
...
if (!err && file) {
res.status(200).send({ status: 'success', data: file });
} else {
res.status(200).send({ status: 'error', message: 'Unable to delete file' });
}
...
The endpoint/submodule to delete an AML file is neccessary to provide the user with the ability to delete a specific file. It is triggered by a request from the GUI when clicked on the delete button of a specific file. The request is processed by the REST API and another request is sent to the database.
The implementation of the module is descriped with SwaggerUI.
The source code of this module can be found here: aml-database-management-api
Testcase ID: | TC.REST.003.F |
---|---|
Testcase Name: | DELETE call |
Requirement ID(s): |
LF110 , LF100 , LF30
|
Description: | The test case verifies that the REST API DELETE call works as documented in the SRS |
Test Steps:
Step | Action | Expected Result |
---|---|---|
1 | Use the GUI to upload two files | Two files are uploaded and visible in the table in the home page |
2 | Open Postman and send the following GET request: localhost:3000/file. Remember the _id attribute of one of the files | One of the _id attributes is remembered. |
3 | Send the following DELETE request: localhost:3000/file/{mongoDBID}, where {mongoDBID} is the _id attribute of the first file that has been received in step 2. | You receive "status": "success" as well as the a response in the format below, along with HTTP-Code 200. |
2 | Send the following GET request: localhost:3000/file | Verify only the not deleted file is not returned anymore, along with HTTP-Code 200. |
{
"status": "success",
"data": {
"n": 1,
"ok": 1,
"deletedCount": 1
}
}
© LMF.software - Jonas Bihr, Namid Marxen, Johannes Emanuel Timter & Nils-Christopher Wiesenauer
For any question regarding our software contact us on here on GitHub.
- Home
- 1. SRS (System Requirements Specification)
- 2. SAS (System Architecuture Specification)
- 3. MODs (Modul Documentations)
- 4. MM (Meeting Minutes)
- 5. User Manual
- 6. Systemtestplan
- 7. Systemtestreport