...
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getUserCorrectly() | Expect a result that is not null. | username = 'Erik' | Returns something that is not null. | Yes | We manually added some return values of this function, to test if it would work. This test cannot connect to the database, since a unit test may not do this. |
2 | getUserSqlException() | Throws a SQLException that in return throws a DatabaseException. | username = 'Erik' | A DatabaseException is thrown. | Yes |
Race tests
The token usernameErik is defined as "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.ewogICAgIm5hbWUiOiAiRXJpayIKfQ==.2d2c39f777b16f75c701e851e9ec20d45f4134a281155e0c6f909876228d7d80"
...
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getRacesWithGoodJWT() | A 200 response code. | token = usernameErik | Returns a 200 response code, which means that the response is OK. | Yes | |
2 | returnsAllRaces() | Returns a list of DTO's. In this case we only put the following DTO inside the list. RaceDTO{ | token = usernameErik | Returns the expected list of DTO's. It does however, return it in an object type. It does return the same information as provided with the DTO, it still gives out a success. | Yes | The response from the service is set manually. This is done to prevent the test from executing code beyond the resource. If this is not set manually, it would test the DAO, service class and the database, which is not necessary for this class. These tests are done in their own classes seperate from this class. |
3 | getRacesWithBadJWT() | A 403 response code. | token = "WrongToken" | Returns a 403 response code, which means it was a FORBIDDEN request. | Yes |
RaceDAOTest
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getAllRaces() | Expect a result that is not null. | Returns something that is not null. | Yes | ||
2 | getAllRacesSqlException() | Throws a SQLException that in return throws a DatabaseException. | A DatabaseException is thrown. | Yes | ||
3 |
testDataAllRaces() | Returns a list of DTO's. In this case we only put the following DTO inside the list. | Returns the expected list of DTOs. For this check the asserts check if the data inside the DTOs are the same. This includes: the raceid, the name of the race and the date. | Yes | For this test we manually changed the outcome of the resultset to simulate the database sending data to the code. This also happens in the Resultset.next function, to see if the DTO's are called. |