From 10ab2b64716a8f2bd84d5f55107a9c635e012b69 Mon Sep 17 00:00:00 2001
From: Rhys Evans <EvansRM17@cardiff.ac.uk>
Date: Tue, 12 Dec 2023 13:01:03 +0000
Subject: [PATCH] Commiting while H2 broken before further testing

---
 build.gradle                                  |   4 +-
 src/main/resources/schema.sql                 |   6 +-
 .../SmartTowns => }/CalculatorTest.java       |   4 +-
 .../SmartTownsApplicationTests.java           | 204 +++++++++---------
 .../java/{Team5/SmartTowns => }/Test3.java    |   4 +-
 5 files changed, 108 insertions(+), 114 deletions(-)
 rename src/test/java/{Team5/SmartTowns => }/CalculatorTest.java (97%)
 rename src/test/java/{Team5/SmartTowns => }/Test3.java (95%)

diff --git a/build.gradle b/build.gradle
index 298e5182..7ca6e70b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -60,7 +60,5 @@ tasks.named('test') {
 	useJUnitPlatform()
 }
 
-tasks.named('test') {
-	Test6Mock()
-}
+
 
diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql
index 426885b4..22d745ed 100644
--- a/src/main/resources/schema.sql
+++ b/src/main/resources/schema.sql
@@ -20,12 +20,12 @@ create table if not exists locations
     locationTrailID varchar(128)
 )   engine=InnoDB;
 
-drop table if exists userss;
-create table if not exists userss
+drop table if exists users;
+create table if not exists users
 (
     userID bigint auto_increment primary key,
     email varchar(128),
-    named varchar(128),
+    name varchar(128),
     dragonProgress int
 ) engine=InnoDB;
 
diff --git a/src/test/java/Team5/SmartTowns/CalculatorTest.java b/src/test/java/CalculatorTest.java
similarity index 97%
rename from src/test/java/Team5/SmartTowns/CalculatorTest.java
rename to src/test/java/CalculatorTest.java
index 33b9fdac..c0fae0f9 100644
--- a/src/test/java/Team5/SmartTowns/CalculatorTest.java
+++ b/src/test/java/CalculatorTest.java
@@ -1,5 +1,3 @@
-package Team5.SmartTowns;
-
 import Team5.SmartTowns.Data.Calculator;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
@@ -12,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 //import org.junit.platform.engine.TestDescriptor;
 //import org.junit.platform.commons.util.Preconditions;
 import org.apache.commons.logging.LogFactory;
-@SpringBootTest
+//@SpringBootTest
 public class CalculatorTest {
 //    String asd= getLegacyReportingName("das");
 
diff --git a/src/test/java/Team5/SmartTowns/SmartTownsApplicationTests.java b/src/test/java/Team5/SmartTowns/SmartTownsApplicationTests.java
index c605229b..16f057a4 100644
--- a/src/test/java/Team5/SmartTowns/SmartTownsApplicationTests.java
+++ b/src/test/java/Team5/SmartTowns/SmartTownsApplicationTests.java
@@ -1,115 +1,115 @@
-package Team5.SmartTowns;
-
-import Team5.SmartTowns.Data.LocationRepository;
-import Team5.SmartTowns.Data.LocationRepositoryJDBC;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest;
-import org.springframework.boot.test.autoconfigure.jdbc.JdbcTest;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
-import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
-import org.springframework.test.context.jdbc.Sql;
-//import org.testng.Assert;
-
-import javax.sql.DataSource;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.mockito.Mockito.mock;
-
-@SpringBootTest
-@JdbcTest
-
-@Sql({"schema.sql", "data.sql"})
-class SmartTownsApplicationTests {
-@Autowired
-	private JdbcTemplate ajdbc;
-
-	@Test
-//	test2
-	public void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount1() {
-		DataSource dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2)
-				.addScript("classpath:jdbc/schema.sql")
-				.addScript("classpath:jdbc/test-data.sql")
-				.build();
-
-		LocationRepositoryJDBC employeeDAO = new LocationRepositoryJDBC();
-		employeeDAO.setDataSource(dataSource);
-
-		assertEquals(4, employeeDAO.getCountOfEmployees());}
-
-	@Test
-//	test 1
-	void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount() {
-		LocationRepositoryJDBC employeeDAO = new LocationRepositoryJDBC();
-		employeeDAO.setJdbcTemplate(ajdbc);
-		assertEquals(4, employeeDAO.getAllLocation().size());
-
-//		assertEquals(4, employeeDAO.getCountOfEmployees());
-	}
+//package Team5.SmartTowns;
+//
+//import Team5.SmartTowns.Data.LocationRepository;
+//import Team5.SmartTowns.Data.LocationRepositoryJDBC;
+//import org.junit.jupiter.api.Test;
+//import org.mockito.Mock;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest;
+//import org.springframework.boot.test.autoconfigure.jdbc.JdbcTest;
+//import org.springframework.boot.test.context.SpringBootTest;
+//import org.springframework.jdbc.core.JdbcTemplate;
+//import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+//import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+//import org.springframework.test.context.jdbc.Sql;
+////import org.testng.Assert;
+//
+//import javax.sql.DataSource;
+//
+//import static org.junit.jupiter.api.Assertions.assertEquals;
+//import static org.junit.jupiter.api.Assertions.assertSame;
+//import static org.mockito.Mockito.mock;
+//
+//@SpringBootTest
+//@JdbcTest
+//
+//@Sql({"schema.sql", "data.sql"})
+//class SmartTownsApplicationTests {
+//
+//	private JdbcTemplate ajdbc;
+//
+//	@Test
+////	test2
+//	public void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount1() {
+//		DataSource dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2)
+//				.addScript("classpath:jdbc/schema.sql")
+//				.addScript("classpath:jdbc/test-data.sql")
+//				.build();
+//
+//		LocationRepositoryJDBC employeeDAO = new LocationRepositoryJDBC();
+//		employeeDAO.setDataSource(dataSource);
+//
+//		assertEquals(4, employeeDAO.getCountOfEmployees());}
+//
 //	@Test
+////	test 1
 //	void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount() {
-//		EmployeeDAO employeeDAO = new EmployeeDAO();
-//		employeeDAO.setJdbcTemplate(jdbcTemplate);
+//		LocationRepositoryJDBC employeeDAO = new LocationRepositoryJDBC(ajdbc);
+////		employeeDAO.setJdbcTemplate(ajdbc);
+//		assertEquals(4, employeeDAO.getAllLocation().size());
+//
+////		assertEquals(4, employeeDAO.getCountOfEmployees());
+//	}}
+////	@Test
+////	void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount() {
+////		EmployeeDAO employeeDAO = new EmployeeDAO();
+////		employeeDAO.setJdbcTemplate(jdbcTemplate);
+////
+////		assertEquals(4, employeeDAO.getCountOfEmployees());
+////	}
 //
-//		assertEquals(4, employeeDAO.getCountOfEmployees());
-//	}
-
-
-
-
 //
-////	private static TownController townController;
 //
 //
-////	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);
+//////	private static TownController townController;
+////
+////
+//////	private static Team5.SmartTowns.Data.Location location;
+//////	@Mock
+//////	private static JdbcTemplate jdbc;
+//////
 //////	@Autowired
-//////	private static Team5.SmartTowns.Data.TownRepository townRepository;
+//////	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;
 //////
 //////
-//////	private static Team5.SmartTowns.Data.Location town;
-//////	private static RowMapper<Location> locationMapper;
-////
-////
-////	@BeforeAll
-////	public void before() {
-//////		MockitoAnnotations.initMocks(this);
-//////		location = new Location();
-////		locationRepo = mock(new LocationRepositoryJDBC(jdbc));
-//////		townController = new TownController();
-////	}
 //////	@BeforeAll
-//////	public static void before(){}
-//////		location = new Location();
-//////}
-////
-////	@Test
-////	void contextLoads() {
+//////	public void before() {
+////////		MockitoAnnotations.initMocks(this);
+////////		location = new Location();
+//////		locationRepo = mock(new LocationRepositoryJDBC(jdbc));
+////////		townController = new TownController();
+//////	}
+////////	@BeforeAll
+////////	public static void before(){}
+////////		location = new Location();
+////////}
+//////
+//////	@Test
+//////	void contextLoads() {
+//////	}
+//////
+//////	@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();
+////		}
+//////		assertSame(allLocationNumber,allLocationNumberAfterFilter);
+////// /// list of all locations,
+//////	filter by all three towns
+//////	add together size  should be same
 ////	}
 ////
-////	@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();
-//		}
-////		assertSame(allLocationNumber,allLocationNumberAfterFilter);
-//// /// list of all locations,
-////	filter by all three towns
-////	add together size  should be same
-//	}
-//
-//
-//
+////
+////
diff --git a/src/test/java/Team5/SmartTowns/Test3.java b/src/test/java/Test3.java
similarity index 95%
rename from src/test/java/Team5/SmartTowns/Test3.java
rename to src/test/java/Test3.java
index a652675d..d80d3658 100644
--- a/src/test/java/Team5/SmartTowns/Test3.java
+++ b/src/test/java/Test3.java
@@ -1,5 +1,3 @@
-package Team5.SmartTowns;
-
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
@@ -9,7 +7,7 @@ import javax.sql.DataSource;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
-@SpringBootTest
+
 public class Test3 {
 
     @Test
-- 
GitLab