Versions Compared

Key

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

TODO: short introduction (order of tests, realized in test suite, every table stands for one test class, extends Abstract...)The below tests are parts of a test suite. Every table shows the test of one test class, so each row is exactly one test (method) inside a test class. The order of the tests reflects the execution order. The tests of a test class don't depend on results of previous executed tests. But a test which updates an object will also fail if saving of the object fails, because the test must save the object before it can update it. To prevent this the strict execution order is used. Before the test methods are executed the CMR is started and if necessary objects are stored into the database. At the end of a test class the initially stored objects are deleted if necessary.

All test classes extends the Spring test class AbstractTransactionalTestNGSpringContextTests. This class rollbacks all actions at the end of a test method which were performed inside the test method.

EnvironmentData DAO Tests

Test Case No. (Test method)

Method to test

Scenario

Outcome of successful test

1 (addEnvironment())

addEnvironment(...)

  • storage of an environment into the
db
  • database
  • returned id > 0

2 (getEnvironments())

getEnvironments(...)

  • storage of an environment into the database
  • receive the environment and compare the values
  • returned list is not empty (size = 1)
  • values of the retrieved EnvironmentData object must be equal to the values of the stored EnvironmentData object

3 (updateEnvironment())

updateEnvironment(...)

  • storage of an environment into the database
  • change the environment and perform update
  • receive the environment
stored in test case 1 will be updated
  • and compare the values
  • no DataAccessException thrown
if values are really updated will be tested in test case 3

3 (getEnvironments())

getEnvironments
  • values of the retrieved EnvironmentData object must be equal to the values of the updated version of the EnvironmentData object
  • values of the retrieved EnvironmentData object must be unequal to the values of the initial version of the EnvironmentData object

4 (deleteEnvironment())

deleteEnvironment(...)

  • storage of an environment into the database
  • deletion of the environment
  • second deletion of the environment to ensure that the environment is really deleted
  • no EntityNotFoundException is thrown during first deletion
  • EntityNotFoundException is thrown during second deletion

ProfileData DAO Tests

Test Case No. (Test method)

Method to test

Scenario

Outcome of successful test

1 (addProfile())

addProfile(...)

retrieving of two environments from the db;
therefore add a second environment

returned list is not empty (size = 2)
values of retrieved environments must be equal to values of the initial environments

4 (deleteExistingEnvironment())

deleteEnvironments(...)

deletion of the first added environment

no EntityNotFoundException is thrown
if environment is really deleted will be tested in test case 5

5 (deleteNonExistingEnvironment())

deleteEnvironments(...)

again deletion of the first added environment

EntityNotFoundException is thrown

ProfileData DAO Tests

Test Case No.
  • storage of a profile into the database
  • returned id > 0

2 (getProfile())

getProfile(...)

  • storage of a profile into the database
  • receive the profile and compare the values
  • returned ProfileData is not null
  • values of the retrieved ProfileData object must be equal to the values of the stored ProfileData object

3 (updateProfile())

updateProfile(...)

  • storage of a profile into the database
  • change the profile and perform update
  • receive the profile and compare the values
  • no DataAccessException thrown
  • values of the retrieved ProfileData object must be equal to the values of the updated version of the ProfileData object
  • values of the retrieved ProfileData object must be unequal to the values of the initial version of the ProfileData object

4 (deleteProfile())

deleteProfile(...)

  • storage of a profile into the database
  • deletion of the profile
  • second deletion of the profile to ensure that the profile is really deleted
  • no EntityNotFoundException is thrown during first deletion
  • EntityNotFoundException is thrown during second deletion

5 (getNoneExistingProfile())

getProfile(...)

  • receive a profile which is not inside the database
  • returned ProfileData object is null

6 (cascadeDeleteOfProfile())

 

  • storage of a profile into the database
  • deletion of the environment
  • receive the profile
  • returned ProfileData object is null

SensorTypeData Dao Tests

Test Case No. (Test method)

Method to test

Scenario

Outcome of successful test test 

1 (addProfileaddSensorType())

addProfile addSensorType(...) add a profile to a previous stored

  • storage of a sensor type into the database
  • returned id > 0

2 (updateProfilegetSensorType())

updateProfile getSensorType(...)

  • storage of a sensor type into the database
  • receive the sensor type and compare the values
  • returned SensorTypeData object is not null

the profile stored in test case 1 will be updated

no DataAccessException thrown
if values are really updated will be tested in test case 3

3 (getProfile())

getProfile(...)

retrieving of the profile stored in test case 1

values of retrieved profile must be equal to values of the initial profile

4 (deleteExistingProfile())

deleteProfile(...)

deletion of the profile stored in test case 1

no EntityNotFoundException is thrown
if environment is really deleted will be tested in test case 5

5 (deleteNonExistingProfile())

deleteProfile(...)

again deletion of the profile stored in test case 1

EntityNotFoundException is thrown

6 (getNoneExistingProfile())

getProfile(...)

retrieving the already deleted profile (done in test case 4)

returned ProfileData object is null

7 (cascadeDeleteOfProfile())

 

an environment which has one profile defined is deleted. Then the profile will be retrieved.

returned ProfileData object is null

...

  • values of the retrieved SensorTypeData object must be equal to the values of the stored SensorTypeData object

3 (updateSensorType())

updateSensorType(...)

  • storage of a sensor type into the database
  • change the sensor type and perform update
  • receive the sensor type and compare the values
  • no DataAccessException thrown
  • values of the retrieved SensorTypeData object must be equal to the values of the updated version of the SensorTypeData object
  • values of the retrieved SensorTypeData object must be unequal to the values of the initial version of the SensorTypeData object

4 (casdadeDeleteOfSensorType())

 

  • storage of a sensor type into the database
  • deletion of the environment
  • deletion of the sensor type
  • EntityNotFoundException is thrown during deletion of the SensorTypeData object

ExceptionSensorDefinitionData Dao Test

Test Case No. (Test method)

Method to test

Scenario

Outcome of successful test

1 (addExceptionSensorDefinition())

addExceptionSensorDefinition(...)

  • storage of an exception sensor definition into the database
  • returned id > 0

2 (getExceptionSensorDefinition())

getExceptionSensorDefinition(...)

  • storage of an exception sensor definition into the database
  • receive the exception sensor and compare the values
  • returned ExceptionSensorDefinitionData object is not null
  • values of the retrieved ExceptionSensorDefinitionData object must be equal to the values of the stored ExceptionSensorDefinitionData object

3  (updateExceptionSensorDefinition())

updateExceptionSensorDefinition(...)

  • storage of an exception sensor definition into the database
  • change the exception sensor definition and perform update
  • receive the exception sensor and compare the values
  • no DataAccessException thrown
  • values of the retrieved ExceptionSensorDefinitionData object must be equal to the values of the updated version of the ExceptionSensorDefinitionData object
  • values of the retrieved ExceptionSensorDefinitionData object must be unequal to the values of the initial version of the ExceptionSensorDefinitionData object

4 (deleteExistingExceptionSensorDefinition())

deleteExceptionSensorDefinition(...)

  • storage of an exception sensor definition into the database
  • deletion of the exception sensor definition
  • second deletion of the exception sensor definition to ensure that the exception sensor definition is really deleted
  • no EntityNotFoundException is thrown during first deletion
  • EntityNotFoundException is thrown during second deletion

5 (cascadeDeleteIfProfileIsDeleted())

 

  • storage of an exception sensor definition type into the database
  • deletion of the profile
  • deletion of the exception sensor definition
  • EntityNotFoundException is thrown during deletion of the ExceptionSensorDefinitionData object

6 (cascadeDeleteIfEnvironmentIsDeleted())

 

  • storage of an exception sensor definition into the database
  • deletion of the environment
  • deletion of the exception sensor definition
  • EntityNotFoundException is thrown during deletion of the ExceptionSensorDefinitionData object

MethodSensorDefinitionData Dao Test

Test Case No. (Test method)

Method to test

Scenario

Outcome of successful test

1 (addMethodSensorDefinition())

addMethodSensorDefinition(...)

  • storage of a method sensor definition into the database
  • returned id > 0

2 (getMethodSensorDefinition())

getMethodSensorDefinition(...)

  • storage of a method sensor definition into the database
  • receive the method sensor and compare the values
  • returned MethodSensorDefinitionData object is not null
  • values of the retrieved MethodSensorDefinitionData object must be equal to the values of the stored MethodSensorDefinitionData object

3  (updateMethodSensorDefinition())

updateMethodSensorDefinition(...)

  • storage of a method sensor definition into the database
  • change the method sensor definition and perform update
  • receive the method sensor and compare the values
  • no DataAccessException thrown
  • values of the retrieved MethodSensorDefinitionData object must be equal to the values of the updated version of the MethodSensorDefinitionData object
  • values of the retrieved MethodSensorDefinitionData object must be unequal to the values of the initial version of the MethodSensorDefinitionData object

4 (deleteExistingMethodSensorDefinition())

deleteMethodSensorDefinition(...)

  • storage of a method sensor definition into the database
  • deletion of the method sensor definition
  • second deletion of the method  sensor definition to ensure that the method sensor definition is really deleted
  • no EntityNotFoundException is thrown during first deletion
  • EntityNotFoundException is thrown during second deletion

5 (getSensorType())

 

  • storage of a sensor type into the database
  • retrieve the sensor type from the database
  • storage of a method sensor definition with the previous retrieved sensor type assigned
  • retrieve the method sensor definition from the database
  • values of the last retrieved SensorTypeData object must be equal to the values of the initially created SensorTypeData object

6 (cascadeDeleteIfProfileIsDeleted())

 

  • storage of a method sensor definition into the database
  • deletion of the profile
  • deletion of the method sensor definition
  • EntityNotFoundException is thrown during deletion of the MethodSensorDefinitionData object

7 (cascadeDeleteIfEnvironmentIsDeleted())

 

  • storage of a method sensor definition into the database
  • deletion of the environment
  • deletion of the method sensor definition
  • EntityNotFoundException is thrown during deletion of the MethodSensorDefinitionData object

PlatformSensorDefinitionData Dao Test

Test Case No. (Test method)

Method to test

Scenario

Outcome of successful test

1 (addPlatformSensorDefinition())

addPlatformSensorDefinition(...)

  • storage of a platform sensor definition into the database
  • returned id > 0

2 (getPlatformSensorDefinition())

getPlatformSensorDefinition(...)

  • storage of a platform sensor definition into the database
  • receive the platform sensor and compare the values
  • returned PlatformSensorDefinitionData object is not null
  • values of the retrievedPlatformSensorDefinitionData  object must be equal to the values of the stored PlatformSensorDefinitionData object

3  (updatePlatformSensorDefinition())

updatePlatformSensorDefinition(...)

  • storage of a platform sensor definition into the database
  • change the platform sensor definition and perform update
  • receive the platform sensor and compare the values
  • no DataAccessException thrown
  • values of the retrieved PlatformSensorDefinitionData object must be equal to the values of the updated version of the PlatformSensorDefinitionData object
  • values of the retrievedPlatformSensorDefinitionData  object must be unequal to the values of the initial version of the PlatformSensorDefinitionData object

4 (deleteExistingPlatformSensorDefinition())

deletePlatformSensorDefinition(...)

  • storage of a platform sensor definition into the database
  • deletion of the platform sensor definition
  • second deletion of the platform sensor definition to ensure that the platform sensor definition is really deleted
  • no EntityNotFoundException is thrown during first deletion
  • EntityNotFoundException is thrown during second deletion

5 (cascadeDeleteIfProfileIsDeleted())

 

  • storage of a platform sensor definition type into the database
  • deletion of the profile
  • deletion of the platform sensor definition
  • EntityNotFoundException is thrown during deletion of the PlatformSensorDefinitionData object

6 (cascadeDeleteIfEnvironmentIsDeleted())

 

  • storage of a platform sensor definition into the database
  • deletion of the environment
  • deletion of the platform sensor definition
  • EntityNotFoundException is thrown during deletion of the PlatformSensorDefinitionData object

Lazy Initialization Tests

Before the below tests are performed an environment and a profile are added into the database. Afterwards the environment is retrieved with the profile. The sensor definitions of that profile should not be received with this service call. The second service call receives the profile with its defined sensor definitions. Following names are used to distinguish between the three different objects used in the tests:

  • retrievedEnvironment : This is the environment retrieved as result of calling environmentDataDao.getEnvironments()
  • profileWithOutSensorDefinitions: This is the profile retrieved with the retrievedEnvironment (should not have sensor definitions)
  • profileWithSensorDefinitions: This is the profile retrieved as result of calling profileDataDao.getProfile(long profileId) (should have sensor definitions)

Test Case No.

Name of Test Method

Scenario

Outcome of successful test

1

getSensortype()

  • check if retrievedEnvironment has sensor types
are also retrieved with an environment
  • No LazyInitializationException is thrown
  • Set of sensor types is empty

2

getProfile()

  • check if
profiles are also retrieved with an environment
  • retrievedEnvironment has profiles
  • No LazyInitializationException is thrown
  • Set of profiles is 1

3

getExceptionSensorDefinitionsFromEnvironmentProfile()

  • check if profileWithOutSensorDefinitions has exception sensor definitions
are also retrieved with an environment
  • LazyInitializationException is thrown

4

getMethodSensorDefinitionsFromEnvironmentProfile()

  • check if profileWithOutSensorDefinitions has method sensor definitions
are also retrieved with an environment
  • LazyInitializationException is thrown

5

getPlatformSensorDefinitionsFromEnvironmentProfile()

  • check if profileWithOutSensorDefinitions has platform sensor definitions
are also retrieved with an environment
  • LazyInitializationException is thrown

6

getExceptionSensorDefinitionsFromProfile()

  • check if profileWithSensorDefinitions has exception sensor definitions
are also retrieved with a profile
  • no LazyInitializationException is thrown

7

getMethodSensorDefinitionsFromProfile()

  • check if profileWithSensorDefinitions has method sensor definitions
are also retrieved with a profile
  • no LazyInitializationException is thrown

8

getPlatformSensorDefinitionsFromProfile()

  • check if profileWithSensorDefinitions has platform sensor definitions
are also retrieved with a profile
  • no LazyInitializationException is thrown