From c1a199419243466400edc40233183f17b2838c21 Mon Sep 17 00:00:00 2001 From: omenem Date: Mon, 25 May 2020 14:34:33 +0200 Subject: [PATCH] state --- .../smarthut/models/StateTests.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/StateTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/StateTests.java index 4b4224d..fa88ef2 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/StateTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/StateTests.java @@ -1,6 +1,7 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -45,4 +46,44 @@ public class StateTests { this.state.setSceneId(50L); assertEquals(50, this.state.getSceneId()); } + + @Test + @DisplayName("copy to scene id") + public void copyToSceneId() { + this.state.setSceneId(50L); + Scene s = new Scene(); + this.state.setScene(s); + + this.state.setDeviceId(30L); + DimmableLight d = new DimmableLight(); + this.state.setDevice(d); + + State stat = this.state.copyToSceneId(10L); + + assertEquals(10, stat.getSceneId()); + assertEquals(30, stat.getDeviceId()); + + assertEquals(s, stat.getScene()); + assertEquals(d, stat.getDevice()); + } + + @Test + @DisplayName("preremove") + public void preRemove() { + this.state.setSceneId(50L); + Scene s = new Scene(); + this.state.setScene(s); + + this.state.setDeviceId(30L); + DimmableLight d = new DimmableLight(); + this.state.setDevice(d); + + state.removeDeviceAndScene(); + + assertNull(state.getSceneId()); + assertNull(state.getDeviceId()); + + assertNull(state.getScene()); + assertNull(state.getDevice()); + } }