diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 7acacda..120e077 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -52,11 +52,16 @@ public class CacheConstructionUtil { } // Caches werden in die Datenbank eingetragen - if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0 || cache.getStationen().size() == 0) { + if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0) { deleteStationenUtil(cache); return ResponseEntity.status(400).body("cache fields can“t be empty"); } + if (cache.getStationen().size() < 2) { + deleteStationenUtil(cache); + return ResponseEntity.status(400).body("a cache needs atleast 2 stations"); + } + for (Cache cache1 : cacheRepository.findAll()) { if (cache1.getName().equals(cache.getName())) { deleteStationenUtil(cache);