| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package org.perfectjpattern.jee.integration.dao; |
| 22 |
|
|
| 23 |
|
import java.util.*; |
| 24 |
|
|
| 25 |
|
import org.perfectjpattern.example.datamodel.*; |
| 26 |
|
import org.perfectjpattern.jee.api.integration.dao.*; |
| 27 |
|
import org.slf4j.*; |
| 28 |
|
import org.springframework.test.*; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@link |
| 32 |
|
|
| 33 |
|
@author |
| 34 |
|
@version |
| 35 |
|
|
| 36 |
|
public |
|
|
|
| 100% |
Uncovered Elements: 0 (52) |
Complexity: 6 |
Complexity Density: 0.13 |
|
| 37 |
|
class TestSpringGenericDao |
| 38 |
|
extends AbstractTransactionalSpringContextTests |
| 39 |
|
{ |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1
PASS
|
|
| 43 |
1
|
public void... |
| 44 |
|
testFindByName() |
| 45 |
|
{ |
| 46 |
|
|
| 47 |
1
|
IPersonDao myPersonDao = LocalDaoFactory.getInstance(). |
| 48 |
|
createPersonDao(); |
| 49 |
|
|
| 50 |
|
|
| 51 |
1
|
Person myErnesto = new Person("Ernesto", 35); |
| 52 |
1
|
myPersonDao.create(myErnesto); |
| 53 |
1
|
Person myGiovanni = new Person("Giovanni", 33); |
| 54 |
1
|
myPersonDao.create(myGiovanni); |
| 55 |
1
|
Person myAlberto = new Person("Alberto", 33); |
| 56 |
1
|
myPersonDao.create(myAlberto); |
| 57 |
|
|
| 58 |
1
|
List<Person> myMatches = myPersonDao.findByName("Ernesto"); |
| 59 |
1
|
assertNotNull("findByName did not work as expected", myMatches); |
| 60 |
1
|
assertEquals("findByName did not work as expected", 1, myMatches. |
| 61 |
|
size()); |
| 62 |
1
|
assertEquals("findByName did not work as expected", myErnesto, |
| 63 |
|
myMatches.get(0)); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1
PASS
|
|
| 67 |
1
|
public void... |
| 68 |
|
testFindByAge() |
| 69 |
|
{ |
| 70 |
|
|
| 71 |
1
|
IPersonDao myPersonDao = LocalDaoFactory.getInstance(). |
| 72 |
|
createPersonDao(); |
| 73 |
|
|
| 74 |
|
|
| 75 |
1
|
Person myErnesto = new Person("Ernesto", 35); |
| 76 |
1
|
myPersonDao.create(myErnesto); |
| 77 |
1
|
Person myGiovanni = new Person("Giovanni", 33); |
| 78 |
1
|
myPersonDao.create(myGiovanni); |
| 79 |
1
|
Person myAlberto = new Person("Alberto", 33); |
| 80 |
1
|
myPersonDao.create(myAlberto); |
| 81 |
|
|
| 82 |
1
|
List<Person> myMatches = myPersonDao.findByAge(33); |
| 83 |
1
|
assertNotNull("findByAge did not work as expected", myMatches); |
| 84 |
1
|
assertEquals("findByAge did not work as expected", 2, myMatches. |
| 85 |
|
size()); |
| 86 |
1
|
assertEquals("findByAge did not work as expected", 33, |
| 87 |
|
myMatches.get(0).getAge()); |
| 88 |
1
|
assertEquals("findByAge did not work as expected", 33, |
| 89 |
|
myMatches.get(1).getAge()); |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1
PASS
|
|
| 93 |
1
|
public void... |
| 94 |
|
testFindByExample() |
| 95 |
|
{ |
| 96 |
|
|
| 97 |
1
|
IPersonDao myPersonDao = LocalDaoFactory.getInstance(). |
| 98 |
|
createPersonDao(); |
| 99 |
|
|
| 100 |
|
|
| 101 |
1
|
Person myErnesto = new Person("Ernesto", 35); |
| 102 |
1
|
myPersonDao.create(myErnesto); |
| 103 |
1
|
Person myGiovanni = new Person("Giovanni", 33); |
| 104 |
1
|
myPersonDao.create(myGiovanni); |
| 105 |
1
|
Person myAlberto = new Person("Alberto", 33); |
| 106 |
1
|
myPersonDao.create(myAlberto); |
| 107 |
|
|
| 108 |
1
|
Person myExample = new Person(); |
| 109 |
1
|
myExample.setAge(33); |
| 110 |
1
|
List<Person> myMatches = myPersonDao.findByExample(myExample); |
| 111 |
1
|
assertNotNull("findByExample did not work as expected", myMatches); |
| 112 |
1
|
assertEquals("findByExample did not work as expected", 2, myMatches. |
| 113 |
|
size()); |
| 114 |
1
|
assertEquals("findByExample did not work as expected", 33, |
| 115 |
|
myMatches.get(0).getAge()); |
| 116 |
1
|
assertEquals("findByExample did not work as expected", 33, |
| 117 |
|
myMatches.get(1).getAge()); |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1
PASS
|
|
| 121 |
1
|
public void... |
| 122 |
|
testFindById() |
| 123 |
|
{ |
| 124 |
|
|
| 125 |
1
|
IPersonDao myPersonDao = LocalDaoFactory.getInstance(). |
| 126 |
|
createPersonDao(); |
| 127 |
|
|
| 128 |
|
|
| 129 |
1
|
Person myErnesto = new Person("Ernesto", 35); |
| 130 |
1
|
myPersonDao.create(myErnesto); |
| 131 |
|
|
| 132 |
1
|
Person myMatch = myPersonDao.findById(myErnesto.getId()); |
| 133 |
1
|
assertNotNull("findById did not work as expected", myMatch); |
| 134 |
1
|
assertEquals("findById did not work as expected", myErnesto, |
| 135 |
|
myMatch); |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 141 |
4
|
protected String[] ... |
| 142 |
|
getConfigLocations() |
| 143 |
|
{ |
| 144 |
4
|
return new String[] |
| 145 |
|
{ |
| 146 |
|
"file:src/main/resources/genericDao-applicationContext.xml", |
| 147 |
|
"file:src/test/resources/test-applicationContext.xml" |
| 148 |
|
}; |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 152 |
4
|
protected void ... |
| 153 |
|
onTearDownAfterTransaction() |
| 154 |
|
throws Exception |
| 155 |
|
{ |
| 156 |
|
|
| 157 |
4
|
IPersonDao myPersonDao = LocalDaoFactory.getInstance(). |
| 158 |
|
createPersonDao(); |
| 159 |
4
|
myPersonDao.deleteAll(); |
| 160 |
|
} |
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
@SuppressWarnings("unused") |
| 169 |
|
private final Logger theLogger = LoggerFactory.getLogger(this.getClass()); |
| 170 |
|
} |