This commit is contained in:
omenem 2020-05-25 14:34:33 +02:00
parent a3b606088c
commit c1a1994192

View File

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