ItEr21S04ArquitecturaServidorItEr20S04: No need to check if the criterion exists by id since the created criterions are transient instances.
This commit is contained in:
parent
e2383ad518
commit
2f5453923c
2 changed files with 7 additions and 21 deletions
|
|
@ -61,8 +61,7 @@ public class CriterionsBootstrap implements ICriterionsBootstrap {
|
|||
private void ensureCriterionExists(String criterionName,
|
||||
CriterionType criterionType) {
|
||||
Criterion criterion = new Criterion(criterionName, criterionType);
|
||||
if (!(criterionDAO.exists(criterion.getId()) || criterionDAO
|
||||
.existsByNameAndType(criterion))) {
|
||||
if (!criterionDAO.existsByNameAndType(criterion)) {
|
||||
criterionDAO.save(criterion);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,32 +30,19 @@ public class CriterionsBootstrapTest {
|
|||
@Test
|
||||
public void testBootstrap() throws Exception {
|
||||
Criterion criterion = WorkingRelationship.FIRED.criterion();
|
||||
if (criterionDAO.exists(criterion.getId())
|
||||
|| criterionDAO.existsByNameAndType(criterion)) {
|
||||
if (criterion.getId() != null) {
|
||||
criterionDAO.remove(criterion.getId());
|
||||
} else {
|
||||
criterionDAO.removeByNameAndType(criterion);
|
||||
}
|
||||
if (criterionDAO.existsByNameAndType(criterion)) {
|
||||
criterionDAO.removeByNameAndType(criterion);
|
||||
}
|
||||
|
||||
criterion = WorkingRelationship.HIRED.criterion();
|
||||
if (criterionDAO.exists(criterion.getId())
|
||||
|| criterionDAO.existsByNameAndType(criterion)) {
|
||||
if (criterion.getId() != null) {
|
||||
criterionDAO.remove(criterion.getId());
|
||||
} else {
|
||||
criterionDAO.removeByNameAndType(criterion);
|
||||
}
|
||||
if (criterionDAO.existsByNameAndType(criterion)) {
|
||||
criterionDAO.removeByNameAndType(criterion);
|
||||
}
|
||||
|
||||
criterionsBootstrap.loadRequiredData();
|
||||
criterion = WorkingRelationship.FIRED.criterion();
|
||||
assertTrue(criterionDAO.exists(criterion.getId())
|
||||
|| criterionDAO.existsByNameAndType(criterion));
|
||||
assertTrue(criterionDAO.existsByNameAndType(criterion));
|
||||
criterion = WorkingRelationship.HIRED.criterion();
|
||||
assertTrue(criterionDAO.exists(criterion.getId())
|
||||
|| criterionDAO.existsByNameAndType(criterion));
|
||||
assertTrue(criterionDAO.existsByNameAndType(criterion));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue