...
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 | |
4 | deleteGraphsTest() | A DatabaseException will be thrown after a SQLException. | tabID = 1 | A SQLException is thrown. | Yes | |
5 | addGraph() | The method is verified by mockito verify. | tabID = 1 graphID = 1 graphType = "Linechart" | The method is verified, which means that the method gets called and does not cause an exception. | Yes | |
6 | deleteGraph() | The method is verified by mockito verify. | tabID = 1 graphID = 1 | The method is verified, which means that the method gets called and does not cause an exception. | Yes |
Table 3: Tests in GraphDAOTest
Tab tests
TabServiceTest class
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getAllTabsTest() | GraphsDTO{ name = "test" tabID = 1 id = 1 } | ||||
2 | deleteTabTest() | Throws a DatabaseException. | tabID = 1 | A DatabaseException is thrown. | Yes | The return value cannot be tested, since this method returns a void. That is why the Exception is checked, instead of a return value. The method is also checked with the mockito.verify function. |
3 | createTabTest() | Throws a DatabaseException. | user = "testUser" tabName = "testTab" raceID = 1 | A DatabaseException is thrown. | Yes | The return value cannot be tested, since this method returns a void. That is why the Exception is checked, instead of a return value. The method is also checked with the mockito.verify function. |
Table 4: Tests in TabServiceTest
...
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 | |
3 | deleteTabTest() | A DatabaseException will be thrown after a SQLException. | tabID = 1 | A DatabaseException is thrown. | Yes | |
4 | createTabTest() | The method is verified by mockito verify. | username = "Erik" tabName = "testTab" raceID = 1 | The method is verified, which means that the method gets called and does not cause an exception. | Yes | |
5 | createTabTestSqlException | A DatabaseException will be thrown after a SQLException. | username = "Erik" tabName = "testTab" raceID = 1 | A DatabaseException is thrown. | Yes |
Table 6: Tests in TabDAOTest
...
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{ | Returns the expected RaceDTO. | Yes |
...
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getAllSensors() | Returns a list of DTO's. In this case we only put the following DTO inside the list. SensorWithGraphDTO{ | Returns the expected list of DTO's with the correct DTO inside the list. | Yes |
Table 13: Test in SensorServiceTest
SensorWithGraphResourceTest
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getGraphDataWithGoodJWT() | A 200 response code. | token = usernameErik | Returns a 200 response code, which means that the response is OK. | Yes | |
2 | returnsAllSensors() | Returns a list of DTO's. In this case we only put the following SensorWithGraphDTO's inside the list. sensorDTO{ sensorDTO2{ | 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 | getGraphDataWithBadJWT() | A 403 response code. | token = "WrongToken" | Returns a 403 response code, which means it was a FORBIDDEN request. | Yes |
Table 14: Tests in SensorWithGraphResourceTest
SensorWithGraphDAOTest
Name | Expected result | Parameters | Actual result | Success | Comments | |
---|---|---|---|---|---|---|
1 | getSensorLinkedWithGraphsCorrectly() | Expect a result that is not null. | Returns something that is not null. | Yes | ||
2 | getUserTabsSQLException() | Throws a SQLException that in return throws a DatabaseException. | A DatabaseException is thrown. | Yes |
Table 15: Tests in SensorWithGraphDAOTest
DtoTest
This class tests if the DTO's do not contain any logic and only getters and setters. The testPojoStructureAndBehavior() function executes this test. Pojo is a dependency that can be used for this kind of testing.
Conclusion
The application contains 52 unit tests that cover about 87.2% of the application. All tests are succesful and only test the classes and methods that they are meant to test. With these statistics we can call this application reliable, secured, maintained and mostly covered.