From 694e717c3733bee848bdc941b0a5c01ec8da5325 Mon Sep 17 00:00:00 2001 From: Rhys Evans <EvansRM17@cardiff.ac.uk> Date: Thu, 7 Dec 2023 13:53:26 +0000 Subject: [PATCH] Further debugging --- build.gradle | 2 + src/main/resources/data.sql | 8 ++-- src/main/resources/schema.sql | 4 +- .../SmartTownsApplicationTests.java | 39 +++++++++---------- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/build.gradle b/build.gradle index 0bdcc02b..4d5ec10c 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,7 @@ dependencies { annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework:spring-dao:2.0.8' } tasks.named('bootBuildImage') { @@ -43,3 +44,4 @@ tasks.named('bootBuildImage') { tasks.named('test') { useJUnitPlatform() } + diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 155d9c76..f2c0ce93 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -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 ('2', '2', '70'); -delete from stickerprogress; -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 ('2', '2', true); \ No newline at end of file +# delete from stickerprogress; +# 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 ('2', '2', true); \ No newline at end of file diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 2ca616e6..22d745ed 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -57,8 +57,8 @@ create table if not exists badgeProgress create table if not exists stickerProgress ( - userID bigint, - stickerID bigint, + userID int, + stickerID int, hasSticker boolean /*Has sticker or not*/ ) engine=InnoDB; diff --git a/src/test/java/Team5/SmartTowns/SmartTownsApplicationTests.java b/src/test/java/Team5/SmartTowns/SmartTownsApplicationTests.java index 67932b97..7a786470 100644 --- a/src/test/java/Team5/SmartTowns/SmartTownsApplicationTests.java +++ b/src/test/java/Team5/SmartTowns/SmartTownsApplicationTests.java @@ -29,31 +29,31 @@ import static org.mockito.Mockito.mock; @Sql({"schema.sql", "data.sql"}) 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 // private static JdbcTemplate jdbc; @Autowired private Team5.SmartTowns.Data.locationRepository locationRepo; JdbcTemplate jdbc = Mockito.mock(JdbcTemplate.class); - @Autowired - private static Team5.SmartTowns.Data.TownRepository townRepository; - - - private static Team5.SmartTowns.Data.Location town; - private static RowMapper<Location> locationMapper; +// @Autowired +// private static Team5.SmartTowns.Data.TownRepository townRepository; +// +// +// private static Team5.SmartTowns.Data.Location town; +// private static RowMapper<Location> locationMapper; @BeforeAll public void before() { // MockitoAnnotations.initMocks(this); - location = new Location(); +// location = new Location(); locationRepo = mock(new locationRepositoryJDBC(jdbc)); - townController = new TownController(); +// townController = new TownController(); } // @BeforeAll // public static void before(){} @@ -67,18 +67,17 @@ class SmartTownsApplicationTests { @Test public void whenFilteringTownsByLocationsReturnOneTown() { List<Location> allLocations = ( locationRepo.getAllLocation()); - List<Town> allTowns = townRepository.getAllTowns(); - int allLocationNumber=allLocations.size(); - int allLocationNumberAfterFilter=0; - for (Town town : allTowns){ - allLocationNumberAfterFilter+=townController.filterByLocationForTrails(allLocations, - town.getTownName()).size(); +// List<Town> allTowns = townRepository.getAllTowns(); +// int allLocationNumber=allLocations.size(); +// int allLocationNumberAfterFilter=0; +// for (Town town : allTowns){ +// allLocationNumberAfterFilter+=townController.filterByLocationForTrails(allLocations, town.getTownName() ).size(); } - assertSame(allLocationNumber,allLocationNumberAfterFilter); - /// list of all locations, +// assertSame(allLocationNumber,allLocationNumberAfterFilter); +// /// list of all locations, // filter by all three towns // add together size should be same } -} + -- GitLab