Skip to content
Snippets Groups Projects
Commit 2fd0f99d authored by Rhys Evans's avatar Rhys Evans
Browse files

Added further testing, return buttons to lcoations pages and map alternative button

parent 9356db39
1 merge request!40Resolve "As a user I would like to see a map containing all landmarks for a trail and a suggested path between them, so that I can easily follow the trail"
......@@ -5,4 +5,5 @@ import java.util.List;
public interface TrailsRepository {
List<Trail> getAllTrails();
String getTrailNameWithID(String trailsID);
}
......@@ -26,4 +26,14 @@ public class TrailsRepositoryJDBC implements TrailsRepository {
String sql= "SELECT * FROM trails";
return jdbc.query(sql, trailMapper);
}
@Override
public String getTrailNameWithID(String trailsID){
String resultName = jdbc.queryForObject(
"SELECT trailName FROM trails WHERE trailID=?", String.class, trailsID);
return resultName;
}
}
......@@ -59,14 +59,19 @@ public class PlacesController {
public ModelAndView getResultBySearchKeyLocation(@PathVariable String location) {
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<Location> approvedLocations = locationRepo.getAllApprovedLocations();
int locationID = 999;
for (int i=0;i<approvedLocations.size();i++){
if ( (approvedLocations.get(i).getLocationName().replace(' ', '-').trim().equals(location)) ){
locationID= i;
}
}
String trailName=trailsRepo.getTrailNameWithID(approvedLocations.get(locationID).getLocationTrailID()).replace(' ', '-').trim();
System.out.println(trailName);
ModelAndView modelAndView= new ModelAndView("fragments/locationPageFrags :: locationSection");
modelAndView.addObject("locCoord", locCoords.get(locationID));
modelAndView.addObject("trail", trailName);
modelAndView.addObject("location", approvedLocations.get(locationID));
return modelAndView;
}
......
......@@ -14,6 +14,9 @@
color: wheat;
}
#return{
padding-bottom: 10px;
}
iframe{
margin-top: 20px;
margin-bottom: 60px;
......
......@@ -28,6 +28,8 @@
marginwidth="0"
th:src="'https://maps.google.com/maps?q='+ ${locCoord.getLocationCoordsLat()} +','+ ${locCoord.getLocationCoordsLong()} +'&hl=en&z=20&amp;output=embed'">
</iframe>
<H2 id="return">
<a th:href="@{'/trails/'+${trail}}">Return</a></H2>
</article>
<hr style="height:40px; visibility:hidden;" />
......
......@@ -28,6 +28,7 @@
marginwidth="0"
src="https://www.google.com/maps/dir/51.57623,-3.21910/51.575372,-3.219186/51.576363,-3.220712//@11z">
</iframe>
<div><a href="https://www.google.com/maps/dir/51.57623,-3.21910/51.575372,-3.219186/51.576363,-3.220712//@11z">Trail Map</a></div>
</div>
......@@ -41,6 +42,7 @@
marginwidth="0"
th:src="'https://www.google.com/maps/dir/51.57239,-3.21992/51.57230,-3.21938//@&hl=en&z=20&amp;output=embed'">
</iframe>
<div><a href="https://www.google.com/maps/dir/51.57239,-3.21992/51.57230,-3.21938//@11z">Trail Map</a></div>
</div>
<div th:if="*{trail.getTrailName()=='Caerphilly Heritage Trail'}">
......@@ -53,6 +55,8 @@
marginwidth="0"
th:src="'https://www.google.com/maps/dir/51.57168,-3.21861/51.57465,-3.22022//@11z'">
</iframe>
<div>
<a href="https://www.google.com/maps/dir/51.57168,-3.21861/51.57465,-3.22022//@11z">Trail Map</a></div>
</div>
<div th:if="*{trail.getTrailName()=='Risca Heritage Trail'}">
......@@ -65,7 +69,7 @@
marginwidth="0"
th:src="'https://www.google.com/maps/dir/51.61117,-3.10198/51.61655,-3.12371 //@11z'">
</iframe>
<div><a href="https://www.google.com/maps/dir/51.61117,-3.10198/51.61655,-3.12371 //@11z">Trail Map</a></div>
</div>
<div th:if="*{trail.getTrailName()=='Penarth Esplanade Trail'}">
<iframe
......@@ -77,14 +81,16 @@
marginwidth="0"
th:src="'https://www.google.com/maps/dir/51.43484,-3.16492/51.43547,-3.16789//@11z'">
</iframe>
<div>
<a href="https://www.google.com/maps/dir/51.43484,-3.16492/51.43547,-3.16789//@11z">Trail Map</a>
</div>
</div>
<H3>Checkpoints:</H3>
<!-- With the trial name, we go through locations list to get -->
<div th:each="locationCoord, indexValue:${locCoords}" >
<div th:if="${locations[indexValue.index].getLocationTrailID()==trail.getTrailsId()}">
<li id="checkpointList">
<a th:href="'/checkpoints/'+${locations[indexValue.index].getLocationName().replace(' ', '-')}" th:text="${locations[indexValue.index].getLocationName()}"></a>
<div><a th:href="'/checkpoints/'+${locations[indexValue.index].getLocationName().replace(' ', '-')}" th:text="${locations[indexValue.index].getLocationName()}"></a></div>
<ul></ul>
</li>
......
......@@ -3,6 +3,7 @@ package Team5.SmartTowns;
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;
......@@ -25,6 +26,8 @@ import static org.junit.jupiter.api.Assertions.assertSame;
@SpringBootTest
public class LocationRepositoryTest {
@Autowired
TrailsRepository trailsRepo;
@Autowired
LocationRepository locationRepository;
......
package Team5.SmartTowns;
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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment