diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/SceneServiceTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/SceneServiceTests.java index b42f263..2925b5a 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/SceneServiceTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/SceneServiceTests.java @@ -1,11 +1,13 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.service; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.when; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.*; +import java.util.List; import java.util.Optional; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -22,6 +24,8 @@ public class SceneServiceTests { @Mock private SceneRepository sceneRepository; + @Mock private StateRepository stateRepository; + @Mock private DevicePropagationService deviceService; @Mock private DevicePopulationService devicePopulationService; @@ -56,4 +60,20 @@ public class SceneServiceTests { assertThat(sceneService.applyAsGuest(s, "user", 42L)).containsExactly(d); assertThat(d.getIntensity()).isEqualTo(40); } + + @Test + public void testCopyStates() { + + final State state = new DimmableState(); + + final Scene sceneFrom = new Scene(); + sceneFrom.getStates().add(state); + final Scene sceneTo = new Scene(); + + when(stateRepository.save(any(State.class))).thenReturn(state); + + List s = sceneService.copyStates(sceneTo, sceneFrom); + + assertEquals(s.get(0), state); + } }