Skip to content

Commit cf46efe

Browse files
Merge pull request #3 from Cameron-C-Chapman/develop
Develop:1.2.0-SNAPSHOT --> Master:1.1.0
2 parents 17c06ee + c6e3ab9 commit cf46efe

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ apply plugin: 'jacoco'
1919

2020
jar {
2121
baseName = 'simpleSpringRestService'
22-
version = '1.1.0'
22+
version = '1.2.0-SNAPSHOT'
2323
}
2424
sourceCompatibility = 1.8
2525
targetCompatibility = 1.8

src/main/java/org/cameronchapman/github/webservice/config/SimpleSpringRestServiceAppConfig.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package org.cameronchapman.github.webservice.config;
22

3+
import javax.sql.DataSource;
4+
35
import org.springframework.beans.factory.annotation.Autowired;
46
import org.springframework.context.annotation.Bean;
57
import org.springframework.context.annotation.Configuration;
68
import org.springframework.jdbc.core.JdbcTemplate;
79
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
8-
9-
import javax.sql.DataSource;
10+
import org.springframework.transaction.annotation.EnableTransactionManagement;
1011

1112

1213
@Configuration
14+
@EnableTransactionManagement
1315
public class SimpleSpringRestServiceAppConfig {
1416

1517
@Autowired

src/main/java/org/cameronchapman/github/webservice/data/CustomerDao.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package org.cameronchapman.github.webservice.data;
22

3+
import java.util.HashMap;
4+
import java.util.List;
5+
import java.util.Map;
6+
37
import org.cameronchapman.github.webservice.model.Customer;
48
import org.springframework.beans.factory.annotation.Autowired;
59
import org.springframework.beans.factory.annotation.Value;
@@ -10,10 +14,6 @@
1014
import org.springframework.jdbc.support.KeyHolder;
1115
import org.springframework.stereotype.Component;
1216

13-
import java.util.HashMap;
14-
import java.util.List;
15-
import java.util.Map;
16-
1717
@Component
1818
public class CustomerDao {
1919

src/main/java/org/cameronchapman/github/webservice/manager/CustomerManager.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.cameronchapman.github.webservice.manager;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
36
import org.cameronchapman.github.webservice.data.CustomerDao;
47
import org.cameronchapman.github.webservice.exception.NoNewCustomerIdReturnedException;
58
import org.cameronchapman.github.webservice.model.Customer;
@@ -10,19 +13,15 @@
1013
import org.springframework.stereotype.Component;
1114
import org.springframework.transaction.annotation.Transactional;
1215

13-
import java.util.ArrayList;
14-
import java.util.List;
15-
1616
@Component
17-
@Transactional(timeout=5)
17+
@Transactional(timeout = 5, readOnly = true)
1818
public class CustomerManager {
1919

2020
private static Logger LOGGER = LoggerFactory.getLogger(CustomerManager.class);
2121

2222
@Autowired
2323
private CustomerDao customerDao;
2424

25-
@Transactional(readOnly = true)
2625
public List<Customer> getAll() {
2726
List<Customer> customers = customerDao.getAll();
2827
if (null == customers) {
@@ -31,7 +30,6 @@ public List<Customer> getAll() {
3130
return customers;
3231
}
3332

34-
@Transactional(readOnly = true)
3533
public Customer getCustomerById(Long id) {
3634
Customer customer = null;
3735
try {
@@ -43,6 +41,7 @@ public Customer getCustomerById(Long id) {
4341
return customer;
4442
}
4543

44+
@Transactional(readOnly = false)
4645
public Number insertCustomer(Customer customer) throws Exception {
4746
Number newId = customerDao.insert(customer);
4847
// if no new id was generated from the insert attempt throw an exception

src/test/java/org/cameronchapman/github/webservice/manager/CustomerManagerTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
package org.cameronchapman.github.webservice.manager;
22

3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertNotNull;
5+
import static org.junit.Assert.assertNull;
6+
import static org.mockito.Matchers.any;
7+
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
311
import org.cameronchapman.github.webservice.data.CustomerDao;
412
import org.cameronchapman.github.webservice.exception.NoNewCustomerIdReturnedException;
5-
import org.cameronchapman.github.webservice.manager.CustomerManager;
613
import org.cameronchapman.github.webservice.model.Customer;
714
import org.junit.Before;
815
import org.junit.Test;
@@ -13,12 +20,6 @@
1320
import org.mockito.MockitoAnnotations;
1421
import org.mockito.runners.MockitoJUnitRunner;
1522

16-
import java.util.ArrayList;
17-
import java.util.List;
18-
19-
import static org.junit.Assert.*;
20-
import static org.mockito.Matchers.any;
21-
2223
@RunWith(MockitoJUnitRunner.class)
2324
public class CustomerManagerTest {
2425

@@ -39,6 +40,8 @@ public void getAllTest() throws Exception {
3940
List<Customer> customers = customerManger.getAll();
4041
assertNotNull(customers);
4142
}
43+
44+
// @TODO add timeout test
4245

4346
@Test
4447
public void getAllReturnsNullConvertsToEmptyListTest() throws Exception {

0 commit comments

Comments
 (0)