The following submodule helps control an air conditioning system:
Submodule coolingControl
Imports: inSensor (Sensor), inAirCon (AirCon), inDisplay (Display)
Exports: nothing
Algorithm:
temperature = inSensor. getTemperature
IF temperature < 20 THEN
inAirCon. turnOff
ELSE IF temperature > 25 THEN
inAirCon. turnOn
END-IF
inDisplay.showTemperature <-- temperature
This submodule imports objects from three other classes:
* Sensor reports various information from the environment. Its method getTemperature returns the current room temperature as an integer.
* AirCon provides simple on/off controls for the air conditioner hardware. Its turnOff and turnOn methods do what they say. They take no imports and provide no exports.
There are no error conditions. If the air conditioner is already off when turnOff is called, or if turnOn is called when the air conditioner is on, nothing happens.
* Display controls a simple LED output device (unrelated to the console), which shows the current temperature (among other things). Its showTemperature method updates the temperature shown using an imported integer value.
The coolingControl submodule itself exists inside the Control class.
(a) Using a white-box approach, design a complete set of test cases for the coolingControl submodule.
(i) Identify all the different conditions that must be tested.
(ii) Identify the objects that should be mocked.
(iii) Identify the submodules called by coolingControl that should be stubbed.
(iv) Identify the submodules called by coolingControl that should be verified.
(b) Select one of your test cases from above, and implement it in Java. State which test case you are implementing.
You must provide all the required code ( for that one test case), except that you may omit any Java import statements. You may use JUnit if you wish.