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

Further debugging

parent e321e10b
No related branches found
No related tags found
1 merge request!34Resolve "As a user, I would like a town specific page which shows all trails for that town so that I can easily see my progress"
...@@ -34,6 +34,7 @@ dependencies { ...@@ -34,6 +34,7 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework:spring-dao:2.0.8'
} }
tasks.named('bootBuildImage') { tasks.named('bootBuildImage') {
...@@ -43,3 +44,4 @@ tasks.named('bootBuildImage') { ...@@ -43,3 +44,4 @@ tasks.named('bootBuildImage') {
tasks.named('test') { tasks.named('test') {
useJUnitPlatform() useJUnitPlatform()
} }
...@@ -55,7 +55,7 @@ insert into badgeprogress (userID, badgeID, progress) value ('1', '1', '40'); ...@@ -55,7 +55,7 @@ insert into badgeprogress (userID, badgeID, progress) value ('1', '1', '40');
insert into badgeprogress (userID, badgeID, progress) value ('1', '2', '70'); insert into badgeprogress (userID, badgeID, progress) value ('1', '2', '70');
insert into badgeprogress (userID, badgeID, progress) value ('2', '2', '70'); insert into badgeprogress (userID, badgeID, progress) value ('2', '2', '70');
delete from stickerprogress; # delete from stickerprogress;
insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '1', true); # 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 ('1', '3', true);
insert into stickerprogress (userID, stickerID, hasSticker) value ('2', '2', true); # insert into stickerprogress (userID, stickerID, hasSticker) value ('2', '2', true);
\ No newline at end of file \ No newline at end of file
...@@ -57,8 +57,8 @@ create table if not exists badgeProgress ...@@ -57,8 +57,8 @@ create table if not exists badgeProgress
create table if not exists stickerProgress create table if not exists stickerProgress
( (
userID bigint, userID int,
stickerID bigint, stickerID int,
hasSticker boolean /*Has sticker or not*/ hasSticker boolean /*Has sticker or not*/
) engine=InnoDB; ) engine=InnoDB;
......
...@@ -29,31 +29,31 @@ import static org.mockito.Mockito.mock; ...@@ -29,31 +29,31 @@ import static org.mockito.Mockito.mock;
@Sql({"schema.sql", "data.sql"}) @Sql({"schema.sql", "data.sql"})
class SmartTownsApplicationTests { class SmartTownsApplicationTests {
//
// private static TownController townController;
private static TownController townController;
// private static Team5.SmartTowns.Data.Location location;
private static Team5.SmartTowns.Data.Location location;
// @Mock // @Mock
// private static JdbcTemplate jdbc; // private static JdbcTemplate jdbc;
@Autowired @Autowired
private Team5.SmartTowns.Data.locationRepository locationRepo; private Team5.SmartTowns.Data.locationRepository locationRepo;
JdbcTemplate jdbc = Mockito.mock(JdbcTemplate.class); JdbcTemplate jdbc = Mockito.mock(JdbcTemplate.class);
@Autowired // @Autowired
private static Team5.SmartTowns.Data.TownRepository townRepository; // private static Team5.SmartTowns.Data.TownRepository townRepository;
//
//
private static Team5.SmartTowns.Data.Location town; // private static Team5.SmartTowns.Data.Location town;
private static RowMapper<Location> locationMapper; // private static RowMapper<Location> locationMapper;
@BeforeAll @BeforeAll
public void before() { public void before() {
// MockitoAnnotations.initMocks(this); // MockitoAnnotations.initMocks(this);
location = new Location(); // location = new Location();
locationRepo = mock(new locationRepositoryJDBC(jdbc)); locationRepo = mock(new locationRepositoryJDBC(jdbc));
townController = new TownController(); // townController = new TownController();
} }
// @BeforeAll // @BeforeAll
// public static void before(){} // public static void before(){}
...@@ -67,18 +67,17 @@ class SmartTownsApplicationTests { ...@@ -67,18 +67,17 @@ class SmartTownsApplicationTests {
@Test @Test
public void whenFilteringTownsByLocationsReturnOneTown() { public void whenFilteringTownsByLocationsReturnOneTown() {
List<Location> allLocations = ( locationRepo.getAllLocation()); List<Location> allLocations = ( locationRepo.getAllLocation());
List<Town> allTowns = townRepository.getAllTowns(); // List<Town> allTowns = townRepository.getAllTowns();
int allLocationNumber=allLocations.size(); // int allLocationNumber=allLocations.size();
int allLocationNumberAfterFilter=0; // int allLocationNumberAfterFilter=0;
for (Town town : allTowns){ // for (Town town : allTowns){
allLocationNumberAfterFilter+=townController.filterByLocationForTrails(allLocations, // allLocationNumberAfterFilter+=townController.filterByLocationForTrails(allLocations, town.getTownName() ).size();
town.getTownName()).size();
} }
assertSame(allLocationNumber,allLocationNumberAfterFilter); // assertSame(allLocationNumber,allLocationNumberAfterFilter);
/// list of all locations, // /// list of all locations,
// filter by all three towns // filter by all three towns
// add together size should be same // add together size should be same
} }
}
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