added DevicePopulationServiceTests
This commit is contained in:
parent
e7def27d22
commit
cffeeca9f8
1 changed files with 42 additions and 0 deletions
|
@ -0,0 +1,42 @@
|
|||
package ch.usi.inf.sa4.sanmarinoes.smarthut.service;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.security.test.context.support.WithMockUser;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@WithMockUser(username = "user")
|
||||
@DisplayName("DevicePopulationService test")
|
||||
public class DevicePopulationServiceTests {
|
||||
@InjectMocks private DevicePopulationService service;
|
||||
|
||||
@Mock private ThermostatPopulationService populationService;
|
||||
|
||||
private void helper(Thermostat t) {
|
||||
t.setMeasuredTemperature(new BigDecimal(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPopulateComputedFields() {
|
||||
Curtains curtains = new Curtains();
|
||||
RegularLight light = new RegularLight();
|
||||
Thermostat t1 = new Thermostat();
|
||||
RegularLight light2 = new RegularLight();
|
||||
ArrayList<Device> list = new ArrayList<>();
|
||||
list.add(curtains);
|
||||
list.add(light);
|
||||
list.add(t1);
|
||||
list.add(light2);
|
||||
doNothing().when(populationService).populateMeasuredTemperature(t1);
|
||||
service.populateComputedFields(list);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue