assertFalse(_repo.exists(criteria.getId()));
}
@Test
public void testSave() throws Exception {
final SchematronCriteriaGroup criteriaGroup = criteriaGroupRepository.save(newGroup(_inc,_schematronRepo));
final SchematronCriteria criteria = criteriaGroup.getCriteria().get(0);
final String newValue = "newValue";
criteria.setValue(newValue);
_repo.save(criteria);
final List<SchematronCriteria> all = _repo.findAll(new Specification<SchematronCriteria>() {
@Override
public Predicate toPredicate(Root<SchematronCriteria> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
return cb.equal(root.get(SchematronCriteria_.id), criteria.getId());
}
});
assertEquals(1, all.size());
assertEquals(newValue, all.get(0).getValue());
final SchematronCriteria newCriteria = newSchematronCriteria(_inc);
criteriaGroup.addCriteria(newCriteria);
_repo.save(newCriteria);
SchematronCriteriaGroup reloaded = criteriaGroupRepository.findOne(criteriaGroup.getId());
assertTrue(reloaded.getCriteria().contains(newCriteria));
final List<SchematronCriteriaGroup> allGroups = criteriaGroupRepository.findAll();
assertEquals(1, allGroups.size());
assertTrue(allGroups.get(0).getCriteria().contains(newCriteria));