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

Contionued to work on bugs and erros withion test programme

parent f2b55e17
No related branches found
No related tags found
1 merge request!30Resolve "As a user I would like to see a map of the landmarks, so that I can figure out where to go"
package Team5.SmartTowns.Data;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<Location> approvedNumber= locationRepository.approvedLocations();
}
}
//package Team5.SmartTowns.Data;
//
//import org.springframework.beans.factory.annotation.Autowired;
//
//import java.util.List;
//
//public class Main {
// @Autowired
// private locationRepository locationRepository;
// List<Location> approvedNumber= locationRepository.approvedLocations();
// public static void main(String[] args) {
// for (Location loc: approvedNumber){}
//
//
// }
//}
......@@ -7,6 +7,6 @@ import java.util.List;
public interface locationRepository {
List<Location> getAllLocation();
void addLocation(Location loc);
List<Location> approvedLocations();
// List<Location> approvedLocations();
}
......@@ -42,14 +42,15 @@ public class locationRepositoryJDBC implements locationRepository {
@Override
public List<Location> approvedLocations(){
List<Location> locations = getAllLocation();
String sql= "SELECT * FROM locations";
List<Location> locations = jdbc.query(sql, locationMapper);
List<Location> locationApprovalList= new ArrayList<>();
for (Location loc :locations){
if (loc.isLocationApproved()) {
locationApprovalList.add(loc);
}
} return locationApprovalList;
}
}
}
......@@ -9,4 +9,5 @@ import lombok.Data;
public class trail {
private int trailsId;
private String name;
private Boolean tru;
}
......@@ -18,7 +18,8 @@ public class trailsRepositoryJDBC implements trailsRepository{
private void settrailsMapper(){
trailMapper = (rs, i) -> new trail(
rs.getInt("trailID"),
rs.getString("name")
rs.getString("name"),
rs.getBoolean("tru")
);
}
public List<trail> getAllTrails(){
......
......@@ -3,8 +3,8 @@ insert into users (email, name, dragonProgress) value ('hannah@gmail.com', 'Hann
insert into users (userID, email, name, dragonProgress) value ('2', 'nigel@gmail.com', 'Nigel', '40');
delete from trails;
insert into trails ( Name) value ( 'Caerphilly Coffee Trail');
insert into trails ( Name) value ( 'Penarth Dragon Trail');
insert into trails ( Name,tru) value ( 'Caerphilly Coffee Trail',false);
insert into trails ( Name,tru) value ( 'Penarth Dragon Trail',true);
delete from locations;
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved)value ( 'St Cenydd','','Location description here','Caerphilly',0101, true);
......
......@@ -2,7 +2,8 @@ drop table if exists trails;
create table if not exists trails
(
trailID bigint auto_increment primary key,
name varchar(128)
name varchar(128),
tru boolean
) engine=InnoDB;
drop table if exists locations;
......
......@@ -24,30 +24,30 @@ class SmartTownsApplicationTests {
void contextLoads() {
}
private static Location location;
@BeforeAll
public static void before() {
location = new Location(); }
@Autowired
private locationRepository locationRepository;
@Test
public void whenAddingLocationsNonApprovedLocationsDontShowInTrails(){
/// Discover number of approved/unapproved locations before adding tests
List<Location> approvedNumber= locationRepository.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()));
}
// private static Location location;
// @BeforeAll
// public static void before() {
// location = new Location(); }
// @Autowired
// private locationRepository locationRepository;
// @Test
// public void whenAddingLocationsNonApprovedLocationsDontShowInTrails(){
// /// Discover number of approved/unapproved locations before adding tests
// List<Location> approvedNumber= locationRepository.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()));
// }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment