diff --git a/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAO.java b/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAO.java index 13bd25c..5c27899 100644 --- a/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAO.java +++ b/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAO.java @@ -1,14 +1,17 @@ package de.ctdo.bunti.dao; import java.util.Collection; +import java.util.List; import de.ctdo.bunti.model.*; public interface BuntiDevicesDAO { - Collection getAllDevices(); - Collection getAllDMXDevices(); + List getAllDevices(); + List getAllDMXDevices(); BuntiDevice getDeviceById(int deviceId); + void addDevice(BuntiDevice device); + void removeDevice(int deviceId); } diff --git a/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAOImpl.java b/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAOImpl.java index dc25b01..0510847 100644 --- a/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAOImpl.java +++ b/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAOImpl.java @@ -1,63 +1,36 @@ package de.ctdo.bunti.dao; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import de.ctdo.bunti.model.*; -import org.springframework.stereotype.Repository; - -@Repository -public final class BuntiDevicesDAOImpl implements BuntiDevicesDAO { - private static final Logger LOGGER = LoggerFactory.getLogger(BuntiDevicesDAOImpl.class); - private List devices = new ArrayList(); - - public BuntiDevicesDAOImpl() { -// addDummyDevices(); - } +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; -// private void addDummyDevices() { -// int deviceID = 0; -// -// devices.add(new Par56Spot(deviceID++, 1, "Par56 Lampe 1")); -// devices.add(new Par56Spot(deviceID++, 6, "Par56 Lampe 2")); -// devices.add(new Par56Spot(deviceID++, 11, "Par56 Lampe 3")); -// devices.add(new Par56Spot(deviceID++, 16, "Par56 Lampe 4")); -// devices.add(new Strobe1500(deviceID++, 21, "Stroboskop 1")); -// devices.add(new Par56Spot(deviceID, 508, "Par56 Lampe 5")); -// LOGGER.debug("added dummy devices in DAO"); -// } - +public final class BuntiDevicesDAOImpl extends HibernateDaoSupport implements BuntiDevicesDAO { @Override - public Collection getAllDMXDevices() { - List list = new ArrayList(); - for (BuntiDevice device : devices) { - if( device instanceof BuntiDMXDevice ) { - list.add((BuntiDMXDevice) device); - } - } - return list; + public List getAllDMXDevices() { + return getHibernateTemplate().loadAll(BuntiDMXDevice.class); } @Override - public Collection getAllDevices() { - return Collections.unmodifiableCollection(devices); + public List getAllDevices() { + return getHibernateTemplate().loadAll(BuntiDevice.class); } @Override public BuntiDevice getDeviceById(int deviceId) { - for (BuntiDevice dev : devices) { - if(dev.getId() == deviceId) { - return dev; - } - } - return null; + return getHibernateTemplate().get(BuntiDevice.class,deviceId); } + @Override + public void addDevice(BuntiDevice device) { + getHibernateTemplate().save(device); + } + + @Override + public void removeDevice(int deviceId) { + getHibernateTemplate().delete(getDeviceById(deviceId)); + } + } diff --git a/src/main/java/de/ctdo/bunti/dao/RoomsDAO.java b/src/main/java/de/ctdo/bunti/dao/RoomsDAO.java index f25fbb2..ecb686d 100644 --- a/src/main/java/de/ctdo/bunti/dao/RoomsDAO.java +++ b/src/main/java/de/ctdo/bunti/dao/RoomsDAO.java @@ -4,16 +4,9 @@ import de.ctdo.bunti.model.Room; import java.util.List; -/** - * @author: lucas - * @date: 15.03.12 21:55 - */ public interface RoomsDAO { - List getRooms(); Room getRoom(int id); Room addRoom(Room room); void removeRoom(int id); - - } diff --git a/src/main/java/de/ctdo/bunti/dao/RoomsDAOImpl.java b/src/main/java/de/ctdo/bunti/dao/RoomsDAOImpl.java index 3127851..d82e74b 100644 --- a/src/main/java/de/ctdo/bunti/dao/RoomsDAOImpl.java +++ b/src/main/java/de/ctdo/bunti/dao/RoomsDAOImpl.java @@ -1,18 +1,11 @@ package de.ctdo.bunti.dao; -import de.ctdo.bunti.model.Par56Spot; import de.ctdo.bunti.model.Room; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - import java.util.List; - public final class RoomsDAOImpl extends HibernateDaoSupport implements RoomsDAO { - public RoomsDAOImpl() { - - } - @Override public List getRooms() { return getHibernateTemplate().loadAll(Room.class); diff --git a/src/main/java/de/ctdo/bunti/dmx/DMXChannels.java b/src/main/java/de/ctdo/bunti/dmx/DMXChannels.java index 43374f8..521e4e7 100644 --- a/src/main/java/de/ctdo/bunti/dmx/DMXChannels.java +++ b/src/main/java/de/ctdo/bunti/dmx/DMXChannels.java @@ -1,5 +1,7 @@ package de.ctdo.bunti.dmx; +import de.ctdo.bunti.dmx.model.DMXChannel; + import java.util.Collection; import java.util.Collections; import java.util.HashMap; diff --git a/src/main/java/de/ctdo/bunti/dmx/DMXChannel.java b/src/main/java/de/ctdo/bunti/dmx/model/DMXChannel.java similarity index 95% rename from src/main/java/de/ctdo/bunti/dmx/DMXChannel.java rename to src/main/java/de/ctdo/bunti/dmx/model/DMXChannel.java index 528cc76..9e386af 100644 --- a/src/main/java/de/ctdo/bunti/dmx/DMXChannel.java +++ b/src/main/java/de/ctdo/bunti/dmx/model/DMXChannel.java @@ -1,4 +1,4 @@ -package de.ctdo.bunti.dmx; +package de.ctdo.bunti.dmx.model; public class DMXChannel { private int offset; diff --git a/src/main/java/de/ctdo/bunti/model/BuntiDMXDevice.java b/src/main/java/de/ctdo/bunti/model/BuntiDMXDevice.java index cf49d11..0a281fb 100644 --- a/src/main/java/de/ctdo/bunti/model/BuntiDMXDevice.java +++ b/src/main/java/de/ctdo/bunti/model/BuntiDMXDevice.java @@ -1,13 +1,11 @@ package de.ctdo.bunti.model; import de.ctdo.bunti.dmx.DMX; -import de.ctdo.bunti.dmx.DMXChannel; +import de.ctdo.bunti.dmx.model.DMXChannel; import de.ctdo.bunti.dmx.DMXChannels; import org.codehaus.jackson.annotate.JsonIgnore; +import org.hibernate.annotations.Entity; -import javax.persistence.Column; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; import javax.persistence.Transient; import java.util.HashMap; import java.util.Map; @@ -113,6 +111,18 @@ public abstract class BuntiDMXDevice extends BuntiDevice { return true; } + @Transient + @Override + public final Map getOptions() { + Map options = new HashMap(); + + for(DMXChannel channel: dmxChannels.getAllChannels()) { + options.put(channel.getName(), channel.getValue()); + } + + return options; + } + /** * Add a channel to this DMX Device * used internally by subclasses to define their structure diff --git a/src/main/java/de/ctdo/bunti/model/BuntiDevice.java b/src/main/java/de/ctdo/bunti/model/BuntiDevice.java index f9f4504..c275e12 100644 --- a/src/main/java/de/ctdo/bunti/model/BuntiDevice.java +++ b/src/main/java/de/ctdo/bunti/model/BuntiDevice.java @@ -1,7 +1,5 @@ package de.ctdo.bunti.model; -import javax.persistence.*; -import java.io.Serializable; import javax.persistence.*; import java.util.Map; @@ -103,13 +101,8 @@ public abstract class BuntiDevice { public abstract boolean setValuesFromOptions(Map options); -// @ManyToOne -// @JoinColumn(name="ROOM_ID") -// public Room getRoom() { -// return room; -// } -// -// public void setRoom(Room room) { -// this.room = room; -// } + @Transient + public abstract Map getOptions(); + } + diff --git a/src/main/java/de/ctdo/bunti/model/Par56Spot.java b/src/main/java/de/ctdo/bunti/model/Par56Spot.java index 92c2d41..b5b7f69 100644 --- a/src/main/java/de/ctdo/bunti/model/Par56Spot.java +++ b/src/main/java/de/ctdo/bunti/model/Par56Spot.java @@ -1,7 +1,8 @@ package de.ctdo.bunti.model; import de.ctdo.bunti.dmx.DMX; -import de.ctdo.bunti.dmx.DMXChannel; +import de.ctdo.bunti.dmx.model.DMXChannel; +import org.codehaus.jackson.annotate.JsonIgnore; import javax.persistence.Entity; import javax.persistence.Transient; @@ -41,16 +42,19 @@ public class Par56Spot extends BuntiDMXDevice { setChannelValueByName(CHANNEL_BLUE, value); } + @JsonIgnore @Transient public final int getRed() { return getChannelValueByName(CHANNEL_RED); } + @JsonIgnore @Transient public final int getGreen() { return getChannelValueByName(CHANNEL_GREEN); } + @JsonIgnore @Transient public final int getBlue() { return getChannelValueByName(CHANNEL_BLUE); diff --git a/src/main/java/de/ctdo/bunti/model/Room.java b/src/main/java/de/ctdo/bunti/model/Room.java index 7512111..ebb2b06 100644 --- a/src/main/java/de/ctdo/bunti/model/Room.java +++ b/src/main/java/de/ctdo/bunti/model/Room.java @@ -1,9 +1,7 @@ package de.ctdo.bunti.model; import javax.persistence.*; -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; +import java.util.*; @Entity @@ -15,7 +13,7 @@ public final class Room { private String floor; private int xCord; private int yCord; - private Set devices = new HashSet(); + private List devices = new ArrayList(); @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -67,38 +65,32 @@ public final class Room { @JoinTable(name = "ROOM_BUNTIDEVICE", joinColumns = { @JoinColumn(name = "ROOM_ID") }, inverseJoinColumns = { @JoinColumn(name = "BUNTIDEVICE_ID") }) - public Set getDevices() { - return this.devices; + public List getDevices() { + return Collections.unmodifiableList(this.devices); } - public void setDevices(Set devices) { + public void setDevices(List devices) { this.devices = devices; } -// @Transient -// public boolean addDevice(BuntiDevice device) { -// return getDevices().add(device); -// } -// -// @Transient -// public boolean removeDevice(BuntiDevice device) { -// return getDevices().remove(device); -// } -// -// @Transient -// public BuntiDevice getDevice(int id) { -// for (BuntiDevice device: getDevices()) { -// if( device.getId() == id) { -// return device; -// } -// } -// return null; -// } -// -// @Transient -// public List getDeviceList() { -// return Collections.unmodifiableList(getDevices()); -// } + @Transient + public boolean addDevice(BuntiDevice device) { + return getDevices().add(device); + } + @Transient + public boolean removeDevice(BuntiDevice device) { + return getDevices().remove(device); + } + + @Transient + public BuntiDevice getDevice(int id) { + for (BuntiDevice device: getDevices()) { + if( device.getId() == id) { + return device; + } + } + return null; + } } diff --git a/src/main/java/de/ctdo/bunti/model/Strobe1500.java b/src/main/java/de/ctdo/bunti/model/Strobe1500.java index cdd647f..4cbb134 100644 --- a/src/main/java/de/ctdo/bunti/model/Strobe1500.java +++ b/src/main/java/de/ctdo/bunti/model/Strobe1500.java @@ -1,7 +1,8 @@ package de.ctdo.bunti.model; import de.ctdo.bunti.dmx.DMX; -import de.ctdo.bunti.dmx.DMXChannel; +import de.ctdo.bunti.dmx.model.DMXChannel; +import org.codehaus.jackson.annotate.JsonIgnore; import javax.persistence.Entity; import javax.persistence.Transient; @@ -36,16 +37,19 @@ public class Strobe1500 extends BuntiDMXDevice { return setChannelValueByName(CHANNEL_MODE, value); } + @JsonIgnore @Transient public final int getSpeed() { return getChannelValueByName(CHANNEL_SPEED); } + @JsonIgnore @Transient public final int getIntensity() { return getChannelValueByName(CHANNEL_INTENSITY); } + @JsonIgnore @Transient public final int getMode() { return getChannelValueByName(CHANNEL_MODE); diff --git a/src/main/java/de/ctdo/bunti/web/DeviceControlController.java b/src/main/java/de/ctdo/bunti/web/DeviceControlController.java index 9df036d..6428089 100644 --- a/src/main/java/de/ctdo/bunti/web/DeviceControlController.java +++ b/src/main/java/de/ctdo/bunti/web/DeviceControlController.java @@ -1,7 +1,6 @@ package de.ctdo.bunti.web; import de.ctdo.bunti.control.BuntiController; -import de.ctdo.bunti.model.BuntiDevice; import de.ctdo.bunti.webmodel.DeviceUpdate; import de.ctdo.bunti.webmodel.DeviceUpdates; import org.slf4j.Logger; @@ -10,8 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; -import java.util.*; - @Controller @RequestMapping(value = "/control") public class DeviceControlController { @@ -23,29 +20,14 @@ public class DeviceControlController { this.controller = controller; } - @RequestMapping(value = "/devices", method = RequestMethod.GET) - public @ResponseBody Collection getAll() { - LOGGER.info("handle GET /devices request"); - return controller.getAllDevices(); - } - - @RequestMapping(value = "/devices/{id}", method = RequestMethod.GET) - public @ResponseBody BuntiDevice getDeviceById(@PathVariable("id") int id) { - LOGGER.info("handle GET /devices/" + id + " request"); - return controller.getDeviceById(id); - } - @RequestMapping(value = "/devices", method = RequestMethod.POST) - public String setDevices(@RequestBody DeviceUpdates updates) { + public void setDevices(@RequestBody DeviceUpdates updates) { LOGGER.info("handle PUT /devices" + " request update=" + updates.toString() ); for (DeviceUpdate update: updates.getUpdates()) { LOGGER.info("Update deviceId=" + update.getDeviceId()); - controller.updateDeviceData(update.getDeviceId(), update.getOptions()); } - - return "bla"; } } diff --git a/src/main/java/de/ctdo/bunti/web/DevicesController.java b/src/main/java/de/ctdo/bunti/web/DevicesController.java new file mode 100644 index 0000000..5e7dfa2 --- /dev/null +++ b/src/main/java/de/ctdo/bunti/web/DevicesController.java @@ -0,0 +1,38 @@ +package de.ctdo.bunti.web; + +import de.ctdo.bunti.dao.BuntiDevicesDAO; +import de.ctdo.bunti.model.BuntiDevice; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import java.util.Collection; + +@Controller +@RequestMapping(value = "/devices") +public class DevicesController { + private BuntiDevicesDAO devicesDAO; + + @Autowired + public void setDevicesDAO(BuntiDevicesDAO devicesDAO) { + this.devicesDAO = devicesDAO; + } + + @RequestMapping(value = "", method = RequestMethod.GET) + public @ResponseBody Collection getAll() { + return devicesDAO.getAllDevices(); + } + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + public @ResponseBody BuntiDevice getDeviceById(@PathVariable("id") int id) { + return devicesDAO.getDeviceById(id); + } + + @RequestMapping(value = "", method = RequestMethod.POST) + public @ResponseBody BuntiDevice setDevices(@RequestBody BuntiDevice device) { + devicesDAO.addDevice(device); + return device; + } + + +} diff --git a/src/main/java/de/ctdo/bunti/web/RoomsController.java b/src/main/java/de/ctdo/bunti/web/RoomsController.java index 180172a..dcd4c00 100644 --- a/src/main/java/de/ctdo/bunti/web/RoomsController.java +++ b/src/main/java/de/ctdo/bunti/web/RoomsController.java @@ -1,47 +1,45 @@ package de.ctdo.bunti.web; -import de.ctdo.bunti.control.BuntiController; +import de.ctdo.bunti.dao.RoomsDAO; +import de.ctdo.bunti.model.BuntiDevice; import de.ctdo.bunti.model.Room; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import java.util.Collection; +import java.util.List; @Controller @RequestMapping(value = "/rooms") public class RoomsController { - private static final Logger LOGGER = LoggerFactory.getLogger(RoomsController.class); - private BuntiController controller; - + private RoomsDAO roomsDAO; @Autowired - public final void setController(BuntiController controller) { - this.controller = controller; + public void setRoomsDAO(RoomsDAO roomsDAO) { + this.roomsDAO = roomsDAO; } @RequestMapping(value = "", method = RequestMethod.GET) public @ResponseBody Collection getAll() { - LOGGER.info("handle GET /rooms" + " request"); - return controller.getAllRooms(); + return roomsDAO.getRooms(); } @RequestMapping(value = "/{id}", method = RequestMethod.GET) public @ResponseBody Room getRoomById(@PathVariable("id") int id) { - LOGGER.info("handle GET /rooms/" + id + " request"); - return controller.getRoomById(id); + return roomsDAO.getRoom(id); } @RequestMapping(value = "/{id}/devices", method = RequestMethod.GET) - public @ResponseBody Room getDevicesFromRoom(@PathVariable("id") int id) { - LOGGER.info("handle GET /rooms/id/devices " + id + " request"); + public @ResponseBody + List getDevicesFromRoom(@PathVariable("id") int id) { + Room room = roomsDAO.getRoom(id); + + if(room != null) { + return room.getDevices(); + } - Room r = controller.getRoomById(id); - - - return controller.getRoomById(id); + return null; } } diff --git a/src/main/java/de/ctdo/bunti/webmodel/DeviceUpdates.java b/src/main/java/de/ctdo/bunti/webmodel/DeviceUpdates.java index 55a4b84..11635a6 100644 --- a/src/main/java/de/ctdo/bunti/webmodel/DeviceUpdates.java +++ b/src/main/java/de/ctdo/bunti/webmodel/DeviceUpdates.java @@ -1,16 +1,16 @@ package de.ctdo.bunti.webmodel; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +/** + * Diese Klasse gibts nur, weil ich es nicht hinbekomme mit Jackson + * ein ArrayList als Parameter im Controller zu verarbeiten. + */ public class DeviceUpdates { - private long timeStamp = 0; - private List updates = new ArrayList(); - public List getUpdates() { return updates; } diff --git a/src/main/resources/META-INF/spring/hibernate-beans.xml b/src/main/resources/META-INF/spring/hibernate-beans.xml index dd19922..ccc9010 100755 --- a/src/main/resources/META-INF/spring/hibernate-beans.xml +++ b/src/main/resources/META-INF/spring/hibernate-beans.xml @@ -1,19 +1,13 @@ - - - - - - - - + + @@ -22,7 +16,7 @@ org.hibernate.dialect.HSQLDialect true - create + @@ -32,6 +26,10 @@ + + + + diff --git a/src/main/resources/init_data.sql b/src/main/resources/init_data.sql index 3e189f7..0b1197e 100755 --- a/src/main/resources/init_data.sql +++ b/src/main/resources/init_data.sql @@ -6,6 +6,14 @@ insert into rooms (ROOM_ID, floor, roomName, xCord, yCord) values (null, '2. Eta insert into rooms (ROOM_ID, floor, roomName, xCord, yCord) values (null, '2. Etage', 'Flur', '1', '1'); +insert into devices (DTYPE, BUNTIDEVICE_ID, deviceName, picture, startAddress) + values ('Par56Spot',null,'Lampe1',null, 1); +insert into devices (DTYPE, BUNTIDEVICE_ID, deviceName, picture, startAddress) + values ('Par56Spot',null,'Lampe2',null, 6); +insert into devices (DTYPE, BUNTIDEVICE_ID, deviceName, picture, startAddress) + values ('Par56Spot',null,'Lampe3',null, 11); +insert into devices (DTYPE, BUNTIDEVICE_ID, deviceName, picture, startAddress) + values ('Par56Spot',null,'Lampe4',null, 16); diff --git a/src/test/java/de/ctdo/bunti/control/BuntiControllerImplTest.java b/src/test/java/de/ctdo/bunti/control/BuntiControllerImplTest.java new file mode 100644 index 0000000..a474047 --- /dev/null +++ b/src/test/java/de/ctdo/bunti/control/BuntiControllerImplTest.java @@ -0,0 +1,40 @@ +package de.ctdo.bunti.control; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +//@ContextConfiguration(locations = { "classpath:/META-INF/spring/root-context.xml","classpath:/de/ctdo/bunti/hibernate-test-context.xml" }) +//@RunWith(SpringJUnit4ClassRunner.class) +//public class BuntiControllerImplTest { + +// @Autowired +// BuntiController dut; +// +// @Test +// public void testUpdateDeviceData() throws Exception { +// +// } +// +// @Test +// public void testGetAllRooms() throws Exception { +// +// } +// +// @Test +// public void testGetRoomById() throws Exception { +// +// } +// +// @Test +// public void testGetAllDevices() throws Exception { +// +// } +// +// @Test +// public void testGetDeviceById() throws Exception { +// +// } +//} diff --git a/src/test/java/de/ctdo/bunti/control/BuntiControllerTest.java b/src/test/java/de/ctdo/bunti/control/BuntiControllerTest.java deleted file mode 100644 index 46d34ce..0000000 --- a/src/test/java/de/ctdo/bunti/control/BuntiControllerTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.ctdo.bunti.control; - -import org.junit.Before; - -public class BuntiControllerTest { - - BuntiControllerImpl dut; - - @Before - public void setUp() throws Exception { - dut = new BuntiControllerImpl(); -// dut.setDevicesDAO(daoMock); - } - -// @Test -// public void testSetDevice() throws Exception { -// Map options = new HashMap(); -// options.put("optionA", "valueA"); -// options.put("optionB", 42); -// assertTrue(dut.updateDeviceData(12, options)); -// } - -} diff --git a/src/test/java/de/ctdo/bunti/dao/BuntiDevicesDAOImplTest.java b/src/test/java/de/ctdo/bunti/dao/BuntiDevicesDAOImplTest.java new file mode 100644 index 0000000..f926a49 --- /dev/null +++ b/src/test/java/de/ctdo/bunti/dao/BuntiDevicesDAOImplTest.java @@ -0,0 +1,43 @@ +package de.ctdo.bunti.dao; + +import de.ctdo.bunti.model.BuntiDMXDevice; +import de.ctdo.bunti.model.BuntiDevice; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Collection; +import java.util.List; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNull; + +@ContextConfiguration(locations = { "classpath:/de/ctdo/bunti/hibernate-test-context.xml" }) +@RunWith(SpringJUnit4ClassRunner.class) +public class BuntiDevicesDAOImplTest { + + @Autowired + BuntiDevicesDAO dut; + + @Test + public void testGetAllDMXDevices() throws Exception { + List deviceList = dut.getAllDMXDevices(); + assertEquals(4, deviceList.size()); + } + + @Test + public void testGetAllDevices() throws Exception { + List deviceList = dut.getAllDevices(); + assertEquals(4, deviceList.size()); + } + + @Test + public void testGetDeviceById() throws Exception { + BuntiDevice device = dut.getDeviceById(2); + + assertEquals("Lampe2", device.getDeviceName()); + + } +} diff --git a/src/test/java/de/ctdo/bunti/dao/RoomsDAOImplTest.java b/src/test/java/de/ctdo/bunti/dao/RoomsDAOImplTest.java index b12d053..881057c 100644 --- a/src/test/java/de/ctdo/bunti/dao/RoomsDAOImplTest.java +++ b/src/test/java/de/ctdo/bunti/dao/RoomsDAOImplTest.java @@ -1,6 +1,5 @@ package de.ctdo.bunti.dao; -import de.ctdo.bunti.model.Room; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -10,7 +9,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNull; -@ContextConfiguration() +@ContextConfiguration(locations = { "classpath:/de/ctdo/bunti/hibernate-test-context.xml" }) @RunWith(SpringJUnit4ClassRunner.class) public class RoomsDAOImplTest { diff --git a/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java b/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java index df71b7f..6bb8375 100644 --- a/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java +++ b/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java @@ -1,5 +1,6 @@ package de.ctdo.bunti.dmx; +import de.ctdo.bunti.dmx.model.DMXChannel; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java b/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java index cbc6922..d24c8b8 100644 --- a/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java +++ b/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java @@ -1,5 +1,6 @@ package de.ctdo.bunti.dmx; +import de.ctdo.bunti.dmx.model.DMXChannel; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java b/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java index 0589455..8e69918 100644 --- a/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java +++ b/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java @@ -1,6 +1,6 @@ package de.ctdo.bunti.model; -import de.ctdo.bunti.dmx.DMXChannel; +import de.ctdo.bunti.dmx.model.DMXChannel; import org.junit.Before; import org.junit.Test; diff --git a/src/test/resources/de/ctdo/bunti/dao/RoomsDAOImplTest-context.xml b/src/test/resources/de/ctdo/bunti/hibernate-test-context.xml similarity index 90% rename from src/test/resources/de/ctdo/bunti/dao/RoomsDAOImplTest-context.xml rename to src/test/resources/de/ctdo/bunti/hibernate-test-context.xml index 5816a46..3def185 100644 --- a/src/test/resources/de/ctdo/bunti/dao/RoomsDAOImplTest-context.xml +++ b/src/test/resources/de/ctdo/bunti/hibernate-test-context.xml @@ -26,13 +26,14 @@ + + + + + + + - - - - - - \ No newline at end of file