From 73ff41f95447b55f22b71da008c35b755fe47ed9 Mon Sep 17 00:00:00 2001 From: Gabriel Copat <copatg@cardiff.ac.uk> Date: Tue, 9 Jan 2024 11:13:30 +0000 Subject: [PATCH] Edited main branch so that I can do my tests for the PPP coursework. Also, Rhys N. asked if he could use this branch to do his tests as well --- .../PlacesController.java | 33 ++--- .../SmartTowns/users/UserController.java | 25 +++- src/main/resources/application.properties | 2 +- src/main/resources/data.sql | 14 +- src/test/java/CalculatorTest.java | 49 ------- .../users/UserTests.java | 7 + .../Team5/SmartTownsOld/DBUnitTestCase.java | 26 ---- .../Team5/SmartTownsOld/DataSourceConfig.java | 19 --- .../SmartTownsOld/LocationRepositoryTest.java | 130 ------------------ .../SmartTownsApplicationTests.java | 92 ------------- src/test/java/Team5/SmartTownsOld/Test4.java | 33 ----- src/test/java/Team5/SmartTownsOld/Test5.java | 37 ----- .../java/Team5/SmartTownsOld/Test6Mock.java | 79 ----------- .../SmartTownsOld/TrailsRepositoryTest.java | 44 ------ .../data/LocationRepositoryJDBCTest.java | 44 ------ .../SmartTownsOld/data/LocationTest.java | 5 - .../PlacesCoordinatesTest.java | 125 ----------------- .../java/Team5/SmartTownsOld/testUsers.java | 79 ----------- src/test/java/Test3.java | 27 ---- src/test/java/testTwo.java | 52 ------- src/test/resources/application.properties | 6 +- src/test/resources/data.sql | 84 +---------- src/test/resources/schema-test.sql | 121 ---------------- src/test/resources/schema.sql | 109 +-------------- src/test/resources/test-data.sql | 104 -------------- 25 files changed, 59 insertions(+), 1287 deletions(-) delete mode 100644 src/test/java/CalculatorTest.java rename src/test/java/Team5/{SmartTownsOld => SmartTowns}/users/UserTests.java (89%) delete mode 100644 src/test/java/Team5/SmartTownsOld/DBUnitTestCase.java delete mode 100644 src/test/java/Team5/SmartTownsOld/DataSourceConfig.java delete mode 100644 src/test/java/Team5/SmartTownsOld/LocationRepositoryTest.java delete mode 100644 src/test/java/Team5/SmartTownsOld/SmartTownsApplicationTests.java delete mode 100644 src/test/java/Team5/SmartTownsOld/Test4.java delete mode 100644 src/test/java/Team5/SmartTownsOld/Test5.java delete mode 100644 src/test/java/Team5/SmartTownsOld/Test6Mock.java delete mode 100644 src/test/java/Team5/SmartTownsOld/TrailsRepositoryTest.java delete mode 100644 src/test/java/Team5/SmartTownsOld/data/LocationRepositoryJDBCTest.java delete mode 100644 src/test/java/Team5/SmartTownsOld/data/LocationTest.java delete mode 100644 src/test/java/Team5/SmartTownsOld/placeswithcoordinates/PlacesCoordinatesTest.java delete mode 100644 src/test/java/Team5/SmartTownsOld/testUsers.java delete mode 100644 src/test/java/Test3.java delete mode 100644 src/test/java/testTwo.java delete mode 100644 src/test/resources/schema-test.sql delete mode 100644 src/test/resources/test-data.sql diff --git a/src/main/java/Team5/SmartTowns/placeswithcoordinates/PlacesController.java b/src/main/java/Team5/SmartTowns/placeswithcoordinates/PlacesController.java index d5c1f96a..f70cabeb 100644 --- a/src/main/java/Team5/SmartTowns/placeswithcoordinates/PlacesController.java +++ b/src/main/java/Team5/SmartTowns/placeswithcoordinates/PlacesController.java @@ -16,10 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @Controller @@ -39,21 +36,21 @@ public class PlacesController { - @GetMapping("/towns") - public ModelAndView getTownPages(){ - ModelAndView modelAndView = new ModelAndView("towns/townsPageList.html"); - List<TownWithTrails> townsList = placeRepo.getAllTownCoords(); - List<Trail> trailslocations = trailsRepo.getAllTrails(); - modelAndView.addObject("trails", trailslocations); - modelAndView.addObject("towns", townsList); - return modelAndView; - } +// @GetMapping("/towns") +// public ModelAndView getTownPages(){ +// ModelAndView modelAndView = new ModelAndView("towns/townsPageList.html"); +// List<TownWithTrails> townsList = placeRepo.getAllTownCoords(); +// List<Trail> trailslocations = trailsRepo.getAllTrails(); +// modelAndView.addObject("trails", trailslocations); +// modelAndView.addObject("towns", townsList); +// return modelAndView; +// } - @RequestMapping(value="/town", method= RequestMethod.POST) - public String sendHtmlFragmentTown(Model map) { - map.addAttribute("foo", "bar"); - return "checkpoint/checkpoint"; - } +// @RequestMapping(value="/town", method= RequestMethod.POST) +// public String sendHtmlFragmentTown(Model map) { +// map.addAttribute("foo", "bar"); +// return "checkpoint/checkpoint"; +// } @GetMapping("/towns/{town}") public ModelAndView getResultBySearchKeyTowns(@PathVariable String town) { diff --git a/src/main/java/Team5/SmartTowns/users/UserController.java b/src/main/java/Team5/SmartTowns/users/UserController.java index e9fd1bef..9504b3f1 100644 --- a/src/main/java/Team5/SmartTowns/users/UserController.java +++ b/src/main/java/Team5/SmartTowns/users/UserController.java @@ -46,7 +46,7 @@ public class UserController { @PostMapping("/register") public ModelAndView registerUser(@Valid @ModelAttribute("user") NewUser user, BindingResult bindingResult, Model model) { ModelAndView mav = new ModelAndView("users/login", model.asMap()); - // TODO VALIDATE EMAIL INPUT + mav.addObject("status", "active"); if (bindingResult.hasErrors()) { ModelAndView modelAndView = new ModelAndView("users/login"); @@ -109,6 +109,29 @@ public class UserController { mav.addObject("user", userRepository.findUserByName(username)); return mav; } +// @GetMapping("/packInfo/{username}/{packID}") +// public ModelAndView betterGetPackInfo(@PathVariable String username, @PathVariable int packID) { +// /* Displays on page the stickers present in the pack and colour the ones the +// * user has acquired */ +// ModelAndView mav = new ModelAndView("users/userFrags :: stickersBox"); +// mav.addObject("currentUser", userRepository.findUserByName(username)); +// mav.addObject("displayedPack", rewardsRepository.findPackByID(packID)); +// +// List<Sticker> allStickers = rewardsRepository.getAllStickersFromPack(packID); +// List<Pack> allPacks = rewardsRepository.getAllPacks() +// .stream() +// .filter(pack -> pack.getId() != packID) //Gets all but current pack +// .toList(); +// mav.addObject("packs", allPacks); +// +// List<Sticker> allUnlockedStickers = setStickerVisibility(allStickers, +// userRepository.getUserStickersFromPack(username, packID) //From database +// ); +// mav.addObject("stickers", allUnlockedStickers); +// mav.addObject("packProgress", getPackProgress(allUnlockedStickers)); +// +// return mav; +// } public int getPackProgress(List<Sticker> userStickers){ /* Returns the % of completion of given userStickers */ diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 52e81d21..fc40c9e4 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,4 @@ -spring.datasource.url=jdbc:mariadb://localhost:3306/towns +spring.datasource.url=jdbc:mariadb://localhost:3306/ spring.datasource.username=root spring.datasource.password=comsc diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 8ffad043..89f5d4a5 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -1,11 +1,11 @@ -delete from trails; + insert into trails ( trailID, trailName, trailNumber, city) value ( 0101,'Caerphilly Castle Trail','0101', 'Caerphilly'); insert into trails ( trailID, trailName, trailNumber, city) value ( 0102,'Caerphilly Pub Trail','0102', 'Caerphilly'); insert into trails ( trailID, trailName, trailNumber, city) value ( 0103,'Caerphilly Heritage Trail','0103', 'Caerphilly'); insert into trails ( trailID, trailName, trailNumber, city) value ( 0201,'Risca Heritage Trail','0201', 'Risca'); insert into trails ( trailID, trailName, trailNumber, city) value ( 0301,'Penarth Esplanade Trail','0301', 'Penarth'); -delete from locations; + insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'St Cenydd','','Location description here','Caerphilly',0101, false); insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Castle','','Location description here','Caerphilly',0101, true); insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Medieval Trades','','Location description here','Caerphilly',0101, true); @@ -55,7 +55,7 @@ INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 2, INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 3, 'Welsh Spoon', 'Welsh Heritage', '1'); -delete from locationCoordinates; + insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (2, 51.57623, -3.21910 ); insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (3, 51.575372, -3.219186); insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (4, 51.576363, -3.220712 ); @@ -69,21 +69,19 @@ insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLon insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (20, 51.43547, -3.16789 ); -delete from localauthority; + insert into localauthority ( localAuthorityName, address1, address2, city, county, postcode, website) value ( 'Caerphilly County Borough Council', 'Tredomen Park','', 'Ystrad Mynach, Hengoed', '', 'CF82 7PG', 'https://www.caerphilly.gov.uk/main.aspx?lang=en-GB'); insert into localauthority ( localAuthorityName, address1, address2, city, county, postcode, website) value ( 'Risca Town Council', 'Unit B, 75 Tredegar Street', '', 'Risca', '', 'NP11 6BW', 'https://www.riscatowncouncil.org.uk/'); insert into localauthority ( localAuthorityName, address1, address2, city, county, postcode, website) value ( 'Penarth Town Council West House', 'Stanwell Road', '', 'Penarth', '', 'CF64 2YG', 'https://www.penarthtowncouncil.gov.uk/your-council/'); -delete from businesses; + insert into businesses ( businessName, address1, address2, city, county, postcode, website) value ( 'Caerphilly Castle', 'Castle Street','', 'Caerphilly', '', 'CF836 1JD', 'https://cadw.gov.wales/visit/places-to-visit/caerphilly-castle'); insert into businesses ( businessName, address1, address2, city, county, postcode, website) value ( 'Risca Museum', 'Grove Road', '', 'Risca', '', 'NP11 6GN', 'https://riscamuseum.wales/'); insert into businesses ( businessName, address1, address2, city, county, postcode, website) value ( 'Penarth Pier Pavillion Cinema', 'Windsor Court', 'The Esplanade', 'Penarth', '', 'CF64 3AU', 'https://www.valeofglamorgan.gov.uk/en/enjoying/Coast-and-Countryside/Dog-Beach-Ban.aspx'); -delete from townsWithTrails; + insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Caerphilly', '51.57903','-3.22075 ','51.60418','51.55093','-3.25222','-3.17696'); insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Risca','51.61195','-3.09648','51.63039','51.59175','-3.12129','-3.06438'); insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Penarth','51.43893','-3.17354','51.44878','51.41233','-3.20271','-3.16005'); -delete from dragonstale; -insert into dragonstale(landmarkID, landmarkName, landmarkDescription, imgPath) value (1, 'A scent of...Dragon', 'The Dragon has been spotted near by, find the QR code to continue', '~/images/dragonstale/DTLM1.png'); \ No newline at end of file diff --git a/src/test/java/CalculatorTest.java b/src/test/java/CalculatorTest.java deleted file mode 100644 index 67f7188b..00000000 --- a/src/test/java/CalculatorTest.java +++ /dev/null @@ -1,49 +0,0 @@ -import Team5.SmartTowns.data.Calculator; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -//import org.springframework.dao.DataAccessException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -//import org.junit.platform.engine.TestDescriptor; -//import org.junit.platform.commons.util.Preconditions; - -//@SpringBootTest -public class CalculatorTest { -// String asd= getLegacyReportingName("das"); - - private static Calculator calculator; - - @BeforeAll - public static void before() { - calculator = new Calculator(); - } - - @Test - public void whenDivideNumbersThenReturnDivision() { - - assertEquals(2, calculator.divide(4, 2)); - } - - @Test - public void whenDivideByZeroThenThrowException() { - assertThrows(ArithmeticException.class, () -> calculator.divide(1, 0)); - } - @Test - public void whenAddingThingsThenAdd(){ - assertEquals(10,calculator.add(6,4)); - } - @Test - public void whenSubtractingThingsThenSubtract(){ - assertEquals(-5,calculator.subtract(5,10)); - } - - @Test - public void whenMultiplyingThingsThenMultiply(){ - assertEquals(-60,calculator.multiply(-3,20)); - } - - - - -} diff --git a/src/test/java/Team5/SmartTownsOld/users/UserTests.java b/src/test/java/Team5/SmartTowns/users/UserTests.java similarity index 89% rename from src/test/java/Team5/SmartTownsOld/users/UserTests.java rename to src/test/java/Team5/SmartTowns/users/UserTests.java index 50fe6606..5abc6d45 100644 --- a/src/test/java/Team5/SmartTownsOld/users/UserTests.java +++ b/src/test/java/Team5/SmartTowns/users/UserTests.java @@ -3,7 +3,11 @@ package Team5.SmartTowns.users; import org.junit.jupiter.api.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.test.context.jdbc.Sql; import javax.sql.DataSource; import java.util.Arrays; @@ -22,6 +26,7 @@ class UserTests { @Autowired JdbcTemplate jdbcTemplate; + @BeforeEach public void resetUserTable(){ /*Deletes table as each test creates the table it needs for its own testing*/ @@ -64,6 +69,7 @@ class UserTests { void doesUserExist() { jdbcTemplate.update("INSERT INTO users (username, email, password) VALUE ('UserExists', 'email@test.com', 'test')" ); assertTrue( userRepository.doesUserExist("email@test.com") ); + assertFalse( userRepository.doesUserExist("user@doesnot.exist")); } @Test @@ -84,5 +90,6 @@ class UserTests { name); User user = userRepository.findUserByName(name); assertEquals(name, user.getName()); + assertNull(userRepository.findUserByName("Jack")); } } \ No newline at end of file diff --git a/src/test/java/Team5/SmartTownsOld/DBUnitTestCase.java b/src/test/java/Team5/SmartTownsOld/DBUnitTestCase.java deleted file mode 100644 index 454e85ee..00000000 --- a/src/test/java/Team5/SmartTownsOld/DBUnitTestCase.java +++ /dev/null @@ -1,26 +0,0 @@ -package Team5.SmartTownsOld; - -import org.junit.jupiter.api.Test; - -//import static org.testing.AssertJUnit.assertEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.testng.annotations.Test; -//import org.testng.annotations.Test; -//import org.apiguardian.api; -//import org.junit.platform.engine.TestDescriptor; - -//import static org.junit.jupiter.api.Assertions.assertEquals; - - -public class DBUnitTestCase { - int bb=4; - int aa=5; - @Test - void whenDivideNumbersThenReturnDivision() { - int aa=5; - assertEquals(5, aa); - } - - -} \ No newline at end of file diff --git a/src/test/java/Team5/SmartTownsOld/DataSourceConfig.java b/src/test/java/Team5/SmartTownsOld/DataSourceConfig.java deleted file mode 100644 index 568065a2..00000000 --- a/src/test/java/Team5/SmartTownsOld/DataSourceConfig.java +++ /dev/null @@ -1,19 +0,0 @@ -package Team5.SmartTowns; - -import javax.sql.DataSource; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.jdbc.datasource.DriverManagerDataSource; - -@Configuration -public class DataSourceConfig { - - @Bean - public DataSource dataSource(){ - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setUrl("jdbc:mariadb://localhost:3306/test_towns"); - dataSource.setUsername("root"); - dataSource.setPassword("comsc"); - return dataSource; - } -} \ No newline at end of file diff --git a/src/test/java/Team5/SmartTownsOld/LocationRepositoryTest.java b/src/test/java/Team5/SmartTownsOld/LocationRepositoryTest.java deleted file mode 100644 index ec99ea8a..00000000 --- a/src/test/java/Team5/SmartTownsOld/LocationRepositoryTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package Team5.SmartTownsOld; - -import Team5.SmartTowns.data.Location; -import Team5.SmartTowns.data.LocationRepository; - -import Team5.SmartTowns.data.TrailsRepository; -import Team5.SmartTowns.placeswithcoordinates.LocationsCoordinates; -import Team5.SmartTowns.placeswithcoordinates.PlacesCoordinatesRepository; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.jdbc.core.JdbcTemplate; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import static junit.framework.TestCase.assertTrue; -import static org.junit.jupiter.api.Assertions.*; - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@SpringBootTest -public class LocationRepositoryTest { - - @Autowired - TrailsRepository trailsRepo; - @Autowired - LocationRepository locationRepository; - - - @Autowired - PlacesCoordinatesRepository placesRepository; - - @Autowired - JdbcTemplate jdbcTemplate; - - - -// @BeforeEach -// public void beforeEachTest(){ -// jdbcTemplate.update("DELETE FROM locations"); -// } - - @Test - public void testGetAllApprovedLocations() { // test to amke sure all approved locations are called - List<Location> approvedLocations = locationRepository.getAllApprovedLocations(); - List<Location> allLocations = locationRepository.getAllLocation(); - for (int i=0;i<allLocations.size();i++){ // iterate over all location, removing authorised=true - for (Location app : approvedLocations){ - if (Objects.equals(allLocations.get(i).getLocationName(), app.getLocationName())){ - allLocations.remove(allLocations.get(i)); - } - } - } boolean noApporvedLeft=false; - for (Location loc2: allLocations){ - if (loc2.isLocationApproved()){ - noApporvedLeft=false; - break; - } else{ - noApporvedLeft=true; - } - } assertTrue(noApporvedLeft); - } - - - @Test - public void testGetAllUnapprovedLocations() { // test to make sure all unapproved coordinates are called - List<Location> unapprovedLocations = locationRepository.getAllUnapprovedLocations(); - List<Location> allLocations = locationRepository.getAllLocation(); - for (int i=0;i<allLocations.size();i++){ // iterate over all location, removing authorised=false - for (Location app : unapprovedLocations){ - if (Objects.equals(allLocations.get(i).getLocationName(), app.getLocationName())){ - allLocations.remove(allLocations.get(i)); - } - } - } boolean noUnapprovedLeft=false; - for (Location loc2: allLocations){ - if (!loc2.isLocationApproved()){ - noUnapprovedLeft=false; - break; - } else{ - noUnapprovedLeft=true; - } - } assertTrue(noUnapprovedLeft); - } - @Test// test to ensure that the number of approved locations and number of associated locations with coordinates are equal - public void ensureApprovedLocationsAndCoordinatessAreTheSameSize(){ - List<Location> approvedLocations = locationRepository.getAllApprovedLocations(); - List<LocationsCoordinates> coordinatesLocations = placesRepository.getAllLocationCoords(); - assertSame(approvedLocations.size(),coordinatesLocations.size() ); - - } - - - @Test // test to ensure that all default locations and location coordinates match - public void ensureApprovedLocationsAndCoordinatessTableLineUpTest(){ - List<Location> approvedLocations = locationRepository.getAllApprovedLocations(); - List<LocationsCoordinates> coordinatesLocations = placesRepository.getAllLocationCoords(); - boolean doTheyMatch=false; - for (int i=0;i<coordinatesLocations.size();i++){ - int locID=coordinatesLocations.get(i).getLocationID(); - String coordName = jdbcTemplate.queryForObject("SELECT locationName FROM locations WHERE locationID=?", String.class, locID); - - if (Objects.equals(coordName, approvedLocations.get(i).getLocationName())){ - doTheyMatch=true; - } else{ - doTheyMatch=false; - break; - } - // for loop goes through entire list, if there were any discrepancies, the loop would break, resulting in a fail - - - } assertTrue(doTheyMatch); - } - - - @Test - public void doesApprovalUpdateTest(){ //tests whether locations that are approved have their database approval changed to true - int approvedLocationsTotal = locationRepository.getAllApprovedLocations().size(); - Location unapprovedLocation = new Location("test","test@email","","Caerphilly","102",false); - locationRepository.addLocation(unapprovedLocation); - int newID=locationRepository.nametoLocationID( unapprovedLocation.getLocationName()); - locationRepository.updateApprovalStatus(newID); - int newApprovedLocationsTotal = locationRepository.getAllApprovedLocations().size(); - assertEquals(1,(newApprovedLocationsTotal-approvedLocationsTotal)); - } -} diff --git a/src/test/java/Team5/SmartTownsOld/SmartTownsApplicationTests.java b/src/test/java/Team5/SmartTownsOld/SmartTownsApplicationTests.java deleted file mode 100644 index 4b281aab..00000000 --- a/src/test/java/Team5/SmartTownsOld/SmartTownsApplicationTests.java +++ /dev/null @@ -1,92 +0,0 @@ -//package Team5.SmartTowns; -// -//import Team5.SmartTowns.data.DatabaseController; -//import Team5.SmartTowns.data.Location; -//import Team5.SmartTowns.data.LocationRepository; -//import Team5.SmartTowns.data.LocationRepositoryJDBC; -//import Team5.SmartTowns.landmarks.Landmarks; -//import org.junit.jupiter.api.BeforeAll; -//import org.junit.jupiter.api.Test; -//import org.mockito.InjectMocks; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -//import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.jdbc.core.JdbcTemplate; -// -//import static org.junit.jupiter.api.Assertions.assertEquals; -// -//import java.lang.annotation.Inherited; -//import java.util.List; -// -// -// -//@DataJpaTest -//@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) -////@SpringBootTest -//class SmartTownsApplicationTests { -// -// @Autowired -// private LocationRepository locationRepository; -// -// -// @Test -// void contextLoads() { -// } -// -// @Test -// void test(){ -// Location location = new Location(); -// location.setLocationName("Test"); -// location.setLocationEmail("test@test"); -// location.setLocationDescription("Description Here"); -// location.setLocationPlace("Caerphilly"); -// location.setLocationTrailID("0103"); -// location.setLocationApproved(false); -// -// int locSize1 = locationRepository.getAllLocation().size(); -// locationRepository.addLocation(location); -// int locSize2 = locationRepository.getAllLocation().size(); -// assertEquals(1, (locSize2-locSize1)); -// -// -// } -// -// -// -// -// -//// private static Location location; -//// private static locationRepositoryJDBC locationRepo; -//// private static JdbcTemplate jdbc; -//// @BeforeAll -//// public static void before() { -//// location = new Location(); -//// locationRepo = new locationRepositoryJDBC(jdbc);} -//// @BeforeAll -//// public static void before2() { -//// locationRepo = new locationRepositoryJDBC(jdbc); } -//// @Autowired -//// private locationRepository locationRepository; -// -//// @Test -//// public void whenAddingLocationsNonApprovedLocationsDontShowInTrails(){ -//// /// Discover number of approved/unapproved locations before adding tests -//// List<Location> approvedNumber = locationRepo.approvedLocations(); -//// } -////// Location loc1= new Location("TestFail", "Test@PleaseFail.test", "Fail Description here", -////// "Caerphilly", 103, false); -////// Location loc2= new Location("TestFail", "Test@PleaseFail2.test", "Fail Description here", -////// "Caerphilly", 103, false); -////// Location loc3= new Location("TestPass", "Test@PleasePass.test", "Pass Description here", -////// "Caerphilly", 103, true); -////// locationRepository.addLocation(loc1); -////// locationRepository.addLocation(loc2); -////// locationRepository.addLocation(loc3); -////// List<Location> ApprovedNumberAfter=locationRepository.approvedLocations(); -////// -////// assertEquals(1,( ApprovedNumber.size()-ApprovedNumberAfter.size())); -//// } -// } -// -//// create test where getFullListLocations and getFullApproved/Unapporved lcopations from lcoationcooirds matches locationJDBC diff --git a/src/test/java/Team5/SmartTownsOld/Test4.java b/src/test/java/Team5/SmartTownsOld/Test4.java deleted file mode 100644 index cdeb2c54..00000000 --- a/src/test/java/Team5/SmartTownsOld/Test4.java +++ /dev/null @@ -1,33 +0,0 @@ -package Team5.SmartTownsOld; - -//import Team5.SmartTowns.Data.Location; -//import Team5.SmartTowns.Data.LocationRepositoryJDBC; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -//import org.springframework.jdbc.core.JdbcTemplate; - -import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig -public class Test4 { -// @Mock -// JdbcTemplate jdbcTemplate; - - -// @BeforeAll -// static void before() { -// Location location = new Location(); -// } - @Test - - public void whenMockJdbcTemplate_thenReturnCorrectEmployeeCount() { -// Location aa=new Location(); -// LocationRepositoryJDBC employeeDAO = new LocationRepositoryJDBC(); -// ReflectionTestUtils.setField(employeeDAO, "jdbcTemplate", jdbcTemplate); -// Mockito.when(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM locations", Integer.class)) -// .thenReturn(4); - - assertEquals(4, 4); - } -} diff --git a/src/test/java/Team5/SmartTownsOld/Test5.java b/src/test/java/Team5/SmartTownsOld/Test5.java deleted file mode 100644 index 23c64352..00000000 --- a/src/test/java/Team5/SmartTownsOld/Test5.java +++ /dev/null @@ -1,37 +0,0 @@ -package Team5.SmartTownsOld; - -import Team5.SmartTowns.data.LocationRepository; -//import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.jdbc.Sql; - - -//import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; - -@SpringBootTest -//@JdbcTest -// -@Sql({"/resources/schema.sql", "/resources/test-data.sql"}) -public class Test5 { - - @Autowired - private LocationRepository locationRepo; - - - @Test -// test 1 - void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount() { -// LocationRepositoryJDBC employeeDAO = new LocationRepositoryJDBC(ajdbc); - int aa=2; - int bb=2; -// employeeDAO.setJdbc(ajdbc); - assertEquals(4, (aa+bb)); - - } - - - -} diff --git a/src/test/java/Team5/SmartTownsOld/Test6Mock.java b/src/test/java/Team5/SmartTownsOld/Test6Mock.java deleted file mode 100644 index 9a19e2dc..00000000 --- a/src/test/java/Team5/SmartTownsOld/Test6Mock.java +++ /dev/null @@ -1,79 +0,0 @@ -//package Team5.SmartTowns; -// -//import Team5.SmartTowns.Data.Location; -//import Team5.SmartTowns.Data.LocationRepository; -//import Team5.SmartTowns.Data.LocationRepositoryJDBC; -//import org.junit.Before; -////import org.junit.runner.RunWith; -////import org.mockito.Mockito; -////import org.mockito.internal.invocation.InvocationsFinder; -//import org.junit.jupiter.api.BeforeAll; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.boot.test.context.TestConfiguration; -// -//import org.springframework.boot.test.mock.mockito.MockBean; -//import org.springframework.context.annotation.Bean; -//import org.springframework.jdbc.core.JdbcTemplate; -////import org.springframework.test.context.junit4.SpringRunner; -//import org.testng.annotations.Test; -// -//import java.util.ArrayList; -//import java.util.List; -// -//import static org.testng.AssertJUnit.assertEquals; -// -////@RunWith(SpringRunner.class) -//@SpringBootTest -//public class Test6Mock { -// -// @TestConfiguration -// static class EmployeeServiceImplTestContextConfiguration { -// -// @Bean -// public Location location() { -// return new Location(); -// } -// } -// -// -// @Autowired -// private LocationRepository locationRepo; -// @Autowired -// private LocationRepositoryJDBC locationRepoJ; -// -// -// @MockBean -// private JdbcTemplate jdbc; -// -// -// @BeforeAll -// public static void setUp() { -// LocationRepository LocationRepository= new LocationRepository() { -// @Override -// public List<Location> getAllLocation() { -// return null; -// } -// -// @Override -// public void addLocation(Location loc) { -// -// } -// }; -// -//// Location alex = new Location("House","House@Bricks","Description Here","Caerphilly",103); -//// -//// Mockito.when(LocationRepository.getAllLocation()) -//// .thenReturn(LocationRepository.getAllLocation()); -// } -// -// -// @Test -// public void whenValidName_thenEmployeeShouldBeFound() { -// LocationRepositoryJDBC s= new LocationRepositoryJDBC(jdbc); -// List<Location> locations = LocationRepository.getAllLocation(); -// assertEquals(18,locations.size()); -// -// } -// } -// diff --git a/src/test/java/Team5/SmartTownsOld/TrailsRepositoryTest.java b/src/test/java/Team5/SmartTownsOld/TrailsRepositoryTest.java deleted file mode 100644 index ad45f88b..00000000 --- a/src/test/java/Team5/SmartTownsOld/TrailsRepositoryTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package Team5.SmartTownsOld; - -import Team5.SmartTowns.data.LocationRepository; -import Team5.SmartTowns.data.TrailsRepository; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.jdbc.core.JdbcTemplate; - -import static org.junit.jupiter.api.Assertions.assertEquals; - - -@SpringBootTest -public class TrailsRepositoryTest { - @Autowired - TrailsRepository trailsRepo; - - @Autowired - JdbcTemplate jdbcTemplate; - - @Test - public void getTrailNameWithIDTest(){ - String trailsID="101"; - String trailName= trailsRepo.getTrailNameWithID(trailsID); - assertEquals("Caerphilly Castle Trail",trailName); - trailsID="102"; - trailName= trailsRepo.getTrailNameWithID(trailsID); - assertEquals("Caerphilly Pub Trail",trailName); - trailsID="103"; - trailName= trailsRepo.getTrailNameWithID(trailsID); - assertEquals("Caerphilly Heritage Trail",trailName); - trailsID="201"; - trailName= trailsRepo.getTrailNameWithID(trailsID); - assertEquals("Risca Heritage Trail",trailName); - trailsID="301"; - trailName= trailsRepo.getTrailNameWithID(trailsID); - assertEquals("Penarth Esplanade Trail",trailName); - } // test whether function works correctly for all instances - - - - -} diff --git a/src/test/java/Team5/SmartTownsOld/data/LocationRepositoryJDBCTest.java b/src/test/java/Team5/SmartTownsOld/data/LocationRepositoryJDBCTest.java deleted file mode 100644 index 73792324..00000000 --- a/src/test/java/Team5/SmartTownsOld/data/LocationRepositoryJDBCTest.java +++ /dev/null @@ -1,44 +0,0 @@ -//package Team5.SmartTowns.data; -// -//import org.junit.jupiter.api.Test; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.jdbc.core.JdbcTemplate; -//import org.springframework.jdbc.core.RowMapper; -// -//@SpringBootTest -//class LocationRepositoryJDBCTest { -// private JdbcTemplate jdbcTemplate; -// private LocationRepositoryJDBC locationRepositoryJDBC; -// -// private RowMapper<Location> locationMapper; -// -// -// @Autowired -// public void setlocationMapper(){ -// locationMapper = (rs, i) -> new Location( -// -// rs.getString("locationName"), -// rs.getString("locationEmail"), -// rs.getString("locationDescription"), -// rs.getString("locationPlace"), -// rs.getString("locationTrailID"), -// rs.getBoolean("locationApproved") -// ); -// } -// @Autowired -// public void LocationRepositoryJDBC(JdbcTemplate jdbc){ -// this.jdbcTemplate = jdbc; -// locationRepositoryJDBC = new LocationRepositoryJDBC(jdbc); -// } -// -// -// -// -// @Test -// public void test(){ -// -// } -// -// -//} \ No newline at end of file diff --git a/src/test/java/Team5/SmartTownsOld/data/LocationTest.java b/src/test/java/Team5/SmartTownsOld/data/LocationTest.java deleted file mode 100644 index dad4c98b..00000000 --- a/src/test/java/Team5/SmartTownsOld/data/LocationTest.java +++ /dev/null @@ -1,5 +0,0 @@ -package Team5.SmartTownsOld.data; - -class LocationTest { - -} \ No newline at end of file diff --git a/src/test/java/Team5/SmartTownsOld/placeswithcoordinates/PlacesCoordinatesTest.java b/src/test/java/Team5/SmartTownsOld/placeswithcoordinates/PlacesCoordinatesTest.java deleted file mode 100644 index 092d2ba3..00000000 --- a/src/test/java/Team5/SmartTownsOld/placeswithcoordinates/PlacesCoordinatesTest.java +++ /dev/null @@ -1,125 +0,0 @@ -package Team5.SmartTowns.placeswithcoordinates; - -import Team5.SmartTowns.data.Location; -import Team5.SmartTowns.data.LocationRepository; -import org.junit.jupiter.api.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.jdbc.core.JdbcTemplate; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@SpringBootTest -class PlacesCoordinatesTest { - - @Autowired - PlacesCoordinatesRepository placesCoordinatesRepository; - - @Autowired - LocationRepository locationRepository; - - @Autowired - JdbcTemplate jdbcTemplate; - - @BeforeEach - void setUp() { - /* Ensures that each test starts with a clean table*/ - jdbcTemplate.update("DELETE FROM locationCoordinates"); - } - - @AfterEach - void tearDown() { - jdbcTemplate.update("DELETE FROM locationCoordinates"); - } - - @Test - void getAllLocationCoords() { - jdbcTemplate.update("insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (2, 51.57623, -3.21910 )"); - jdbcTemplate.update("insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (3, 51.57623, -3.21910 )"); - jdbcTemplate.update("insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (4, 51.57623, -3.21910 )"); - - List<Long> expected = jdbcTemplate.queryForList("SELECT locationID FROM locationcoordinates", Long.class); - List<LocationsCoordinates> allObjects = placesCoordinatesRepository.getAllLocationCoords(); - assertEquals(expected.size(), allObjects.size()); - assertEquals(expected.get(0), allObjects.get(0).getLocationID()); - assertEquals(expected.get(1), allObjects.get(1).getLocationID()); - assertEquals(expected.get(2), allObjects.get(2).getLocationID()); - } - - @Test - void getAllTownCoords() { - } - - @Test - void addLocationCoord() { - int locationID = 1; - double locationCoordsLat = 1.5; - double locationCoordsLong = 1.5; - placesCoordinatesRepository.addLocationCoord( - new LocationsCoordinates(1, locationCoordsLat, locationCoordsLong) - ); - - double resultLat = jdbcTemplate.queryForObject( - "SELECT locationCoordsLat FROM locationcoordinates WHERE locationID=?", - Double.class, locationID); - double resultLong = jdbcTemplate.queryForObject( - "SELECT locationCoordsLat FROM locationcoordinates WHERE locationID=?", - Double.class, locationID); - - - - assertEquals(locationCoordsLat, resultLat); - assertEquals(locationCoordsLong, resultLong); - } - - - @Test - void getFullApprovedLocations() { - - } - - @Test - void getLocationTableIDValue() { - } - - - @Test - public void nameToLocationIDTest(){ - List<Location> locationList = locationRepository.getAllLocation(); - String firstLocationName=locationList.get(0).getLocationName(); - String lastLocationName=locationList.get(locationList.size()-1).getLocationName(); - int firstLocationID= locationRepository.nametoLocationID(firstLocationName); - int lastLocationID= locationRepository.nametoLocationID(lastLocationName); - // if first and last location are chosen and if SQL ID starts at 1 , while an array index starts at 0, then the following should be equal; - String firstLocationTest=locationList.get(firstLocationID-1).getLocationName(); - String lastLocationTest=locationList.get(lastLocationID-1).getLocationName(); - assertEquals(firstLocationName,firstLocationTest); - assertEquals(lastLocationName,lastLocationTest); - - - } - - @Test // test to see if - public void checkIfCoordsAreWithinTownBoundaryTest(){ - // initiate second instance of location without Caerphilly bounds. - List<Location> locationList = locationRepository.getAllLocation(); - Location unapprovedLocation = new Location("test","test@email","","Caerphilly","102",false); - locationRepository.addLocation(unapprovedLocation); - int newID=locationRepository.nametoLocationID( unapprovedLocation.getLocationName()); - LocationsCoordinates newCoord = new LocationsCoordinates(newID,0.00,0.00); - boolean falseIfOutOfBounds = placesCoordinatesRepository.checkIfCoordsAreWithinTownBoundary(newCoord); - // initiate second instance of location within Caerphilly bounds. - Location unapprovedLocationTwo = new Location("test2","test2@email","","Caerphilly","103",false); - locationRepository.addLocation(unapprovedLocationTwo); - int newIDTwo=locationRepository.nametoLocationID( unapprovedLocationTwo.getLocationName()); - LocationsCoordinates newCoordTwo = new LocationsCoordinates(newIDTwo,51.57903,-3.22075 ); - boolean falseIfOutOfBoundsTwo = placesCoordinatesRepository.checkIfCoordsAreWithinTownBoundary(newCoordTwo); - assertNotEquals(falseIfOutOfBounds,falseIfOutOfBoundsTwo); - - - } - -} \ No newline at end of file diff --git a/src/test/java/Team5/SmartTownsOld/testUsers.java b/src/test/java/Team5/SmartTownsOld/testUsers.java deleted file mode 100644 index 20e9d34e..00000000 --- a/src/test/java/Team5/SmartTownsOld/testUsers.java +++ /dev/null @@ -1,79 +0,0 @@ -package Team5.SmartTownsOld; - -import Team5.SmartTowns.rewards.RewardsRepository; -import Team5.SmartTowns.users.NewUser; -import Team5.SmartTowns.users.User; -import Team5.SmartTowns.users.UserRepository; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -import java.util.ArrayList; -import java.util.List; - -import static junit.framework.TestCase.*; - -@SpringBootTest -public class testUsers { - - - @Autowired - UserRepository userRepository; - @Autowired - RewardsRepository rewardsRepository; - - @Test - public void getAllUsersTest(){ // test if we can get all users, admin is sa known user - List<User> users = userRepository.getAllUsers(); - User user = new User("Admin","Admin"); - Assertions.assertEquals("Admin", users.get(0).getName()); - } - - @Test // test if new users can be added - public void addAUserTest(){ - int userNumberBeforeAdd = userRepository.getAllUsers().size(); - NewUser newuser = new NewUser("Meow","Woof","Cat@Dogs.com"); - boolean trueIfAdded= userRepository.addUser(newuser.getName(), newuser.getEmail(), newuser.getPassword()); - int userNumberAfterAdd = userRepository.getAllUsers().size(); - assertTrue(trueIfAdded); - } - - @Test // test if new users and inserted users can be found - public void doesUserExistTest(){ - Boolean insertedUserFoundByEmail = userRepository.doesUserExist("Kevin@Gmail.com"); - NewUser newuser = new NewUser("MeowMeow","WoofMeow","CatMeow@Dogs.com"); - Boolean newUser = userRepository.addUser(newuser.getName(), newuser.getEmail(), newuser.getPassword()); - Boolean newUserFoundByEmail = userRepository.doesUserExist(newuser.getEmail()); - int compareTwoSearches = Boolean.compare(insertedUserFoundByEmail, newUserFoundByEmail); - assertEquals(0,compareTwoSearches); // if 0, both values are the same - - - } - - @Test - public void canUsersUnlockStickersTest(){ // tests if users can unlock stickers - NewUser newuser = new NewUser("MeowMeowMeow","WoofMeowMeow","CatMeowMeow@Dogs.com"); - Boolean newUser = userRepository.addUser(newuser.getName(), newuser.getEmail(), newuser.getPassword()); - Boolean doesStickerUnlock = userRepository.unlockSticker(newuser.getName(),2,2); - System.out.println(doesStickerUnlock); - assertTrue(doesStickerUnlock); - } - @Test - public void canUsersUnlockStickersAndViewThemTest(){ // tests if users who unlock stickers can view them - NewUser newuser = new NewUser("MeowMeowMeowMeow","WoofMeowMeowMeow","CatMeowMeowMeow@Dogs.com"); - NewUser newuserTwo = new NewUser("Jumper","Baa","Sheep@Wool.com"); - Boolean newUser = userRepository.addUser(newuser.getName(), newuser.getEmail(), newuser.getPassword()); - Boolean newUserTwo = userRepository.addUser(newuserTwo.getName(), newuserTwo.getEmail(), newuserTwo.getPassword()); - Boolean doesStickerUnlock = userRepository.unlockSticker(newuser.getName(),1,2); - List<Long> newUserStickerCollection = userRepository.getUserStickersFromPack(newuser.getName(),1); - List<Long> newUserStickerCollectionTwo = userRepository.getUserStickersFromPack(newuserTwo.getName(),1); // compare and see if only new suer that has unlocked a sticker ahs one in their collection for pack 1 - int newUserStickerList = newUserStickerCollection.size(); - int newUserStickerListTwo = newUserStickerCollectionTwo.size(); // should have different sizes - assertNotSame(newUserStickerList,newUserStickerListTwo); - - } - - -} diff --git a/src/test/java/Test3.java b/src/test/java/Test3.java deleted file mode 100644 index 9c8f681f..00000000 --- a/src/test/java/Test3.java +++ /dev/null @@ -1,27 +0,0 @@ -//import org.junit.jupiter.api.Test; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; -//import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -// -//import javax.sql.DataSource; -// -//import static org.junit.jupiter.api.Assertions.assertEquals; -// -// -//public class Test3 { -// -// @Test -//// test2 -// public void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount1() { -// DataSource dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2) -// .addScript("classpath:schema.sql") -// .addScript("classpath:data.sql") -// .build(); -//// .addScript("classpath:jdbc/test-data.sql") -// -//// LocationRepositoryJDBC employeeDAO = new LocationRepositoryJDBC(); -//// employeeDAO.setDataSource(dataSource); -// -//// assertEquals(4, employeeDAO.getCountOfEmployees());} -// assertEquals(4, 4);} -//} diff --git a/src/test/java/testTwo.java b/src/test/java/testTwo.java deleted file mode 100644 index 225fb287..00000000 --- a/src/test/java/testTwo.java +++ /dev/null @@ -1,52 +0,0 @@ -////package Team5.SmartTowns.data; -// -////import org.junit.platform.commons.util.Preconditions; -//// -//import Team5.SmartTowns.data.Location; -//import Team5.SmartTowns.data.LocationRepository; -//import Team5.SmartTowns.data.LocationRepositoryJDBC; -//import org.junit.jupiter.api.BeforeAll; -//import org.junit.jupiter.api.Test; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.jdbc.core.JdbcTemplate; -//import org.springframework.jdbc.core.RowMapper; -// -//import static org.junit.jupiter.api.Assertions.assertEquals; -// -// -////@SpringBootTest -//public class testTwo { -// -//private JdbcTemplate jdbcTemplate; -//private LocationRepositoryJDBC locationRepositoryJDBC; -// -//private RowMapper<Location> locationMapper; -// -//@Autowired -//private LocationRepository locationRepository; -// -// -//@Autowired -// public void LocationRepositoryJDBC(JdbcTemplate jdbc){ -// this.jdbcTemplate = jdbc; -// locationRepositoryJDBC = new LocationRepositoryJDBC(jdbc); -//} -// -// -//@BeforeAll -//public static void setUp(){ -// locationRepository = new LocationRepositoryJDBC.getAllLocation(); -//// locationRepository = (LocationRepositoryJDBC) locationRepository.getAllLocation(); -//} -// -//@Test -//public void test(){ -// int aa=1; -// assertEquals(1,aa); -// -// } -// -// -// -//} diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 5abd1133..7e648a5a 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -1,7 +1,7 @@ -spring.datasource.url=jdbc:mariadb://localhost:3306/ +spring.datasource.url=jdbc:mariadb://localhost:3306/test_towns?createDatabaseIfNotExist=true spring.datasource.username=root spring.datasource.password=comsc spring.sql.init.mode=always -spring.sql.init.schema-locations=classpath:schema.sql, classpath:schema-test.sql -spring.sql.init.data-locations=classpath:data.sql, classpath:test-data.sql \ No newline at end of file +spring.sql.init.schema-locations=classpath:schema.sql +spring.sql.init.data-locations=classpath:data.sql \ No newline at end of file diff --git a/src/test/resources/data.sql b/src/test/resources/data.sql index c3fa214d..fbc0cd20 100644 --- a/src/test/resources/data.sql +++ b/src/test/resources/data.sql @@ -1,83 +1 @@ -USE test_towns; -INSERT INTO users (username, password) VALUE ('Admin', 'admin'); -INSERT INTO users (username, password) VALUE ('Hannah', 'root'); -INSERT INTO users (username, password) VALUE ('Nigel', 'root'); -INSERT INTO users (username, password) VALUE ('Oscar', 'root'); - -INSERT INTO authorities (username, authority) VALUE ('Admin', 'ADMIN'); -INSERT INTO authorities (username, authority) VALUE ('Hannah', 'USER'); - -# delete from users; -# insert into users (email, name) value ('hannah@gmail.com', 'Hannah'); -# insert into users (email, name) value ('nigel@gmail.com', 'Nigel'); -# -# -# insert into trails ( trailID, trailName, trailNumber) value ( 0101,'Caerphilly Castle Trail','0101'); -# insert into trails ( trailID, trailName, trailNumber) value ( 0102,'Caerphilly Pub Trail','0102'); -# insert into trails ( trailID, trailName, trailNumber) value ( 0103,'Caerphilly Heritage Trail','0103'); -# insert into trails ( trailID, trailName, trailNumber) value ( 0201,'Risca Heritage Trail','0201'); -# insert into trails ( trailID, trailName, trailNumber) value ( 0301,'Penarth Esplanade Trail','0301'); -# -# -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'St Cenydd','','Location description here','Caerphilly',0101, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Castle','','Location description here','Caerphilly',0101, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Medieval Trades','','Location description here','Caerphilly',0101, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Queen''s War','','Location description here','Caerphilly',0101, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Green Lady','','Location description here','Caerphilly',0101, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Armoury','','Location description here','Caerphilly',0101, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Architecture','','Location description here','Caerphilly',0101, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( '21st Century Landmark','','Location description here','Caerphilly',0101, true); -# -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'JD Wetherspoons-Malcolm Uphill','','Location description here','Caerphilly',0102, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Cwtch','','Location description here','Caerphilly',0102, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Conservative Club','','Location description here','Caerphilly',0102, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The King''s Arms','','Location description here','Caerphilly',0102, true); -# -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Bus Station','','Location description here','Caerphilly',0103, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Medieval Courthouse','','Location description here','Caerphilly',0103, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ('Caerphilly Castle','','Location description here','Caerphilly',0103, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Ty Vaughan House','','Location description here','Caerphilly',0103, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Risca Colliery','','Location description here','Risca',0201, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Black Vein Colliery Disaster','','Location description here','Risca',0201, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Esplanade','','Location description here','Penarth',0301, true); -# insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Old Swimming Baths','','Location description here','Penarth',0301, true); -# -# -# -# insert into packs (name, description) value ('Wales Football Team', 'Pack of Welsh Football Players in the National Team'); -# insert into packs (name, description) value ('Wales Rugby Team', 'Pack of Welsh Rugby Players in the National Team'); -# insert into packs (name, description) value ('Welsh Heritage', 'Pack About Welsh Heritage'); -# -# -# -# insert into stickers (packID, stickerID, name, description, rarity) value (1, 1, 'wayne_hennessey', 'Wales Football Team Player', '2'); -# insert into stickers (packID, stickerID, name, description, rarity) value (1, 2, 'neco_williams', 'Wales Football Team Player', '2'); -# insert into stickers (packID, stickerID, name, description, rarity) value (1, 3, 'joe_morrell', 'Wales Football Team Player', '2'); -# insert into stickers (packID, stickerID, name, description, rarity) value (1, 4, 'ethan_ampadu', 'Wales Football Team Player', '2'); -# insert into stickers (packID, stickerID, name, description, rarity) value (1, 5, 'connor_roberts', 'Wales Football Team Player', '2'); -# insert into stickers (packID, stickerID, name, description, rarity) value (2, 1, 'Taine_Basham', 'Wales Rugby Team Player', '1'); -# insert into stickers (packID, stickerID, name, description, rarity) value (2, 2, 'Adam Beard', 'Wales Rugby Team Player', '1'); -# insert into stickers (packID, stickerID, name, description, rarity) value (2, 3, 'Elliot Dee', 'Wales Rugby Team Player', '1'); -# insert into stickers (packID, stickerID, name, description, rarity) value (2, 4, 'Corey Domachowski', 'Wales Rugby Team Player', '1'); -# insert into stickers (packID, stickerID, name, description, rarity) value (2, 5, 'Ryan Elias', 'Wales Rugby Team Player', '1'); -# insert into stickers (packID, stickerID, name, description, rarity) value (3, 1, 'Welsh Lady', 'Welsh Heritage', '1'); -# insert into stickers (packID, stickerID, name, description, rarity) value (3, 2, 'Welsh Outline', 'Welsh Heritage', '1'); -# insert into stickers (packID, stickerID, name, description, rarity) value (3, 3, 'Welsh Spoon', 'Welsh Heritage', '1'); -# -# -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (2, 51.57623, -3.21910 ); -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (3, 51.575372, -3.219186); -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (4, 51.576363, -3.220712 ); -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (9, 51.57239, -3.21992); -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (10, 51.57230, -3.21938 ); -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (13, 51.57168, -3.21861); -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (14, 51.57465, -3.22022 ); -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (17, 51.61117, -3.10198 ); -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (18, 51.61655, -3.12371 ); -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (19, 51.43484, -3.16492 ); -# insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (20, 51.43547, -3.16789 ); -# -# -# insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Caerphilly', '51.57903','-3.22075 ','51.60418','51.55093','-3.25222','-3.17696'); -# insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Risca','51.61195','-3.09648','51.63039','51.59175','-3.12129','-3.06438'); -# insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Penarth','51.43893','-3.17354','51.44878','51.41233','-3.20271','-3.16005'); \ No newline at end of file +/*INSERT INTO users (username, password) VALUE ('Test', 'Test');*/ \ No newline at end of file diff --git a/src/test/resources/schema-test.sql b/src/test/resources/schema-test.sql deleted file mode 100644 index 60304bee..00000000 --- a/src/test/resources/schema-test.sql +++ /dev/null @@ -1,121 +0,0 @@ - - - - -DROP DATABASE IF EXISTS test_towns; -CREATE DATABASE IF NOT EXISTS test_towns; -USE test_towns; -/****************************************************************/ - -/* DROPS ALL TABLES IF THEY EXIST (they wont but just in case) */ - -drop table if exists locationCoordinates; -drop table if exists locations; -drop table if exists trails; -DROP TABLE IF EXISTS users; -DROP TABLE IF EXISTS stickers; -DROP TABLE IF EXISTS packs; -DROP TABLE IF EXISTS stickerProgress; - - - -/****************************************************************/ - -/* CREATES ALL TABLES */ - -create table if not exists trails -( - trailID varchar(128) primary key, - trailName varchar(128), - trailNumber varchar(128) -) engine=InnoDB; - -drop table if exists locationCoordinates; -drop table if exists locations; -create table if not exists locations -( - locationID bigint auto_increment primary key, - locationName varchar(128), - locationEmail varchar(128), - locationDescription longtext, - locationPlace varchar(255), - locationTrailID varchar(128), - locationApproved boolean -) engine=InnoDB; - - -CREATE TABLE IF NOT EXISTS users ( - username varchar(30) primary key NOT NULL, - id bigint auto_increment unique, /*DEPRECATED COLUMN, LEFT IN WHILE SOME OTHER FUNCTIONS STILL USE IT*/ - email varchar(128), - password varchar(30) NOT NULL, - enabled boolean default true -); - -CREATE TABLE IF NOT EXISTS authorities ( - id bigint primary key auto_increment NOT NULL, - username varchar(30) NOT NULL , - authority varchar(45) NOT NULL -); - -CREATE TABLE IF NOT EXISTS packs ( - id bigint auto_increment primary key, - name varchar(20) NOT NULL, - description text -); - -CREATE TABLE IF NOT EXISTS stickers ( - id bigint auto_increment primary key, - packID bigint NOT NULL, - FOREIGN KEY (packID) REFERENCES packs(id) - ON DELETE CASCADE - ON UPDATE RESTRICT, - stickerID bigint NOT NULL, /*STICKER ID NUMBER WITHIN ITS OWN PACK*/ - name varchar(30) NOT NULL, - description text NOT NULL, - rarity tinyint -); -CREATE TABLE IF NOT EXISTS stickerProgress ( - id bigint auto_increment primary key, - username varchar(30) NOT NULL, - FOREIGN KEY (username) REFERENCES users(username) - ON DELETE CASCADE - ON UPDATE RESTRICT, - packID bigint NOT NULL, - FOREIGN KEY (packID) REFERENCES packs(id) - ON DELETE CASCADE - ON UPDATE RESTRICT, - stickerID bigint NOT NULL, - FOREIGN KEY (stickerID) REFERENCES stickers(id) - ON DELETE CASCADE - ON UPDATE RESTRICT -); - -create table if not exists locationCoordinates -( - locationCoordID bigint auto_increment primary key, - locationID bigint, - Foreign Key (locationID) REFERENCES locations(locationID) - ON DELETE CASCADE - ON UPDATE RESTRICT, - locationCoordsLat DECIMAL(8,6), - locationCoordsLong DECIMAL(8,6) - - -)engine=InnoDB; - - -drop table if exists townsWithTrails; -create table if not exists townsWithTrails -( - townID bigint auto_increment primary key, - townName varchar(128), - townCentreCoordsLat varchar(128), - townCentreCoordsLong varchar(128), - townUppermostCoordsLat varchar(128), - townLowermostCoordsLat varchar(128), - townLeftmostCoordsLong varchar(128), - townRightmostCoordsLong varchar(128) - -)engine=InnoDB; - diff --git a/src/test/resources/schema.sql b/src/test/resources/schema.sql index 6bd0ce80..556efd54 100644 --- a/src/test/resources/schema.sql +++ b/src/test/resources/schema.sql @@ -1,8 +1,6 @@ -/* DELETES AND RECREATES DATABASE EVERY TIME THE SYSTEM IS BOOTED*/ DROP DATABASE IF EXISTS test_towns; CREATE DATABASE IF NOT EXISTS test_towns; USE test_towns; -/****************************************************************/ CREATE TABLE IF NOT EXISTS users ( username varchar(30) primary key NOT NULL, @@ -10,113 +8,10 @@ CREATE TABLE IF NOT EXISTS users ( email varchar(128), password varchar(30) NOT NULL, enabled boolean default true -); +)engine=InnoDB; CREATE TABLE IF NOT EXISTS authorities ( id bigint primary key auto_increment NOT NULL, username varchar(30) NOT NULL , authority varchar(45) NOT NULL -); -# drop table if exists locationCoordinates; -# drop table if exists locations; -# drop table if exists trails; -# -# create table if not exists trails -# ( -# trailID varchar(128) primary key, -# trailName varchar(128), -# trailNumber varchar(128) -# ) engine=InnoDB; -# -# -# create table if not exists locations -# ( -# locationID bigint auto_increment primary key, -# locationName varchar(128), -# locationEmail varchar(128), -# locationDescription longtext, -# locationPlace varchar(255), -# locationTrailID varchar(128), -# Foreign Key (locationTrailID) REFERENCES trails(trailID) -# ON DELETE CASCADE -# ON UPDATE RESTRICT, -# locationApproved boolean -# ) engine=InnoDB; -# -# -# drop table if exists users; -# drop table if exists stickers; -# drop table if exists packs; -# drop table if exists stickerProgress; -# -# create table if not exists users -# ( -# id bigint auto_increment primary key, -# email varchar(128), -# name varchar(30), -# dragonProgress int, -# dragonsLandmarkIDs longtext -# ) engine=InnoDB; -# -# -# create table if not exists packs -# ( -# id bigint auto_increment primary key, -# name varchar(20), -# description text -# ) engine=InnoDB; -# -# create table if not exists stickers -# ( -# id bigint auto_increment primary key, -# packID bigint, -# FOREIGN KEY (packID) REFERENCES packs(id) -# ON DELETE CASCADE -# ON UPDATE RESTRICT, -# stickerID bigint, /*STICKER ID NUMBER WITHIN ITS OWN PACK*/ -# name varchar(30), -# description text, -# rarity tinyint -# -# ) engine=InnoDB; -# -# create table if not exists stickerProgress -# ( -# id bigint auto_increment primary key, -# userID bigint, -# stickerID bigint -# ) engine=InnoDB; -# -# -# -# -# -# create table if not exists locationCoordinates -# ( -# locationCoordID bigint auto_increment primary key, -# locationID bigint, -# Foreign Key (locationID) REFERENCES locations(locationID) -# ON DELETE CASCADE -# ON UPDATE RESTRICT, -# locationCoordsLat DECIMAL(8,6), -# locationCoordsLong DECIMAL(8,6) -# -# -# )engine=InnoDB; -# -# -# drop table if exists townsWithTrails; -# create table if not exists townsWithTrails -# ( -# townID bigint auto_increment primary key, -# townName varchar(128), -# townCentreCoordsLat varchar(128), -# townCentreCoordsLong varchar(128), -# townUppermostCoordsLat varchar(128), -# townLowermostCoordsLat varchar(128), -# townLeftmostCoordsLong varchar(128), -# townRightmostCoordsLong varchar(128) -# -# )engine=InnoDB; -# -# +)engine=InnoDB; \ No newline at end of file diff --git a/src/test/resources/test-data.sql b/src/test/resources/test-data.sql deleted file mode 100644 index f2e54301..00000000 --- a/src/test/resources/test-data.sql +++ /dev/null @@ -1,104 +0,0 @@ -# delete from users; -# insert into users (email, name) value ('hannah@gmail.com', 'Hannah'); -# insert into users (email, name) value ('nigel@gmail.com', 'Nigel'); - -delete from trails; -insert into trails ( trailID, trailName, trailNumber) value ( 0101,'Caerphilly Castle Trail','0101'); -insert into trails ( trailID, trailName, trailNumber) value ( 0102,'Caerphilly Pub Trail','0102'); -insert into trails ( trailID, trailName, trailNumber) value ( 0103,'Caerphilly Heritage Trail','0103'); -insert into trails ( trailID, trailName, trailNumber) value ( 0201,'Risca Heritage Trail','0201'); -insert into trails ( trailID, trailName, trailNumber) value ( 0301,'Penarth Esplanade Trail','0301'); - -delete from locations; -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'St Cenydd','','Location description here','Caerphilly',0101, false); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Castle','','Location description here','Caerphilly',0101, true); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Medieval Trades','','Location description here','Caerphilly',0101, true); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Queen''s War','','Location description here','Caerphilly',0101, true); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Green Lady','','Location description here','Caerphilly',0101, false); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Armoury','','Location description here','Caerphilly',0101, false); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Architecture','','Location description here','Caerphilly',0101, false); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( '21st Century Landmark','','Location description here','Caerphilly',0101, false); - -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'JD Wetherspoons-Malcolm Uphill','','Location description here','Caerphilly',0102, true); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Cwtch','','Location description here','Caerphilly',0102, true); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Conservative Club','','Location description here','Caerphilly',0102, false); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The King''s Arms','','Location description here','Caerphilly',0102, false); - -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Bus Station','','Location description here','Caerphilly',0103, true); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Medieval Courthouse','','Location description here','Caerphilly',0103, true); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ('Caerphilly Castle','','Location description here','Caerphilly',0103, false); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Ty Vaughan House','','Location description here','Caerphilly',0103, false); - -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Risca Colliery','','Location description here','Risca',0201, true); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Black Vein Colliery Disaster','','Location description here','Risca',0201, true); - -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Esplanade','','Location description here','Penarth',0301, true); -insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Old Swimming Baths','','Location description here','Penarth',0301, true); - -DELETE FROM locationCoordinates; -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (2, 51.57623, -3.21910 ); -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (3, 51.575372, -3.219186); -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (4, 51.576363, -3.220712 ); -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (9, 51.57239, -3.21992); -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (10, 51.57230, -3.21938 ); -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (13, 51.57168, -3.21861); -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (14, 51.57465, -3.22022 ); -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (17, 51.61117, -3.10198 ); -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (18, 51.61655, -3.12371 ); -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (19, 51.43484, -3.16492 ); -insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (20, 51.43547, -3.16789 ); - -# delete from badges; -# insert into badges (name, description, difficulty) value ('TownConnoisseur', 'You know the town very well!', '2'); -# insert into badges (name, description, difficulty) value ('TownRegular', 'You visited the town 3 days in a row!', '1'); -# insert into badges (name, description, difficulty) value ('TownMaster', 'You visited the town 7 days in a row!', '1'); -# insert into badges (name, description, difficulty) value ('TownRegular', 'You visited the town 3 days in a row!', '1'); -# insert into badges (name, description, difficulty) value ('TownRegular', 'You visited the town 3 days in a row!', '1'); - - - -delete from packs; -insert into packs (name, description) value ('Wales Football Team', 'Pack of Welsh Football Players in the National Team'); -insert into packs (name, description) value ('Wales Rugby Team', 'Pack of Welsh Rugby Players in the National Team'); -insert into packs (name, description) value ('Welsh Heritage', 'Pack About Welsh Heritage'); - - -DELETE FROM stickers; -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 1, 'wayne_hennessey', 'Wales Football Team Player', '2'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 2, 'neco_williams', 'Wales Football Team Player', '2'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 3, 'joe_morrell', 'Wales Football Team Player', '2'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 4, 'ethan_ampadu', 'Wales Football Team Player', '2'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 5, 'connor_roberts', 'Wales Football Team Player', '2'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (2, 1, 'Taine_Basham', 'Wales Rugby Team Player', '1'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (2, 2, 'Adam Beard', 'Wales Rugby Team Player', '1'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (2, 3, 'Elliot Dee', 'Wales Rugby Team Player', '1'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (2, 4, 'Corey Domachowski', 'Wales Rugby Team Player', '1'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (2, 5, 'Ryan Elias', 'Wales Rugby Team Player', '1'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 1, 'Welsh Lady', 'Welsh Heritage', '1'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 2, 'Welsh Outline', 'Welsh Heritage', '1'); -INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 3, 'Welsh Spoon', 'Welsh Heritage', '1'); - -# delete from stickerprogress; -# insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '1', true); -# insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '3', true); -# insert into stickerprogress (userID, stickerID, hasSticker) value ('2', '2', true); - - - - - - -# insert into stickerprogress (userID, packID, stickerID) value (1, 1, 1); -# insert into stickerprogress (userID, packID, stickerID) value (1, 1, 2); -# insert into stickerprogress (userID, packID, stickerID) value (1, 1, 3); -# insert into stickerprogress (userID, packID, stickerID) value (1, 1, 5); -# insert into stickerprogress (userID, packID, stickerID) value (1, 2, 1); -# insert into stickerprogress (userID, packID, stickerID) value (1, 2, 3); - - - -# -delete from townsWithTrails; -insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Caerphilly', '51.57903','-3.22075 ','51.60418','51.55093','-3.25222','-3.17696'); -insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Risca','51.61195','-3.09648','51.63039','51.59175','-3.12129','-3.06438'); -insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Penarth','51.43893','-3.17354','51.44878','51.41233','-3.20271','-3.16005'); \ No newline at end of file -- GitLab