From fe911d492ff1cfde6b18f3992b2333530ccefbad Mon Sep 17 00:00:00 2001 From: omenem Date: Tue, 17 Mar 2020 15:10:49 +0100 Subject: [PATCH] small changes --- .../ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmer.java | 7 ++++++- .../inf/sa4/sanmarinoes/smarthut/ButtonDimmerTests.java | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmer.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmer.java index af00025..10f0c5a 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmer.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmer.java @@ -1,5 +1,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models; +import java.util.HashSet; import java.util.Set; import javax.persistence.Entity; import javax.persistence.Inheritance; @@ -15,7 +16,7 @@ public abstract class Dimmer extends InputDevice { } @OneToMany(mappedBy = "dimmer") - private Set lights; + private Set lights = new HashSet<>(); /** * Get the lights connected to this dimmer @@ -26,4 +27,8 @@ public abstract class Dimmer extends InputDevice { public Set getOutputs() { return this.lights; } + + public void addDimmableLight(DimmableLight dimmableLight) { + lights.add(dimmableLight); + } } diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/ButtonDimmerTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/ButtonDimmerTests.java index 85f4e49..22b3e0c 100644 --- a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/ButtonDimmerTests.java +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/ButtonDimmerTests.java @@ -20,8 +20,8 @@ public class ButtonDimmerTests { } @Nested - @DisplayName(" when lights are present") - class lightsPresent { + @DisplayName(" when multiple lights are present") + class MultipleLights { @BeforeEach public void setLights() {