From 5878e2a65095206a023f71ee101124bd9c44ca74 Mon Sep 17 00:00:00 2001 From: FKD13 <44001949+FKD13@users.noreply.github.com> Date: Thu, 28 Mar 2024 00:35:21 +0100 Subject: [PATCH] feat: fix test locally --- src/main/java/telraam/database/daos/StationDAO.java | 4 ++-- src/main/java/telraam/database/models/Station.java | 11 ++++++----- .../java/telraam/database/daos/StationDAOTest.java | 8 +++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/telraam/database/daos/StationDAO.java b/src/main/java/telraam/database/daos/StationDAO.java index cd73051..983eecf 100644 --- a/src/main/java/telraam/database/daos/StationDAO.java +++ b/src/main/java/telraam/database/daos/StationDAO.java @@ -19,7 +19,7 @@ public interface StationDAO extends DAO { List getAll(); @Override - @SqlUpdate("INSERT INTO station (name, distance_from_start, broken, url, coord_x, coord_y) VALUES (:name, :distanceFromStart, :isBroken, :url, :coordX, :coordY)") + @SqlUpdate("INSERT INTO station (name, distance_from_start, broken, url, coord_x, coord_y) VALUES (:name, :distanceFromStart, :broken, :url, :coordX, :coordY)") @GetGeneratedKeys({"id"}) int insert(@BindBean Station station); @@ -33,6 +33,6 @@ public interface StationDAO extends DAO { int deleteById(@Bind("id") int id); @Override - @SqlUpdate("UPDATE station SET name = :name, distance_from_start = :distanceFromStart, broken = :isBroken, url = :url, coord_x = :coordX, coord_y = :coordY WHERE id = :id") + @SqlUpdate("UPDATE station SET name = :name, distance_from_start = :distanceFromStart, broken = :broken, url = :url, coord_x = :coordX, coord_y = :coordY WHERE id = :id") int update(@Bind("id") int id, @BindBean Station station); } diff --git a/src/main/java/telraam/database/models/Station.java b/src/main/java/telraam/database/models/Station.java index 888a21e..442e412 100644 --- a/src/main/java/telraam/database/models/Station.java +++ b/src/main/java/telraam/database/models/Station.java @@ -8,30 +8,31 @@ public class Station { private Integer id; private String name; private Double distanceFromStart; - private Boolean isBroken; + @Getter @Setter + private Boolean broken; private String url; private Double coordX; private Double coordY; public Station() { - this.isBroken = false; + this.broken = false; } public Station(String name, String url) { this.name = name; - this.isBroken = false; + this.broken = false; this.url = url; } public Station(String name, Double distanceFromStart, String url) { this.name = name; - this.isBroken = false; + this.broken = false; this.distanceFromStart = distanceFromStart; this.url = url; } public Station(String name, boolean isBroken) { this.name = name; - this.isBroken = isBroken; + this.broken = isBroken; } } diff --git a/src/test/java/telraam/database/daos/StationDAOTest.java b/src/test/java/telraam/database/daos/StationDAOTest.java index 64b5c6f..2bd64bc 100644 --- a/src/test/java/telraam/database/daos/StationDAOTest.java +++ b/src/test/java/telraam/database/daos/StationDAOTest.java @@ -34,7 +34,7 @@ void createStation() { Station station = stationOptional.get(); assertEquals("teststation", station.getName()); assertEquals(1d, station.getDistanceFromStart()); - assertEquals(false, station.getIsBroken()); + assertEquals(false, station.getBroken()); assertEquals("localhost:8000", station.getUrl()); } @@ -83,7 +83,8 @@ void testUpdateDoesUpdate() { testStation.setId(testid); testStation.setName("postUpdate"); testStation.setDistanceFromStart(2d); - testStation.setIsBroken(true); + testStation.setCoordY(0.69); + testStation.setBroken(true); testStation.setUrl("localhost:8001"); int updatedRows = stationDAO.update(testid, testStation); assertEquals(1, updatedRows); @@ -92,7 +93,8 @@ void testUpdateDoesUpdate() { assertFalse(dbStation.isEmpty()); assertEquals("postUpdate", dbStation.get().getName()); assertEquals(2d, dbStation.get().getDistanceFromStart()); - assertEquals(true, dbStation.get().getIsBroken()); + assertEquals(true, dbStation.get().getBroken()); + assertEquals(0.69, dbStation.get().getCoordY()); assertEquals("localhost:8001", dbStation.get().getUrl()); }