Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import java.util.List;

@Repository
public class QueryingDAO {
public class QueryingDao {
private JdbcTemplate jdbcTemplate;

public QueryingDAO(JdbcTemplate jdbcTemplate) {
public QueryingDao(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import java.sql.PreparedStatement;

@Repository
public class UpdatingDAO {
public class UpdatingDao {
private JdbcTemplate jdbcTemplate;

public UpdatingDAO(JdbcTemplate jdbcTemplate) {
public UpdatingDao(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}

Expand Down
14 changes: 7 additions & 7 deletions spring-jdbc-1/complete/src/test/java/cholog/QueryingDaoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

@JdbcTest
public class QueryingDaoTest {
private QueryingDAO queryingDAO;
private QueryingDao queryingDao;

@Autowired
private JdbcTemplate jdbcTemplate;

@BeforeEach
void setUp() {
queryingDAO = new QueryingDAO(jdbcTemplate);
queryingDao = new QueryingDao(jdbcTemplate);

jdbcTemplate.execute("DROP TABLE customers IF EXISTS");
jdbcTemplate.execute("CREATE TABLE customers(" +
Expand All @@ -36,36 +36,36 @@ void setUp() {

@Test
void count() {
int count = queryingDAO.count();
int count = queryingDao.count();

assertThat(count).isEqualTo(4);
}

@Test
void getLastName() {
String lastName = queryingDAO.getLastName(1L);
String lastName = queryingDao.getLastName(1L);

assertThat(lastName).isEqualTo("Woo");
}

@Test
void findCustomerById() {
Customer customer = queryingDAO.findCustomerById(1L);
Customer customer = queryingDao.findCustomerById(1L);

assertThat(customer).isNotNull();
assertThat(customer.getLastName()).isEqualTo("Woo");
}

@Test
void findAllCustomers() {
List<Customer> customers = queryingDAO.findAllCustomers();
List<Customer> customers = queryingDao.findAllCustomers();

assertThat(customers).hasSize(4);
}

@Test
void findCustomerByFirstName() {
List<Customer> customers = queryingDAO.findCustomerByFirstName("Josh");
List<Customer> customers = queryingDao.findCustomerByFirstName("Josh");

assertThat(customers).hasSize(2);
}
Expand Down
16 changes: 8 additions & 8 deletions spring-jdbc-1/complete/src/test/java/cholog/UpdatingDaoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@

@JdbcTest
public class UpdatingDaoTest {
private UpdatingDAO updatingDAO;
private QueryingDAO queryingDAO;
private UpdatingDao updatingDao;
private QueryingDao queryingDao;

@Autowired
private JdbcTemplate jdbcTemplate;

@BeforeEach
void setUp() {
queryingDAO = new QueryingDAO(jdbcTemplate);
updatingDAO = new UpdatingDAO(jdbcTemplate);
queryingDao = new QueryingDao(jdbcTemplate);
updatingDao = new UpdatingDao(jdbcTemplate);

jdbcTemplate.execute("DROP TABLE customers IF EXISTS");
jdbcTemplate.execute("CREATE TABLE customers(" +
Expand All @@ -40,24 +40,24 @@ void setUp() {
@Test
void insert() {
Customer customer = new Customer("Leonor", "Watling");
updatingDAO.insert(customer);
updatingDao.insert(customer);

List<Customer> customers = queryingDAO.findCustomerByFirstName("Leonor");
List<Customer> customers = queryingDao.findCustomerByFirstName("Leonor");

assertThat(customers).hasSize(1);
}

@Test
void delete() {
int rowNum = updatingDAO.delete(1L);
int rowNum = updatingDao.delete(1L);

assertThat(rowNum).isEqualTo(1);
}

@Test
void keyHolder() {
Customer customer = new Customer("Leonor", "Watling");
Long id = updatingDAO.insertWithKeyHolder(customer);
Long id = updatingDao.insertWithKeyHolder(customer);

assertThat(id).isNotNull();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import java.util.List;

@Repository
public class QueryingDAO {
public class QueryingDao {
private JdbcTemplate jdbcTemplate;

public QueryingDAO(JdbcTemplate jdbcTemplate) {
public QueryingDao(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import java.sql.PreparedStatement;

@Repository
public class UpdatingDAO {
public class UpdatingDao {
private JdbcTemplate jdbcTemplate;

public UpdatingDAO(JdbcTemplate jdbcTemplate) {
public UpdatingDao(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}

Expand Down
14 changes: 7 additions & 7 deletions spring-jdbc-1/initial/src/test/java/cholog/QueryingDaoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

@JdbcTest
public class QueryingDaoTest {
private QueryingDAO queryingDAO;
private QueryingDao queryingDao;

@Autowired
private JdbcTemplate jdbcTemplate;

@BeforeEach
void setUp() {
queryingDAO = new QueryingDAO(jdbcTemplate);
queryingDao = new QueryingDao(jdbcTemplate);

jdbcTemplate.execute("DROP TABLE customers IF EXISTS");
jdbcTemplate.execute("CREATE TABLE customers(" +
Expand All @@ -37,36 +37,36 @@ void setUp() {

@Test
void count() {
int count = queryingDAO.count();
int count = queryingDao.count();

assertThat(count).isEqualTo(4);
}

@Test
void getLastName() {
String lastName = queryingDAO.getLastName(1L);
String lastName = queryingDao.getLastName(1L);

assertThat(lastName).isEqualTo("Woo");
}

@Test
void findCustomerById() {
Customer customer = queryingDAO.findCustomerById(1L);
Customer customer = queryingDao.findCustomerById(1L);

assertThat(customer).isNotNull();
assertThat(customer.getLastName()).isEqualTo("Woo");
}

@Test
void findAllCustomers() {
List<Customer> customers = queryingDAO.findAllCustomers();
List<Customer> customers = queryingDao.findAllCustomers();

assertThat(customers).hasSize(4);
}

@Test
void findCustomerByFirstName() {
List<Customer> customers = queryingDAO.findCustomerByFirstName("Josh");
List<Customer> customers = queryingDao.findCustomerByFirstName("Josh");

assertThat(customers).hasSize(2);
}
Expand Down
16 changes: 8 additions & 8 deletions spring-jdbc-1/initial/src/test/java/cholog/UpdatingDaoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@

@JdbcTest
public class UpdatingDaoTest {
private UpdatingDAO updatingDAO;
private QueryingDAO queryingDAO;
private UpdatingDao updatingDao;
private QueryingDao queryingDao;

@Autowired
private JdbcTemplate jdbcTemplate;

@BeforeEach
void setUp() {
queryingDAO = new QueryingDAO(jdbcTemplate);
updatingDAO = new UpdatingDAO(jdbcTemplate);
queryingDao = new QueryingDao(jdbcTemplate);
updatingDao = new UpdatingDao(jdbcTemplate);

jdbcTemplate.execute("DROP TABLE customers IF EXISTS");
jdbcTemplate.execute("CREATE TABLE customers(" +
Expand All @@ -40,24 +40,24 @@ void setUp() {
@Test
void insert() {
Customer customer = new Customer("Leonor", "Watling");
updatingDAO.insert(customer);
updatingDao.insert(customer);

List<Customer> customers = queryingDAO.findCustomerByFirstName("Leonor");
List<Customer> customers = queryingDao.findCustomerByFirstName("Leonor");

assertThat(customers).hasSize(1);
}

@Test
void delete() {
int rowNum = updatingDAO.delete(1L);
int rowNum = updatingDao.delete(1L);

assertThat(rowNum).isEqualTo(1);
}

@Test
void keyHolder() {
Customer customer = new Customer("Leonor", "Watling");
Long id = updatingDAO.insertWithKeyHolder(customer);
Long id = updatingDao.insertWithKeyHolder(customer);

assertThat(id).isNotNull();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD)
class CRUDTest {
class CrudTest {
@Test
void create() {
var response = RestAssured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD)
class CRUDTest {
class CrudTest {
@Test
void create() {
var response = RestAssured
Expand Down