...
Table 2: Tests in GraphDAOTest
GraphDAOTest class
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getGraphs() | All graphs with tabID are shown. | tabID = 1 | All graphs with the given tabID, are returned to the user. | Yes | |
2 | getUserTabsSqlException() | A DatabaseException will be thrown after a SQLException. | tabID = 1 | A SQLException is thrown. | Yes | |
3 | addGraphsTestSqlException() | A DatabaseException will be thrown after a SQLException. | tabID = 1 graphID = 1 graphType = "Linechart" | A SQLException is thrown. | Yes |
Table 3: Tests in GraphDAOTest
...
Table 5: Tests in TabResourceTest
TabDAOTest class
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getUserTabsCorrectly() | Expect a result that is not null. | username = 'Erik' | Returns something that is not null. | Yes | |
2 | getUserTabsSqlException() | A DatabaseException will be thrown after a SQLException. | username = 'Erik' | A DatabaseException is thrown. | Yes |
Table 6: Tests in TabDAOTest
...
Login tests
LoginServiceTest
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | checkCorrectUsernameResponse() | Gives the same username back as the user has given to the system. | LoginRequestDTO{ username = 'Erik' } | The class returns 'Erik', and thus gives the same username back. | Yes | |
2 | checkCorrectTokenResponse() | Gives a new token dedicated to a specific name. | LoginRequestDTO{ username = 'Erik' } | The class returns the same token as expected for the user given. | Yes | |
3 | checkThrownExceptionWrongPassword() | Throws a LoginCredentialsIncorrectException after wrong input of the password. | LoginRequestDTO{ username = 'Erik' } | A LoginCredentialsIncorrectException is thrown. | Yes | The DAO response is set to 0, to simulate the database returning nothing. |
4 | checkThrownExceptionWrongUser() | Throws a LoginCredentialsIncorrectException after wrong input of the name. | LoginRequestDTO{ username = 'WrongUser' } | A LoginCredentialsIncorrectException is thrown. | Yes | The DAO response is set to 0, to simulate the database returning nothing. |
5 | checkThrownExceptionNoUserAndPassword() | Throws a LoginCredentialsIncorrectException after no input. | LoginRequestDTO{ username = '' } | A LoginCredentialsIncorrectException is thrown. | Yes | The DAO response is set to 0, to simulate the database returning nothing. |
6 | testCreationToken() | Creates a token based on the name that it has received. | username = 'Erik' | Creates the token from username 'Erik'. | Yes |
Table 7: Tests in LoginServiceTest
LoginResourceTest
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getUserHTMLcodeWithCorrectInformation() | Returns a 200 status code back to the user. | LoginRequestDTO{ username = 'Erik' } | Returns a 200 response code, which means that the response is OK. | Yes | |
2 | getUserHTMLcodeWithIncorrectInformation() | Returns a 403 status code back to the user. | Returns a 403 response code, which means it was a FORBIDDEN request. | Yes (see comments) | This method does work, but doesn't test if it works with a wrong input given. This is because the thrown exception gets mapped by the mapper with the Provider annotation. This test strictly tests if the mapper does return the 403 code given by the user. | |
3 | checkExceptionThrown() | Throws a LoginCredentialsIncorrectException after wrong input of the password in resource. | LoginRequestDTO{ username = 'Erik' } | A LoginCredentialsIncorrectException is thrown. | Yes |
Table 8: Tests in LoginResourceTest
UserDAOTest
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 | |
2 | getUserSqlException() | Throws a SQLException that in return throws a DatabaseException. | username = 'Erik' | A DatabaseException is thrown. | Yes |
Table 9: Tests in UserDAOTest
Race tests
RaceServiceTest
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getAllRaces() | Returns a list of DTO's. In this case we only put the following DTO inside the list. RaceDTO{ raceID = 1 raceName = "BMW Race" date = "2022-05-22" } | Returns the expected RaceDTO. | Yes | The response from the DAO is set manually, because a connection to the real database is not safe in tests. The response is the same RaceDTO, to see if the getter works en returns the list from RaceDAO. |
Table 10: Tests in RaceServiceTest
RaceResourceTest
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 |
Table 11: Tests in RaceResourceTest
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 |
Table 12: Tests in RaceDAOTest
...