Skip to content

Commit

Permalink
feat: fix test locally
Browse files Browse the repository at this point in the history
  • Loading branch information
FKD13 committed Mar 27, 2024
1 parent ab84635 commit 5878e2a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main/java/telraam/database/daos/StationDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface StationDAO extends DAO<Station> {
List<Station> 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);

Expand All @@ -33,6 +33,6 @@ public interface StationDAO extends DAO<Station> {
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);
}
11 changes: 6 additions & 5 deletions src/main/java/telraam/database/models/Station.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
8 changes: 5 additions & 3 deletions src/test/java/telraam/database/daos/StationDAOTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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);
Expand All @@ -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());
}

Expand Down

0 comments on commit 5878e2a

Please sign in to comment.