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

Commiting while H2 broken before further testing

parent f3ff1178
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"
......@@ -60,7 +60,5 @@ tasks.named('test') {
useJUnitPlatform()
}
tasks.named('test') {
Test6Mock()
}
......@@ -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;
......
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");
......
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
// }
//
//
//
////
////
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment