Skip to content
Snippets Groups Projects
Commit f658b806 authored by Connor Brock's avatar Connor Brock
Browse files

Merge branch...

Merge branch '82-as-a-site-admininstrator-i-want-to-be-able-to-review-submited-trail-checkpoints-by-bussiness' into 'main'

Resolve "As a site administrator I want to be able to review submitted trail checkpoints by business owners, so that they might be added to the existing trails

Closes #82

See merge request !42
parents 6a4491e8 769cca5e
Branches
No related tags found
1 merge request!42Resolve "As a site administrator I want to be able to review submitted trail checkpoints by business owners, so that they might be added to the existing trails
Showing
with 366 additions and 33 deletions
......@@ -8,8 +8,11 @@ public interface LocationRepository {
List<Location> getAllLocation();
void addLocation(Location loc);
void updateApprovalStatus(int locID);
List<Location> getAllApprovedLocations();
int nametoLocationID(String name);
// List<Location> getApprovedLocations2(List<Location> list);
......
......@@ -121,6 +121,18 @@ public class LocationRepositoryJDBC implements LocationRepository {
// } return locationUnapprovedList;
// }
@Override
public int nametoLocationID(String name){
return jdbc.queryForObject("SELECT locationID FROM locations WHERE locationName=?", Integer.class, name);
}
@Override
public void updateApprovalStatus(int locID){
String updateSql = "update locations set locationApproved = true where locationID = ?";
jdbc.update(updateSql, locID);
}
// return jdbc.queryForObject("SELECT locationApproval FROM locations WHERE locationName=?", locationID);
// public JdbcTemplate getJdbc() {
// return jdbc;
......
......@@ -2,6 +2,8 @@ package Team5.SmartTowns.landmarks;
import Team5.SmartTowns.data.Location;
import Team5.SmartTowns.data.LocationRepository;
import Team5.SmartTowns.placeswithcoordinates.LocationsCoordinates;
import Team5.SmartTowns.placeswithcoordinates.PlacesCoordinatesRepository;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -11,14 +13,16 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
//import jakarta.validation.Valid;
@Controller
public class LandmarksController {
// Controllers for LandmarkFormTh.html landmark submission form
// Controllers for LandmarkFormTh.html landmark submission form
@GetMapping("/landmarkSubmission")
public ModelAndView landmarkSubmission(){
public ModelAndView landmarkSubmission() {
ModelAndView modelAndView1 = new ModelAndView("Landmarks/LandmarkFormTh.html");
modelAndView1.addObject("landmarkData", new Landmarks());
return modelAndView1;
......@@ -27,30 +31,68 @@ public class LandmarksController {
@Autowired
private LocationRepository locationRepository;
@PostMapping("/landmarkSub")
public ModelAndView landmarkSent(@Valid @ModelAttribute("landmarkData") Landmarks landmarks, BindingResult bindingResult, Model model ) {
public ModelAndView landmarkSent(@Valid @ModelAttribute("landmarkData") Landmarks landmarks, BindingResult bindingResult, Model model) {
if (bindingResult.hasErrors()) {
ModelAndView modelAndView = new ModelAndView("Landmarks/LandmarkFormTh.html", model.asMap());
return modelAndView;
} else{
} else {
// converts valid response using Location constructor into a submittable format to the sql table
Location loc= new Location(landmarks.getLandmarkName(), landmarks.getLandmarkEmail(), landmarks.getLandmarkDescription(), landmarks.getLandmarkLocation(), landmarks.getTrailID(), false);
Location loc = new Location(landmarks.getLandmarkName(), landmarks.getLandmarkEmail(), landmarks.getLandmarkDescription(), landmarks.getLandmarkLocation(), landmarks.getTrailID(), false);
locationRepository.addLocation(loc); // adds valid landmark to locations table
ModelAndView modelAndView = new ModelAndView("redirect:/home");
return modelAndView;
}
}
@Autowired
private PlacesCoordinatesRepository placesCoordinatesRepo;
// For form that allows an administrator to add an unapproved location to a trail
@GetMapping("/checkpointApproval")
public ModelAndView adminCheckpointApproval() {
List<Location> unapprovedLocations = locationRepository.getAllUnapprovedLocations(); //change to unauthorised once merger 68 accepted!! todo
ModelAndView modelAndView = new ModelAndView("Landmarks/locationApprovalFormTh.html");
modelAndView.addObject("uLocs", unapprovedLocations);
modelAndView.addObject("location", new Location());
modelAndView.addObject("locationCoord", new LocationsCoordinates());
return modelAndView;
}
@PostMapping("/checkpointSubmitted")
public ModelAndView checkpointSent(@Valid LocationsCoordinates locCoord, Location location, BindingResult bindingResult, Model model) {
if (bindingResult.hasErrors()) {
ModelAndView modelAndView = new ModelAndView("Landmarks/locationApprovalFormTh.html", model.asMap());
return modelAndView;
} else {
int locationID = locationRepository.nametoLocationID(location.getLocationName());
// converts valid response using Location constructor into a submittable format to the sql table
LocationsCoordinates ALocCoord = new LocationsCoordinates(locationID, locCoord.getLocationCoordsLat(), locCoord.getLocationCoordsLong());
boolean checkIfCoorsWithinBoundaries = placesCoordinatesRepo.checkIfCoordsAreWithinTownBoundary(ALocCoord);
if (checkIfCoorsWithinBoundaries==false){ // if coords outside associated town, form is returned to original state
return new ModelAndView("redirect:/checkpointApproval");
}
placesCoordinatesRepo.addLocationCoord(ALocCoord); // adds valid landmark to locations table
locationRepository.updateApprovalStatus(locationID); // updates approval status accordingly
System.out.println(placesCoordinatesRepo.getAllLocationCoords());
ModelAndView modelAndView = new ModelAndView("redirect:/home"); //redirects back top form in case admin wants to input second location
return modelAndView;
// }
}
}
}
......@@ -4,6 +4,10 @@ package Team5.SmartTowns.placeswithcoordinates;
import Team5.SmartTowns.data.Location;
import Team5.SmartTowns.data.LocationRepositoryJDBC;
import jakarta.validation.constraints.Digits;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -18,7 +22,12 @@ import java.util.List;
public class LocationsCoordinates {
/// separate class to location to cover all locations within trails that have been approved and have long/lat coords attached for mapping.
private int locationID;
// @NotEmpty(message = "You must enter a Latitude.")
// @Min(value=0,message = "You must enter a Latitude.")
private Double locationCoordsLat;
// @NotEmpty(message = "You must type in a Longitude.")
// @Min(value=0,message = "You must type in a Longitude.")
private Double locationCoordsLong;
private JdbcTemplate jdbc;
......@@ -104,8 +113,13 @@ public class LocationsCoordinates {
/// Need a constructor to create a locations list, approved collation list, unapproved locations list.
@Override
public String toString() {
return "LocationsCoordinates{" +
"locationID=" + locationID +
", locationCoordsLat=" + locationCoordsLat +
", locationCoordsLong=" + locationCoordsLong +
", jdbc=" + jdbc +
'}';
}
}
......@@ -14,8 +14,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.List;
import java.util.*;
@Controller
public class PlacesController {
......@@ -51,7 +50,7 @@ public class PlacesController {
@GetMapping("/checkpoints/{location}")
public ModelAndView getResultBySearchKeyLocation(@PathVariable String location) {
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<LocationsCoordinates> locCoords = reorderCoordsWRTLocations(placeRepo.getAllLocationCoords());
List<Location> approvedLocations = locationRepo.getAllApprovedLocations();
int locationID = 999;
......@@ -84,7 +83,7 @@ public class PlacesController {
modelAndView.addObject("trails", trailslocations);
modelAndView.addObject("locations", approvedLocations);
modelAndView.addObject("locationCoords", locCoords);
modelAndView.addObject("locationCoords", reorderCoordsWRTLocations(locCoords));
return modelAndView;
}
......@@ -106,11 +105,53 @@ public class PlacesController {
trailID=i;
break;}
}
List<LocationsCoordinates> aa=reorderCoordsWRTLocations(locCoords);
ModelAndView modelAndView= new ModelAndView("fragments/trailsPageFrags :: trailsSection");
modelAndView.addObject("trail", trailslocations.get(trailID));
modelAndView.addObject("locCoords", locCoords);
modelAndView.addObject("locCoords", aa);
modelAndView.addObject("locations", approvedLocations);
return modelAndView;
}
}
// public List<LocationsCoordinates> reorderCoordsWRTLocations(List<LocationsCoordinates> locCoords){
// List<Location> approvedList = locationRepo.getAllLocation();
//// List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
// List<Integer> locationID= new ArrayList<Integer>();
// System.out.println(locCoords);
// System.out.println("///////");
// Collections.swap(locCoords,0,10);
// for(int i=0;i<locCoords.size();i++){
// if (i==locCoords.size()-1){
// if (locCoords.get(i).getLocationID()<locCoords.get(i-1).getLocationID()){
// Collections.swap(locCoords,i,i--);
// i=0;
// }
//
// }
// if (locCoords.get(i).getLocationID()>locCoords.get(i++).getLocationID()){
// System.out.println("ASDSADASD");
// Collections.swap(locCoords,i,i++);
// i=0;
// }
//
// } System.out.println(locCoords);
// return locCoords;
//
//
//
// }
// When adding to the locationsCoordinates table, the order is not based on LocationID order, therefore it is needed to rearrange this list to
// follow ascending locationID so that any new coordinates match up with their intended locations.
public List<LocationsCoordinates> reorderCoordsWRTLocations(List<LocationsCoordinates> locCoords){
Collections.sort(locCoords,
Comparator.comparingInt(LocationsCoordinates::getLocationID));
System.out.println(locCoords);
return locCoords;
}
}
......@@ -13,6 +13,10 @@ public interface PlacesCoordinatesRepository {
List<TownWithTrails> getAllTownCoords();
void addTownWithCoords(TownWithTrails town);
int getLocationTableIDValue(List<Location> locations, String locationName);
Boolean checkIfCoordsAreWithinTownBoundary(LocationsCoordinates loc);
// List<Location> getFullApprovedLocations(JdbcTemplate aJdbc);
......
package Team5.SmartTowns.placeswithcoordinates;
import Team5.SmartTowns.data.Location;
import Team5.SmartTowns.data.LocationRepositoryJDBC;
import org.springframework.boot.autoconfigure.integration.IntegrationProperties;
import Team5.SmartTowns.data.LocationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
......@@ -88,6 +88,11 @@ public class PlacesCoordinatesRepositoryJDBC implements PlacesCoordinatesReposit
// }
public boolean checkInputtedCoordsMatchTown(String inpLatCoords, String inpLongCoords, String townName){
PlacesCoordinatesRepositoryJDBC jbdcsecond = new PlacesCoordinatesRepositoryJDBC(jdbc);
List<TownWithTrails> allTowns = jbdcsecond.getAllTownCoords();
......@@ -116,7 +121,9 @@ public class PlacesCoordinatesRepositoryJDBC implements PlacesCoordinatesReposit
}
}
return true;}
int getLocationTableIDValue(List<Location> locations, String locationName){
@Override
public int getLocationTableIDValue(List<Location> locations, String locationName){
int index;
for(int i=0;i<locations.size();i++){
if (Objects.equals(locations.get(i).getLocationName(), locationName)){
......@@ -128,6 +135,34 @@ public class PlacesCoordinatesRepositoryJDBC implements PlacesCoordinatesReposit
}
@Autowired
LocationRepository local;
@Override
public Boolean checkIfCoordsAreWithinTownBoundary(LocationsCoordinates loc){
int locationID=loc.getLocationID();
String locationTown= jdbc.queryForObject("SELECT locationPlace FROM locations WHERE locationID=?", String.class, locationID);
List<TownWithTrails> allTowns = getAllTownCoords();
for (int i=0;i<allTowns.size();i++){
if (Objects.equals(allTowns.get(i).getTownName(), locationTown)){
double inpLat=(loc.getLocationCoordsLat());
double inpLong=(loc.getLocationCoordsLong());
double townBoundaryLatUppermost=Double.parseDouble(allTowns.get(i).getTownUppermostCoordsLat());
double townBoundaryLatLowermost=Double.parseDouble(allTowns.get(i).getTownLowermostCoordsLat());
double townBoundaryLongLeftmost=Double.parseDouble(allTowns.get(i).getTownLeftmostCoordsLong());
double townBoundaryLongRightmost=Double.parseDouble(allTowns.get(i).getTownRightmostCoordsLong());
// check coords within respective town boundary (boundary decided by rough google maps red-line)
if ( (inpLat<=townBoundaryLatUppermost)&& (inpLat>=townBoundaryLatLowermost) && (inpLong>=townBoundaryLongLeftmost) && (inpLong<=townBoundaryLongRightmost)){
// location within boundary returns true
return true;
}}
} return false; // if location outside boundary, return true won't function and it wil return false.
}
// Method used to approve and add locations with associated coordinates. List<Location> unapprovedLocations
......
......@@ -5,6 +5,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.JdbcUserDetailsManager;
......@@ -23,6 +24,7 @@ public class SecurityConfiguration {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests((requests) -> requests
.requestMatchers("/user/**", "/userProfile").authenticated()
.anyRequest().permitAll()
......
......@@ -9,6 +9,10 @@ body{
.submitLand{
grid-area: submitButton;
}
.reviewLand{
grid-area: reviewButton;
}
.Banner {
margin-top: 20px;
background-color: darkslategrey;
......@@ -149,7 +153,7 @@ a{
grid-template-rows: auto;
grid-template-areas:
". pageTitle pageTitle pageTitle pageTitle ."
". . . submitButton submitButton .";
". reviewButton . submitButton submitButton .";
}
.gridContainer2 {
......
body{
background: rgb(41, 41, 41);
color: wheat;
}
main {
background-color: rgb(206, 153, 253);
color: black;
border-color: white;
align-content: center;
text-align: center;
border-radius: 25px;
max-width: 620px;
margin: 0 auto
}
#formHeader{
padding-top: 10px;
color:white;
text-align: center;}
table, th,tr{
margin: 0 auto;
border: white 2px solid;
align-content: center;
text-align: center;
}
//script for basic long/lat validation
function acceptanceValidation(){
var pass=true;
var lat = document.forms["adminCheckpointApproval"]["locationCoordsLat"].value
var long = document.forms["adminCheckpointApproval"]["locationCoordsLong"].value
if (lat=="") {
alert('Invalid location inputted. \nPlease input a valid latitude.');
pass = false;
}
if (long==""){
alert('Invalid location inputted. \nPlease input a valid longitude.');
pass = false;
} return pass;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" th:href="@{css/templatingstyle.css}">
<link rel="stylesheet" th:href="@{css/locationApprovalFormStyle.css}">
<script src="/scripts/locationApprovalForm.js"></script>
</head>
<body>
<header th:insert="~{/fragments/Templating.html :: header}"></header>
<hr style="height:20px; visibility:hidden;" />
<main>
<H1 id="formHeader">Locations To Be Approved:</H1>
<form action="/checkpointSubmitted" method="post" id="adminCheckpointApproval" name="adminCheckpointApproval" th:object="${locationCoord}" onsubmit="return acceptanceValidation()">
<label> Location:
<select th:object="${location}" th:field="*{locationName}"}>
<!-- <select th:field="*{locationName}">-->
<option value="" hidden="true">Select Location</option>
<option value="" selected disabled>Select Location</option>
<option th:each="uloc:${uLocs}" th:value="${uloc.getLocationName()}" th:text="${uloc.getLocationName()}+' ('+${uloc.getLocationTrailID()}+')'">
</option>
</select>
</label>
<br><br>
<label> Location Latitude:
<input type="text" th:field="*{locationCoordsLat}" placeholder="Latitude Here">
<div th:errors="*{locationCoordsLat}" th:if="${#fields.hasErrors('locationCoordsLat')}">ErrorlocationCoordsLat</div>
<br><br>
<label> Location Longitude:
<input type="text" th:field="*{locationCoordsLong}" placeholder="Latitude Here">
</label><br><br>
<div th:errors="*{locationCoordsLong}" th:if="${#fields.hasErrors('locationCoordsLong')}">ErrorlocationCoordsLat</div>
<input type="submit">
</form>
<hr style="height:20px; visibility:hidden;" />
<section id =unapprovedList >
<H2>To Be Approved:</H2>
<table>
<tr>
<th>Business Name</th>
<th>Town</th>
<th>Contact Address</th>
<th>Description</th>
</tr>
<div th:each="uloc:${uLocs}">
<tr>
<td th:text="${uloc.getLocationName()}+' ('+${uloc.getLocationTrailID()}+')'" ></td>
<td th:text="${uloc.getLocationPlace()}"></td>
<td th:text="${uloc.getLocationEmail()}"></td>
<td th:text="${uloc.getLocationDescription()}"></td>
</tr>
</div>
<tr>
</table>
</section>
<hr style="height:20px; visibility:hidden;" />
</main>
<footer th:insert="~{/fragments/Templating.html :: footer}"></footer>
</body>
</html>
\ No newline at end of file
......@@ -83,6 +83,14 @@
<!-- <div th:each="locationCoord:${locationCoords}" >-->
<!-- <div th:each="location:${locations}">-->
<!-- <div th:if="${location.getLocationTrailID()==trail.getTrailsId()}">-->
<!-- <li style="list-style: none">-->
<!-- <a th:href="'/checkpoints/'+${location.getLocationName().replace(' ', '-')}" th:text="${location.getLocationName()}"></a>-->
<!-- <ul></ul>-->
<!-- </li></div>-->
</div>
......
......@@ -13,6 +13,7 @@
<div class="gridContainer1">
<H1 id="homeTitle"> VZTA Smart Towns - Trails</H1>
<a class="submitLand" href="/landmarkSubmission"> <button> Submit Landmark!</button></a>
<a class="reviewLand" href="/checkpointApproval"> <button> Review Landmark!</button></a>
<!-- <div th:text="${towns}">-->
</div>
......
......@@ -19,8 +19,7 @@ import java.util.List;
import java.util.Objects;
import static junit.framework.TestCase.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.*;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@SpringBootTest
......@@ -46,7 +45,7 @@ public class LocationRepositoryTest {
// }
@Test
public void testGetAllApprovedLocations() {
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
......@@ -68,7 +67,7 @@ public class LocationRepositoryTest {
@Test
public void testGetAllUnapprovedLocations() {
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
......@@ -77,17 +76,17 @@ public class LocationRepositoryTest {
allLocations.remove(allLocations.get(i));
}
}
} boolean noUnapporvedLeft=false;
} boolean noUnapprovedLeft=false;
for (Location loc2: allLocations){
if (!loc2.isLocationApproved()){
noUnapporvedLeft=false;
noUnapprovedLeft=false;
break;
} else{
noUnapporvedLeft=true;
noUnapprovedLeft=true;
}
} assertTrue(noUnapporvedLeft);
} assertTrue(noUnapprovedLeft);
}
@Test
@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();
......@@ -96,11 +95,10 @@ public class LocationRepositoryTest {
}
@Test
@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();
List<Integer> coordinatesLocationsID = new ArrayList<>();
boolean doTheyMatch=false;
for (int i=0;i<coordinatesLocations.size();i++){
int locID=coordinatesLocations.get(i).getLocationID();
......@@ -117,4 +115,16 @@ public class LocationRepositoryTest {
} 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));
}
}
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;
......@@ -16,6 +18,9 @@ class PlacesCoordinatesTest {
@Autowired
PlacesCoordinatesRepository placesCoordinatesRepository;
@Autowired
LocationRepository locationRepository;
@Autowired
JdbcTemplate jdbcTemplate;
......@@ -79,4 +84,42 @@ class PlacesCoordinatesTest {
@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
......@@ -53,7 +53,7 @@ public class testUsers {
}
@Test
public void canUsersUnlockStickersTest(){
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);
......@@ -61,7 +61,7 @@ public class testUsers {
assertTrue(doesStickerUnlock);
}
@Test
public void canUsersUnlockStickersAndViewThemTest(){
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());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment