Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development -> main merge #17

Merged
merged 6 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gombahaz/Gombahaz/Repositories/DataSetRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public DataSetRepository(DataContext _dataContext)
DataSetItem? retrievedDataSet = await dataContext.DataSets
.Include(ds => ds.Resource)
.Where(ds => ds.Id == dataSetId)
.SingleAsync();
.SingleOrDefaultAsync();
if (retrievedDataSet == null)
return null;

Expand Down
5 changes: 1 addition & 4 deletions Gombahaz/Gombahaz/Services/DataSetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ public DataSetService(IDataSetRepository _datasetRepository, IResourceRepository
this.datasetRepository = _datasetRepository;
this.resourceRepository = resourceRepository;
}
public async Task<DataSetItem> getDataSetById(int id)
public async Task<DataSetItem?> getDataSetById(int id)
{
DataSetItem? retrievedDataSet = await datasetRepository.getDataSetById(id);

if (retrievedDataSet == null)
throw new Exception($"Element with id={id} is not found!");

return retrievedDataSet;
}
Expand Down
2 changes: 1 addition & 1 deletion Gombahaz/Gombahaz/Services/IDataSetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Gombahaz.Services
public interface IDataSetService
{
public Task<DataSetItem> insertDataSet(DataSetItem datasetToInsert, int resourceId);
public Task<DataSetItem> getDataSetById(int id);
public Task<DataSetItem?> getDataSetById(int id);

public Task<IEnumerable<DataSetItem>> getDataSetsByResourceId(int resourceId);

Expand Down
49 changes: 49 additions & 0 deletions doc/API_testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
### API végpontok létrehozása

A feladatom első részeként Postman segítségével létrehoztam egy Collectiont, és abba két mappát - Resource és DataSet. Ezek a mappák aszerint csoportosítják a végpontokat, hogy melyik táblából kérnek le adatokat a backenden.

Az egyes mappákban pedig létrehoztam a végpontokat, ezek az alábbi képen láthatók:

![image](https://github.com/BME-MIT-IET/iet-hf-2024-lg_iet_lab/assets/166651149/35ed5972-20f0-4301-9ca3-5b601b6c2c12)

_Megjegyzés_: Több végpont lett létrehozva annak érdekében, hogy olyan tesztek is lefuthassanak, amelyek a hibás kérés esetén visszadott válaszokra vonatkoznak.

Létrehoztam több Collection Variable változót is, mivel az összes kérés ugyanazt az URL-t használja, valamint hogy az egész Collection-re lehessen teszteket futtatni, ugyanis egyes kérések átállították a változókat.

![alt text](src/img1.png)

### Tesztek megírása

Miután elkészültem a végpontok létrehozásával, utána az egyes API végpontokhoz tartozó teszteket megírtam.

A tesztek megírásában segítséget nyújtott a Postman dokumentáció, valamint a Postbot beépített AI copilot is.

A tesztek futtatása után hibákat fedeztem fel a backendben, ennek javításai láthatók GitHub-on issue-k formájában.

Jelenlegi állapotban, ha az alábbi sorrendben futtatjuk le a teszteket a Collection-ön (csak a Resource és DataSet mappába tartozó kéréseket), akkor a tesztek mindegyike sikerrel fog lezárulni.

![alt text](src/img6.png)

**Fontos:** A DELETE kérésnek mindig a Collection run legvégén kell lefutnia.

A tesztek eredménye, pedig az alábbi képeken látható:

![alt text](src/img2.png)

![alt text](src/img3.png)

![alt text](src/img4.png)

![alt text](src/img5.png)

Ha a teszteket külön szeretnénk lefuttatni, akkor oda kell figyelni a Collection változókra, ugyanis egyes kérések megváltoztatják azokat, és ha erre nem figyelünk, akkor a tesztek hibával térhetnek vissza. (Például a DELETE többszöri meghívása anélkül, hogy POST-ot hívtunk volna)

### API leírása

Az API-hoz található a VisualStudio projekt által automatikusan készített Swagger leírás.

![alt text](src/img7.png)

### Tanulság

Amit megtanultam ebben a házi feladatban az az, hogy a tesztelést komolyan kell venni, és el kell végezni, mert egy olyan projektben is előjöhetnek hibák, amiről a fejlesztő alapesetben úgy gondolta, hogy nagyrészt hibamentes. Továbbá rávilágított arra is a házi feladat, hogy a GitHub-ot hogyan kellene rendesen használni verziókezelésre.
Binary file added doc/src/img1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/src/img2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/src/img3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/src/img4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/src/img5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/src/img6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/src/img7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading