From 36860567b340e3a43c268a2a62a7401fb235d8f0 Mon Sep 17 00:00:00 2001
From: Rhys Evans <EvansRM17@cardiff.ac.uk>
Date: Sun, 18 Feb 2024 18:10:34 +0000
Subject: [PATCH] further testinmg to integhration, unit tests

---
 .../SmartTowns/ContainerMockMVCTests.java     | 161 ++++++++++++++-
 src/test/java/Team5/SmartTowns/DataJPA.java   |  52 +++++
 .../SmartTowns/DatabaseRepositoryTests.java   |  21 +-
 .../SmartTowns/FirefoxDriverPagesTests.java   | 193 +++++++++---------
 .../Team5/SmartTowns/JUnitSimpleTests.java    |  15 +-
 .../SmartTowns/LightweightMockMVCTests.java   |   5 +-
 src/test/resources/data-h2.sql                |   5 +-
 7 files changed, 342 insertions(+), 110 deletions(-)
 create mode 100644 src/test/java/Team5/SmartTowns/DataJPA.java

diff --git a/src/test/java/Team5/SmartTowns/ContainerMockMVCTests.java b/src/test/java/Team5/SmartTowns/ContainerMockMVCTests.java
index 3a858bcc..3f0da3b1 100644
--- a/src/test/java/Team5/SmartTowns/ContainerMockMVCTests.java
+++ b/src/test/java/Team5/SmartTowns/ContainerMockMVCTests.java
@@ -1,11 +1,14 @@
 package Team5.SmartTowns;
 
 import static org.hamcrest.Matchers.containsString;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 
 import Team5.SmartTowns.data.Location;
+import jakarta.servlet.ServletException;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
@@ -19,7 +22,7 @@ import java.util.List;
 
 @SpringBootTest
 @AutoConfigureMockMvc
-@ActiveProfiles("dev") //change to MockDev?
+//@ActiveProfiles("dev") //change to MockDev?
 public class ContainerMockMVCTests {
     @Autowired
     private MockMvc mockMvc;
@@ -56,16 +59,166 @@ public class ContainerMockMVCTests {
 
 
     @Test
-    public void a_testGreeting4() throws Exception {
-        this.mockMvc.perform(get("/mobile-home").with(SecurityMockMvcRequestPostProcessors.user("Admin").roles("ADMIN")))
-                .andDo(print())
+    public void testReviewLandmarkOnlyShowsToAdmins() throws Exception {
+        AssertionError thrown = assertThrows(AssertionError.class , () ->{
+            this.mockMvc.perform(get("/mobile-home").with(SecurityMockMvcRequestPostProcessors.user("user").roles("USER"))).andExpect(status().isOk())
+                    .andExpect(content().string(containsString("Review Landmark!")));;
+        });
+        assertTrue(thrown.getMessage().contains("Expected: a string containing \"Review Landmark!\""));
+
+        this.mockMvc.perform(get("/mobile-home").with(SecurityMockMvcRequestPostProcessors.user("Admin").roles("ADMIN"))).andExpect(status().isOk())
                 .andExpect(content().string(containsString("Review Landmark!")));
+    }
+    @Test
+    public void testAllCaerphillyTrails() throws Exception {
+        this.mockMvc.perform(get("/allTrails-Caerphilly")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Caerphilly Castle Trail")))
+                .andExpect(content().string(containsString("Caerphilly Pub Trail")))
+                .andExpect(content().string(containsString("Caerphilly Heritage Trail")));
+    }
+
+    @Test
+    public void testAllCaerphillyPubTrail() throws Exception {
+
+        this.mockMvc.perform(get("/trails/Caerphilly-Pub-Trail")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Trail Map")))
+                .andExpect(content().string(containsString("Caerphilly Cwtch")))
+                .andExpect(content().string(containsString("https://www.google.com/maps/dir/51.57239,-3.21992/51.57230,-3.21938//@11"))) //checks that href works, hard-coded
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.57239,-3.21992&output=svembed"))) //checks that current map-substitute shows
+                .andExpect(content().string(containsString("JD Wetherspoons-Malcolm Uphill")))
+                .andExpect(content().string(containsString("Caerphilly Cwtch")));
+
+        this.mockMvc.perform(get("/checkpoints/JD-Wetherspoons-Malcolm-Uphill")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("JD Wetherspoons-Malcolm Uphill")))
+                .andExpect(content().string(containsString("Caerphilly")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.57239,-3.21992&amp;hl=en&amp;z=20&amp;output=embed")));
+
+        this.mockMvc.perform(get("/checkpoints/Caerphilly-Cwtch")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Caerphilly Cwtch")))
+                .andExpect(content().string(containsString("Caerphilly")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.5723,-3.21938&amp;hl=en&amp;z=20&amp;output=embed")));
+
+
+    }
+
+    @Test
+    public void testAllRiscaTrails() throws Exception {
+        this.mockMvc.perform(get("/allTrails-Risca")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Risca Heritage Trail")));
+
+
+        this.mockMvc.perform(get("/trails/Risca-Heritage-Trail")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Risca Heritage Trail")))
+                .andExpect(content().string(containsString("Trail Map")))
+                .andExpect(content().string(containsString("https://www.google.com/maps/dir/51.61117,-3.10198/51.61655,-3.12371 //@11z"))) //checks that href works, hard-coded
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.61117,-3.10198&amp;output=svembed"))) //checks that current map-substitute shows
+                .andExpect(content().string(containsString("Risca Colliery")))
+                .andExpect(content().string(containsString("Black Vein Colliery Disaster")));
+
+        this.mockMvc.perform(get("/checkpoints/Risca-Colliery")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Risca Colliery")))
+                .andExpect(content().string(containsString("Risca")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.61117,-3.10198&amp;hl=en&amp;z=20&amp;output=embed")));
+
+        this.mockMvc.perform(get("/checkpoints/Black-Vein-Colliery-Disaster")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Black Vein Colliery Disaster")))
+                .andExpect(content().string(containsString("Risca")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.61655,-3.12371&amp;hl=en&amp;z=20&amp;output=embed")));
 
+    }
+
+    @Test
+    public void testAllPenarthTrails() throws Exception {
+        this.mockMvc.perform(get("/allTrails-Penarth")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Penarth Esplanade Trail")));
+
+
+        this.mockMvc.perform(get("/trails/Penarth-Esplanade-Trail")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Trail Map")))
+                .andExpect(content().string(containsString("Penarth Esplanade Trail")))
+                .andExpect(content().string(containsString("https://www.google.com/maps/dir/51.43484,-3.16492/51.43547,-3.16789//@11z")))// href
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.43484,-3.164928&amp;output=svembed"))) //iframe hard-coded
+                .andExpect(content().string(containsString("The Esplanade")))
+                .andExpect(content().string(containsString("The Old Swimming Baths")));
+
+        this.mockMvc.perform(get("/checkpoints/The-Esplanade")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("The Esplanade")))
+                .andExpect(content().string(containsString("Penarth")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.43484,-3.16492&amp;hl=en&amp;z=20&amp;output=embed")));
+
+        this.mockMvc.perform(get("/checkpoints/The-Old-Swimming-Baths")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("The Old Swimming Baths")))
+                .andExpect(content().string(containsString("Penarth")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.43547,-3.16789&amp;hl=en&amp;z=20&amp;output=embed")));
+
+    }
+
+    @Test
+    public void testAllCaerphillyHeritageTrails() throws Exception {
+        this.mockMvc.perform(get("/trails/Caerphilly-Heritage-Trail")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Trail Map")))
+                .andExpect(content().string(containsString("Caerphilly Heritage Trail")))
+                .andExpect(content().string(containsString("https://www.google.com/maps/dir/51.57168,-3.21861/51.57465,-3.22022//@11z"))) //checks that href works, hard-coded
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.57168,-3.21861&amp;output=svembed"))) //checks that current map-substitute shows
+                .andExpect(content().string(containsString("Caerphilly Bus Station")))
+                .andExpect(content().string(containsString("The Medieval Courthouse")));
+
+        this.mockMvc.perform(get("/checkpoints/Caerphilly-Bus-Station")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Caerphilly Bus Station")))
+                .andExpect(content().string(containsString("Caerphilly")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.57168,-3.21861&amp;hl=en&amp;z=20&amp;output=embed")));
+
+        this.mockMvc.perform(get("/checkpoints/The-Medieval-Courthouse")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("The Medieval Courthouse")))
+                .andExpect(content().string(containsString("Caerphilly")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.57465,-3.22022&amp;hl=en&amp;z=20&amp;output=embed")));
 
     }
 
 
 
+
+    @Test
+    public void testAllCaerphillyCastleTrails() throws Exception {
+        this.mockMvc.perform(get("/trails/Caerphilly-Castle-Trail")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Trail Map")))
+                .andExpect(content().string(containsString("Caerphilly Castle Trail")))
+                .andExpect(content().string(containsString("https://www.google.com/maps/dir/51.57623,-3.21910/51.575372,-3.219186/51.576363,-3.220712//@11z&output=svembed"))) //checks that href works, hard-coded
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.57623,-3.21910&output=svembed"))) //checks that current map-substitute shows
+                .andExpect(content().string(containsString("The Castle")))
+                .andExpect(content().string(containsString("Medieval Trades")))
+                .andExpect(content().string(containsString("The Queen&#39;s War")));//html
+
+        this.mockMvc.perform(get("/checkpoints/The-Castle")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("The Castle")))
+                .andExpect(content().string(containsString("Caerphilly")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.57623,-3.2191&amp;hl=en&amp;z=20&amp;output=embed")));
+
+        this.mockMvc.perform(get("/checkpoints/Medieval-Trades")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("Medieval Trades")))
+                .andExpect(content().string(containsString("Caerphilly")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.575372,-3.219186&amp;hl=en&amp;z=20&amp;output=embed")));
+
+        this.mockMvc.perform(get("/checkpoints/The-Queen's-War")).andExpect(status().isOk())
+                .andExpect(content().string(containsString("The Queen&#39;s War")))
+                .andExpect(content().string(containsString("Caerphilly")))
+                .andExpect(content().string(containsString("Location description here")))
+                .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.576363,-3.220712&amp;hl=en&amp;z=20&amp;output=embed")));
+
+
+    }
+
+    //todo test homepage, reviewpage,
 //    addLocation
 //    locationRepository.getAllUnapprovedLocations()
 //    checkIfCoordsAreWithinTownBoundary
diff --git a/src/test/java/Team5/SmartTowns/DataJPA.java b/src/test/java/Team5/SmartTowns/DataJPA.java
new file mode 100644
index 00000000..56ea4bfa
--- /dev/null
+++ b/src/test/java/Team5/SmartTowns/DataJPA.java
@@ -0,0 +1,52 @@
+//package Team5.SmartTowns;
+//
+//
+//import Team5.SmartTowns.data.Location;
+//import Team5.SmartTowns.data.LocationRepository;
+//import Team5.SmartTowns.data.LocationRepositoryJDBC;
+//import org.junit.jupiter.api.Tag;
+//import org.junit.Test;
+//import org.junit.runner.RunWith;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest;
+//import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
+//import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+//import org.springframework.context.annotation.ComponentScan;
+//import org.springframework.context.annotation.FilterType;
+//import org.springframework.context.annotation.Import;
+//import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+//import org.springframework.data.repository.RepositoryDefinition;
+//import org.springframework.jdbc.core.JdbcTemplate;
+//import org.springframework.stereotype.Repository;
+//import org.springframework.test.context.ContextConfiguration;
+//import org.springframework.test.context.jdbc.Sql;
+//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+//
+//import static org.junit.Assert.assertTrue;
+//import static org.junit.jupiter.api.Assertions.assertFalse;
+//
+////@DataJdbcTest(includeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Repository.class))
+//@Sql({"/schema-h2.sql", "/data-h2.sql"})
+////@EnableJpaRepositories
+////@Import(LocationRepository.class)
+//@DataJpaTest(includeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = LocationRepository.class))
+////@Testcontainers
+//@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
+//public class DataJPA {
+//
+//    @Autowired
+//    private JdbcTemplate jdbcTemplate;
+//
+//    @Autowired
+//    private LocationRepository locationRepo;
+//
+//    @Test
+//    @Tag("locations")
+//    public void locationsCanBeAdded(){
+////        assertFalse(locationRepo.getAllLocation().contains("MockLocation"));
+//        Location location = new Location(1,"MockLocation", "Mock@Test.co.uk",
+//                "MockDescription","MockCaerphilly","99",false);
+//        locationRepo.addLocation(location);
+//        assertTrue(locationRepo.getAllLocation().contains("MockLocation"));
+//    }
+//}
diff --git a/src/test/java/Team5/SmartTowns/DatabaseRepositoryTests.java b/src/test/java/Team5/SmartTowns/DatabaseRepositoryTests.java
index bf5a346b..d21bfb1c 100644
--- a/src/test/java/Team5/SmartTowns/DatabaseRepositoryTests.java
+++ b/src/test/java/Team5/SmartTowns/DatabaseRepositoryTests.java
@@ -26,6 +26,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 import static org.junit.Assert.assertTrue;
 import static org.junit.jupiter.api.Assertions.*;
 
+import java.util.ArrayList;
 import java.util.List;
 //@RunWith(SpringRunner.class)
 //@ContextConfiguration(classes=LocationRepository.class)
@@ -59,10 +60,14 @@ public class DatabaseRepositoryTests {
     @Tag("locations")
     public void locationsCanBeAdded(){
         assertFalse(locationRepo.getAllLocation().contains("MockLocation"));
-        Location location = new Location(1,"MockLocation", "Mock@Test.co.uk",
+        Location location = new Location(9999,"MockLocation", "Mock@Test.co.uk",
                 "MockDescription","MockCaerphilly","99",false);
         locationRepo.addLocation(location);
-        assertTrue(locationRepo.getAllLocation().contains("MockLocation"));
+        List<Location> list = locationRepo.getAllLocation();
+        ArrayList<String> listNames = new ArrayList<>();
+        for (Location loc: list){
+            listNames.add(loc.getLocationName());}
+        assertTrue(listNames.contains("MockLocation"));
     }
 
     @Test
@@ -95,7 +100,8 @@ public class DatabaseRepositoryTests {
         assertFalse(loc.isLocationApproved());
         int DbID=locationRepo.nametoLocationID(loc.getLocationName());
         locationRepo.updateApprovalStatus(DbID);
-        assertTrue(loc.isLocationApproved());
+        Location locUpdated=locationRepo.getAllLocation().get(0); // neeed to recall updated value from db to re-test as true
+        assertTrue(locUpdated.isLocationApproved());
     }
 
 
@@ -120,8 +126,13 @@ public class DatabaseRepositoryTests {
     public void locationCoordsCanBeAdded(){//check
         LocationsCoordinates locPlc=new LocationsCoordinates(1, 51.576,-3.222);
         placesRepo.addLocationCoord(locPlc);
-        System.out.println(placesRepo.getAllLocationCoords());
-        assertEquals((placesRepo.getAllLocationCoords().get(placesRepo.getAllLocationCoords().size()-1).getLocationID()),(locPlc.getLocationID()));
+        List<LocationsCoordinates> list = placesRepo.getAllLocationCoords();
+        ArrayList<Integer> locCoordIdFK = new ArrayList<>();
+        for (LocationsCoordinates locC: list ){
+            locCoordIdFK.add(locC.getLocationID());}
+        assertTrue(locCoordIdFK.contains(locPlc.getLocationID()));
+
+//        assertEquals((placesRepo.getAllLocationCoords().get(placesRepo.getAllLocationCoords().size()-1).getLocationID()),(locPlc.getLocationID()));
 
     }
 
diff --git a/src/test/java/Team5/SmartTowns/FirefoxDriverPagesTests.java b/src/test/java/Team5/SmartTowns/FirefoxDriverPagesTests.java
index ee839736..4917eb81 100644
--- a/src/test/java/Team5/SmartTowns/FirefoxDriverPagesTests.java
+++ b/src/test/java/Team5/SmartTowns/FirefoxDriverPagesTests.java
@@ -83,8 +83,9 @@ public class FirefoxDriverPagesTests {
 //test false entries, log ina dn log out?, test Risca and Penarth at least once
 
     @Test
-   @DirtiesContext
+    @DirtiesContext
     @Order(1)
+    @Tag("verification")
     public void testingLandmarkSubmissionErrorAlertsShow(){
         this.webDriver.get("http://localhost:" + Integer.toString(port) + "/landmarkSubmission");
         //check error messages aren't showing straight away
@@ -158,6 +159,7 @@ public class FirefoxDriverPagesTests {
     @Test
     @DirtiesContext(methodMode = DirtiesContext.MethodMode.AFTER_METHOD)
     @Order(2)
+    @Tag("verification")
     public void testingAdminAcceptanceForm(){
         this.webDriver.get("http://localhost:" + Integer.toString(port) + "/login");
         this.webDriver.findElement(By.xpath("/html/body/main/div/div[2]/form/label[1]/input")).sendKeys("Admin");
@@ -194,98 +196,107 @@ public class FirefoxDriverPagesTests {
     }
 
 
-@Test
-@DirtiesContext
-@Order(3)
-public void testingEntireFeature(){
-        //homePage
-    //todo error if submitted location same as approved location(*in trail) and submitted on approvalform
-    this.webDriver.get("http://localhost:" + Integer.toString(port) + "/mobile-home");
-    assertTrue(webDriver.findElement(By.cssSelector("main")).getText().contains("Welcome to VZTA Smart Towns!"));
-    assertTrue(webDriver.findElements(By.xpath("/html/body/main/div[1]/a[1]/button")).size() > 0);
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/div[1]/a[1]/button")).getText().contains("Submit Landmark"));
-    this.webDriver.findElement(By.xpath("/html/body/main/div[1]/a[1]/button")).click();
-    //Landmark Sign Up Form
-    assertTrue(webDriver.findElement(By.cssSelector("main form h1")).getText().contains("Interested in joining our trails? Sign up Here!"));
-    this.webDriver.findElement(By.name("landmarkName")).sendKeys("MockLocation");
-    this.webDriver.findElement(By.name("landmarkEmail")).sendKeys("MockAddress@Contact.co.uk");
-    this.webDriver.findElement(By.name("landmarkDescription")).sendKeys("This is a mock description of this business.");
-    new Select(this.webDriver.findElement(By.name("landmarkLocation"))).selectByVisibleText("Caerphilly");
-    new Select(this.webDriver.findElement(By.name("trailID"))).selectByVisibleText("(Caerphilly) Heritage Trail");
-    assertTrue(webDriver.findElement(By.cssSelector("main form ")).getText().contains("Submit"));
-    assertTrue(webDriver.findElements(By.xpath("/html/body/main/form/button")).size() > 0);
-    this.webDriver.findElement(By.xpath("/html/body/main/form/button")).click();
-    //return to home page
-    assertTrue(webDriver.findElement(By.cssSelector("main div")).getText().contains("Welcome to VZTA Smart Towns!"));
-    assertFalse(webDriver.findElement(By.cssSelector("main div")).getText().contains("Review Landmark!"));
-    //Log In as Administrator (This user-feature is not what's being tested, as such it won't be covered apart from here)
-    assertTrue(webDriver.findElement(By.cssSelector("header nav")).getText().contains("Log In"));
-    assertTrue(webDriver.findElement(By.xpath("/html/body/header/nav/ul/li[4]")).getText().contains("Log In"));
-//    assertEquals(webDriver.findElement(By.xpath("/html/body/header/nav/ul/li[4]")).getAttribute("href"),("localhost:" + Integer.toString(port) + "/login"));
-    assertTrue(webDriver.findElements(By.xpath("/html/body/header/nav/ul/li[4]")).size() > 0);
-    this.webDriver.findElement(By.xpath("/html/body/header/nav/ul/li[4]/a")).click();
-
-    //sign in
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/div/div[2]/h1")).getText().contains("Sign In"));
-    this.webDriver.findElement(By.xpath("/html/body/main/div/div[2]/form/label[1]/input")).sendKeys("Admin");
-    this.webDriver.findElement(By.xpath("/html/body/main/div/div[2]/form/label[2]/input")).sendKeys("admin");
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/div/div[2]/form/button")).getText().contains("SIGN IN"));
-    assertTrue(webDriver.findElements(By.xpath("/html/body/main/div/div[2]/form/button")).size() > 0);
-    this.webDriver.findElement(By.xpath("/html/body/main/div/div[2]/form/button")).click();
-
-    //check review shows for admin
-    assertTrue(webDriver.findElement(By.cssSelector("main div")).getText().contains("Review Landmark!"));
-    assertTrue(webDriver.findElements(By.xpath("/html/body/main/div[1]/a[2]")).size() > 0);
-    this.webDriver.findElement(By.xpath("/html/body/main/div[1]/a[2]")).click();
-
-
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/section/h2")).getText().contains("To Be Approved"));
-    assertTrue(webDriver.findElement(By.cssSelector("main h1")).getText().contains("Locations To Be Approved:"));
-//todo FIX THIS!!
-    assertTrue(webDriver.findElement(By.cssSelector("main table tbody ")).getText().contains("MockLocation (103)"));
-    assertTrue(webDriver.findElement(By.cssSelector("main section table tbody")).getText().contains("MockAddress@Contact.co.uk"));
-    assertTrue(webDriver.findElement(By.cssSelector("main section table tbody")).getText().contains("This is a mock description of this business."));
-    //Can't test Caerphilly;ly as others already there todo? look into Risca
-    //todo test verification of this form
-    //<!--            values used to be 0103, 0102, intro error becuase the trailnamefromid trailRepoJDBC used string valeus to search DB and not ints
-    new Select(this.webDriver.findElement(By.name("locationName"))).selectByVisibleText("MockLocation (103)");
-    this.webDriver.findElement(By.name("locationCoordsLat")).sendKeys("51.57815");
-    this.webDriver.findElement(By.name("locationCoordsLong")).sendKeys("-3.22510");
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/form/button")).getText().contains("Submit"));
-    assertTrue(webDriver.findElements(By.xpath("/html/body/main/form/button")).size() > 0);
-    this.webDriver.findElement(By.xpath("/html/body/main/form/button")).click();
-    //back to home, check approved variable is gone from approval screen
-    assertTrue(webDriver.findElement(By.cssSelector("main")).getText().contains("Welcome to VZTA Smart Towns!"));
-    this.webDriver.findElement(By.xpath("/html/body/main/div[1]/a[2]")).click();
-    assertFalse(webDriver.findElement(By.cssSelector("main table")).getText().contains("MockLocation (103)"));
-    //go back to hiome following header
-    assertTrue(webDriver.findElement(By.xpath("/html/body/header/nav/ul/li[1]")).getText().contains("Home"));
-    assertTrue(webDriver.findElements(By.xpath("/html/body/header/nav/ul/li[1]")).size() > 0); //todo fix tghis bit
-    this.webDriver.findElement(By.xpath("/html/body/header/nav/ul/li[1]/a")).click();
-    assertTrue(webDriver.findElement(By.cssSelector("main")).getText().contains("Welcome to VZTA Smart Towns!")); // back home here
-    //check town is there, click to go to trails page
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/div[1]/h2")).getText().contains("Caerphilly"));
-    assertTrue(webDriver.findElements(By.xpath("/html/body/main/article/div[1]/a")).size() > 0);
-    this.webDriver.findElement(By.xpath("/html/body/main/article/div[1]/a")).click();
-    // check path is in towns trails page
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/section/a[3]/h1")).getText().contains("Caerphilly Heritage Trail"));
-    assertTrue(webDriver.findElements(By.xpath("/html/body/main/section/a[3]")).size() > 0);
-    this.webDriver.findElement(By.xpath("/html/body/main/section/a[3]")).click();
-
-    //Trail-list page test
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/article[1]")).getText().contains("Caerphilly Heritage Trail"));
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/article[1]/h3")).getText().contains("Checkpoints"));
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/article[1]")).getText().contains("MockLocation"));
-    assertTrue(webDriver.findElements(By.xpath("//a[text()='MockLocation']")).size() > 0); //tests MockLocation html name is there
-    this.webDriver.findElement(By.xpath("//a[text()='MockLocation']")).click();
-    //Trail-location page test
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/h1")).getText().contains("MockLocation"));
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/h4")).getText().contains("Caerphilly"));
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/p")).getText().contains("This is a mock description of this business."));
-    assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/iframe")).getAttribute("src").contains("https://maps.google.com/maps?q=51.57815,-3.2251&hl=en&z=20&output=embed"));
+    @Test
+    @DirtiesContext
+    @Order(3)
+    @Tag("full")
+    public void testingEntireFeature(){
+            //homePage
+        //todo error if submitted location same as approved location(*in trail) and submitted on approvalform
+        this.webDriver.get("http://localhost:" + Integer.toString(port) + "/mobile-home");
+        assertTrue(webDriver.findElement(By.cssSelector("main")).getText().contains("Welcome to VZTA Smart Towns!"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/main/div[1]/a[1]/button")).size() > 0);
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/div[1]/a[1]/button")).getText().contains("Submit Landmark"));
+        this.webDriver.findElement(By.xpath("/html/body/main/div[1]/a[1]/button")).click();
+        //Landmark Sign Up Form
+        assertTrue(webDriver.findElement(By.cssSelector("main form h1")).getText().contains("Interested in joining our trails? Sign up Here!"));
+        this.webDriver.findElement(By.name("landmarkName")).sendKeys("MockLocation");
+        this.webDriver.findElement(By.name("landmarkEmail")).sendKeys("MockAddress@Contact.co.uk");
+        this.webDriver.findElement(By.name("landmarkDescription")).sendKeys("This is a mock description of this business.");
+        new Select(this.webDriver.findElement(By.name("landmarkLocation"))).selectByVisibleText("Caerphilly");
+        new Select(this.webDriver.findElement(By.name("trailID"))).selectByVisibleText("(Caerphilly) Heritage Trail");
+        assertTrue(webDriver.findElement(By.cssSelector("main form ")).getText().contains("Submit"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/main/form/button")).size() > 0);
+        this.webDriver.findElement(By.xpath("/html/body/main/form/button")).click();
+        //return to home page
+        assertTrue(webDriver.findElement(By.cssSelector("main div")).getText().contains("Welcome to VZTA Smart Towns!"));
+        assertFalse(webDriver.findElement(By.cssSelector("main div")).getText().contains("Review Landmark!"));
+        //Log In as Administrator (This user-feature is not what's being tested, as such it won't be covered apart from here)
+        assertTrue(webDriver.findElement(By.cssSelector("header nav")).getText().contains("Log In"));
+        assertTrue(webDriver.findElement(By.xpath("/html/body/header/nav/ul/li[4]")).getText().contains("Log In"));
+    //    assertEquals(webDriver.findElement(By.xpath("/html/body/header/nav/ul/li[4]")).getAttribute("href"),("localhost:" + Integer.toString(port) + "/login"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/header/nav/ul/li[4]")).size() > 0);
+        this.webDriver.findElement(By.xpath("/html/body/header/nav/ul/li[4]/a")).click();
+
+        //sign in
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/div/div[2]/h1")).getText().contains("Sign In"));
+        this.webDriver.findElement(By.xpath("/html/body/main/div/div[2]/form/label[1]/input")).sendKeys("Admin");
+        this.webDriver.findElement(By.xpath("/html/body/main/div/div[2]/form/label[2]/input")).sendKeys("admin");
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/div/div[2]/form/button")).getText().contains("SIGN IN"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/main/div/div[2]/form/button")).size() > 0);
+        this.webDriver.findElement(By.xpath("/html/body/main/div/div[2]/form/button")).click();
 
+        //check review shows for admin
+        assertTrue(webDriver.findElement(By.cssSelector("main div")).getText().contains("Review Landmark!"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/main/div[1]/a[2]")).size() > 0);
+        this.webDriver.findElement(By.xpath("/html/body/main/div[1]/a[2]")).click();
+
+
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/section/h2")).getText().contains("To Be Approved"));
+        assertTrue(webDriver.findElement(By.cssSelector("main h1")).getText().contains("Locations To Be Approved:"));
+    //todo FIX THIS!!
+        assertTrue(webDriver.findElement(By.cssSelector("main table tbody ")).getText().contains("MockLocation (103)"));
+        assertTrue(webDriver.findElement(By.cssSelector("main section table tbody")).getText().contains("MockAddress@Contact.co.uk"));
+        assertTrue(webDriver.findElement(By.cssSelector("main section table tbody")).getText().contains("This is a mock description of this business."));
+        //Can't test Caerphilly;ly as others already there todo? look into Risca
+        //todo test verification of this form
+        //<!--            values used to be 0103, 0102, intro error becuase the trailnamefromid trailRepoJDBC used string valeus to search DB and not ints
+        new Select(this.webDriver.findElement(By.name("locationName"))).selectByVisibleText("MockLocation (103)");
+        this.webDriver.findElement(By.name("locationCoordsLat")).sendKeys("51.57815");
+        this.webDriver.findElement(By.name("locationCoordsLong")).sendKeys("-3.22510");
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/form/button")).getText().contains("Submit"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/main/form/button")).size() > 0);
+        this.webDriver.findElement(By.xpath("/html/body/main/form/button")).click();
+        //back to home, check approved variable is gone from approval screen
+        assertTrue(webDriver.findElement(By.cssSelector("main")).getText().contains("Welcome to VZTA Smart Towns!"));
+        this.webDriver.findElement(By.xpath("/html/body/main/div[1]/a[2]")).click();
+        assertFalse(webDriver.findElement(By.cssSelector("main table")).getText().contains("MockLocation (103)"));
+        //go back to hiome following header
+        assertTrue(webDriver.findElement(By.xpath("/html/body/header/nav/ul/li[1]")).getText().contains("Home"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/header/nav/ul/li[1]")).size() > 0); //todo fix tghis bit
+        this.webDriver.findElement(By.xpath("/html/body/header/nav/ul/li[1]/a")).click();
+        assertTrue(webDriver.findElement(By.cssSelector("main")).getText().contains("Welcome to VZTA Smart Towns!")); // back home here
+        //check town is there, click to go to trails page
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/div[1]/h2")).getText().contains("Caerphilly"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/main/article/div[1]/a")).size() > 0);
+        this.webDriver.findElement(By.xpath("/html/body/main/article/div[1]/a")).click();
+        // check path is in towns trails page
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/section/a[3]/h1")).getText().contains("Caerphilly Heritage Trail"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/main/section/a[3]")).size() > 0);
+        this.webDriver.findElement(By.xpath("/html/body/main/section/a[3]")).click();
+
+        //Trail-list page test
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article[1]")).getText().contains("Caerphilly Heritage Trail"));
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article[1]/h3")).getText().contains("Checkpoints"));
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article[1]")).getText().contains("MockLocation"));
+        assertTrue(webDriver.findElements(By.xpath("//a[text()='MockLocation']")).size() > 0); //tests MockLocation html name is there
+        this.webDriver.findElement(By.xpath("//a[text()='MockLocation']")).click();
+        //Trail-location page test
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/h1")).getText().contains("MockLocation"));
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/h4")).getText().contains("Caerphilly"));
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/p")).getText().contains("This is a mock description of this business."));
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/iframe")).getAttribute("src").contains("https://maps.google.com/maps?q=51.57815,-3.2251&hl=en&z=20&output=embed"));
+        //return to home works
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article/h2/a")).getText().contains("Return"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/main/article/h2/a")).size() > 0);
+        this.webDriver.findElement(By.xpath("/html/body/main/article/h2/a")).click();
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article[1]")).getText().contains("Caerphilly Heritage Trail"));
+        assertTrue(webDriver.findElement(By.xpath("/html/body/main/article[2]/h2/a")).getText().contains("Home"));
+        assertTrue(webDriver.findElements(By.xpath("/html/body/main/article[2]/h2/a")).size() > 0);
+        this.webDriver.findElement(By.xpath("/html/body/main/article[2]/h2/a")).click();
+        assertTrue(webDriver.findElement(By.cssSelector("main div")).getText().contains("Welcome to VZTA Smart Towns!"));
 
 
 
-}
+    }
 }
diff --git a/src/test/java/Team5/SmartTowns/JUnitSimpleTests.java b/src/test/java/Team5/SmartTowns/JUnitSimpleTests.java
index 2c889d97..0242d1f2 100644
--- a/src/test/java/Team5/SmartTowns/JUnitSimpleTests.java
+++ b/src/test/java/Team5/SmartTowns/JUnitSimpleTests.java
@@ -8,10 +8,7 @@ import Team5.SmartTowns.placeswithcoordinates.PlacesController;
 import Team5.SmartTowns.placeswithcoordinates.TownWithTrails;
 import jakarta.validation.Path;
 import jakarta.validation.constraints.AssertTrue;
-import org.junit.jupiter.api.MethodOrderer;
-import org.junit.jupiter.api.Order;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.jupiter.api.*;
 //import org.junit.platform.engine.support.hierarchical.Node;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
@@ -36,7 +33,9 @@ public class JUnitSimpleTests {
     private final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
 
     @Test
-public void landmarkJakartaValidationTest() {
+    @Tag("landmark")
+    @Tag("validation")
+    public void landmarkJakartaValidationTest() {
         Landmarks landmark = new Landmarks("99", 1, "MockLandmark", "Mock@Mock2.com",
                 "MockLandmarkDesc", "MockRisca", "MockImage");
         Set<ConstraintViolation<Landmarks>> violations = validator.validate(landmark);
@@ -79,6 +78,7 @@ public void landmarkJakartaValidationTest() {
 
     @Test
     @Order(1)
+    @Tag("landmark")
     public void landmarksTest(){ // generic for all landmarks, trails+dragons tale
         Landmarks landmark = new Landmarks("99",1,"MockLandmark","Mock@Mock2.com",
                 "MockLandmarkDesc","MockRisca","MockImage");
@@ -109,6 +109,7 @@ public void landmarkJakartaValidationTest() {
 
     @Test
     @Order(2)
+    @Tag("locations")
     public void locationsTest(){ //specific for trail locations
         Location location = new Location(1,"MockLocation", "Mock@Test.co.uk",
                 "MockDescription","MockCaerphilly","99",false);
@@ -145,6 +146,7 @@ public void landmarkJakartaValidationTest() {
 
     @Test
     @Order(3)
+    @Tag("locationCoordinates")
     public void locationsCoordinatesTest(){
         LocationsCoordinates locCoord = new LocationsCoordinates(1,51.57756,-3.22002);
         assertEquals(locCoord.getLocationID(),1);
@@ -160,6 +162,7 @@ public void landmarkJakartaValidationTest() {
     }
 
     @Test
+    @Tag("trails")
     public void trailTest(){
         Trail trail = new Trail(101L, "MockTrail", "0101");
         assertEquals(trail.getTrailsId(),101);
@@ -179,6 +182,7 @@ public void landmarkJakartaValidationTest() {
 
 
     @Test
+    @Tag("towns")
     public void townWithTrailsTest(){
         TownWithTrails townTrail = new TownWithTrails("MockCaerphilly","51.57903","-3.22075",
                 "51.60418", "51.55093", "-3.25222", "-3.17696");
@@ -210,6 +214,7 @@ public void landmarkJakartaValidationTest() {
 
     @Test
     @Order(4)
+    @Tag("locationCoordinates")
     public void reorderingLocationCoordsListToMatchIDWithLocationListTest(){
         List<Location> locList = new ArrayList<>(); /// trail location list, w/ ID as expected from DB output
         locList.add(new Location(1,"MockLocation", "Mock@Test.co.uk",
diff --git a/src/test/java/Team5/SmartTowns/LightweightMockMVCTests.java b/src/test/java/Team5/SmartTowns/LightweightMockMVCTests.java
index 21b7d839..65ca7edc 100644
--- a/src/test/java/Team5/SmartTowns/LightweightMockMVCTests.java
+++ b/src/test/java/Team5/SmartTowns/LightweightMockMVCTests.java
@@ -170,8 +170,9 @@ public class LightweightMockMVCTests {
         this.mockMvc.perform(get("/trails/Caerphilly-Castle-Trail")).andDo(print()).andExpect(status().isOk())
                 .andExpect(content().string(containsString("Caerphilly Castle Trail"))) //tests that trail name loads correctly
                 .andExpect(content().string(containsString("MockLocation"))) // checks fake trail-location loads correctly
-                .andExpect(content().string(containsString("https://www.google.com/maps/dir/51.57623,-3.21910/51.575372,-3.219186/51.576363,-3.220712//@11z&output=svembed"))) //checks that href works
+                .andExpect(content().string(containsString("https://www.google.com/maps/dir/51.57623,-3.21910/51.575372,-3.219186/51.576363,-3.220712//@11z&output=svembed"))) //checks that href works, hard-coded
                 .andExpect(content().string(containsString("https://maps.google.com/maps?q=51.57623,-3.21910&output=svembed"))); //checks that current map-substitute shows
+
     }
 
 
@@ -189,7 +190,7 @@ public class LightweightMockMVCTests {
         Trail trail = new Trail(99L, "MockLocation","0099");
 
         String mock= "MockLocation";
-        given(this.trailsRepo.getTrailNameWithID("99")).willReturn(mock);
+        given(this.trailsRepo.getTrailNameWithID("99")).willReturn(mock);//todo return trrail.getname?
         this.mockMvc.perform(get("/checkpoints/MockLocation")).andDo(print()).andExpect(status().isOk())
                 .andExpect(content().string(containsString("MockLocation"))) //checks mock-lkocation name is showing
                 .andExpect(content().string(containsString("MockDescription"))) //checks description shows
diff --git a/src/test/resources/data-h2.sql b/src/test/resources/data-h2.sql
index 0cfd02b8..a9adc25f 100644
--- a/src/test/resources/data-h2.sql
+++ b/src/test/resources/data-h2.sql
@@ -39,7 +39,6 @@ insert into locations ( locationName , locationEmail,locationDescription,locatio
 
 
 
-
 DELETE FROM packs;
 INSERT INTO packs (name, description) VALUES ('Wales Football Team', 'Pack of Welsh Football Players in the National Team');
 INSERT INTO packs (name, description) VALUES ('Wales Rugby Team', 'Pack of Welsh Rugby Players in the National Team');
@@ -92,12 +91,12 @@ insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong
 insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) values ('Penarth','51.43893','-3.17354','51.44878','51.41233','-3.20271','-3.16005');
 
 INSERT INTO users (username, password) VALUES ('Admin', 'admin');
-INSERT INTO users (username, password) VALUES ('Hannah', 'root');
+INSERT INTO users (username, password) VALUES ('user', 'root');
 INSERT INTO users (username, password) VALUES ('Nigel', 'root');
 INSERT INTO users (username, password) VALUES ('Oscar', 'root');
 
 INSERT INTO authorities (username, authority) VALUES ('Admin', 'ADMIN');
-INSERT INTO authorities (username, authority) VALUES ('Hannah', 'USER');
+INSERT INTO authorities (username, authority) VALUES ('user', 'USER');
 
 
 
-- 
GitLab