Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Name

Expected result

Parameters

Actual result

SuccessComments
1getUserCorrectly()Expect a result that is not null.

username = 'Erik'

Returns something that is not null.YesWe 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

SuccessComments
1getRacesWithGoodJWT()

A 200 response code.

token = usernameErik

Returns a 200 response code, which means that the response is OK.Yes
2returnsAllRaces()

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"
}

token = usernameErikReturns 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.YesThe 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.
3getRacesWithBadJWT()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

SuccessComments
1getAllRaces()

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
getRacesWithBadJWT()
testDataAllRaces()

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-02-22"
}


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.YesFor 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.
4testDataAllRaces()