From ff87d3ecc246a9c8cc3eed792dad0ce44338e54b Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Mon, 23 Mar 2020 22:00:55 -0600 Subject: [PATCH] BAEL-3069 Remove final keyword, add more empty lines for readability. --- .../src/main/java/com/baeldung/jdbc/EmployeeDAO.java | 2 +- .../src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java index a7adb7933a..b5bf9452ed 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Repository; public class EmployeeDAO { private JdbcTemplate jdbcTemplate; - public void setDataSource(final DataSource dataSource) { + public void setDataSource(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource); } diff --git a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java b/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java index a64ba9b2f0..71e8fb4263 100644 --- a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java +++ b/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java @@ -27,10 +27,12 @@ public class EmployeeDAOUnitTest { ReflectionTestUtils.setField(employeeDAO, "jdbcTemplate", jdbcTemplate); Mockito.when(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM EMPLOYEE", Integer.class)) .thenReturn(4); + assertEquals(4, employeeDAO.getCountOfEmployees()); Mockito.when(jdbcTemplate.queryForObject(Mockito.anyString(), Mockito.eq(Integer.class))) .thenReturn(3); + assertEquals(3, employeeDAO.getCountOfEmployees()); } @@ -40,8 +42,10 @@ public class EmployeeDAOUnitTest { .addScript("classpath:jdbc/schema.sql") .addScript("classpath:jdbc/test-data.sql") .build(); + EmployeeDAO employeeDAO = new EmployeeDAO(); employeeDAO.setDataSource(dataSource); + assertEquals(4, employeeDAO.getCountOfEmployees()); } }