added DevicePopulationServiceTests

This commit is contained in:
Jacob Salvi 2020-05-25 16:47:06 +02:00
parent e7def27d22
commit cffeeca9f8

View file

@ -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);
}
}