use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractDAOImplTest method testSaveOrUpdate.
/**
* Test of saveOrUpdate method, of class ContractDAOImpl.
*/
public void testSaveOrUpdate() {
System.out.println("saveOrUpdate");
Date beginDate = new Date();
Date endDate = new Date();
Date renewalDate = new Date();
int nbOfContract = contractDAO.findAll().size();
Set<Functionality> functionalitySet = new HashSet<Functionality>();
Set<OptionElement> optionElementSet = new HashSet<OptionElement>();
Set<Referential> referenceSet = new HashSet<Referential>();
Set<Scenario> scenarioSet = new HashSet<Scenario>();
Contract contract = contractFactory.createContract("Contract-test", beginDate, endDate, renewalDate, Float.valueOf(200), functionalitySet, optionElementSet, referenceSet, scenarioSet, null);
contractDAO.saveOrUpdate(contract);
assertEquals(nbOfContract + 1, contractDAO.findAll().size());
}
use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ActDAOImplTest method testFindRunningActsByContract.
/**
* Test of findRunningActsByContract method, of class ContractDAOImpl.
*/
public void testFindRunningActsByContract() {
System.out.println("findRunningActsByContract");
Contract contract = contractDAO.read((Long.valueOf(1)));
assertEquals(1, actDAO.findRunningActsByContract(contract).size());
assertEquals(Long.valueOf(3), actDAO.findRunningActsByContract(contract).iterator().next().getId());
contract = contractDAO.read((Long.valueOf(2)));
assertEquals(3, actDAO.findRunningActsByContract(contract).size());
}
use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractDAOImpl method read.
@Override
public Contract read(Long id) {
try {
Query query = entityManager.createQuery("SELECT c FROM " + getEntityClass().getName() + " c" + " LEFT JOIN FETCH c.optionElementSet o" + " LEFT JOIN FETCH c.functionalitySet f" + " LEFT JOIN FETCH c.referentialSet f" + " LEFT JOIN FETCH c.scenarioSet f" + " WHERE c.id = :id");
query.setParameter("id", id);
Contract contract = (Contract) query.getSingleResult();
// to ensure the options associated with the contract is
// retrieved
contract.getOptionElementSet().size();
contract.getFunctionalitySet().size();
contract.getScenarioSet().size();
contract.getReferentialSet().size();
return contract;
} catch (NoResultException nre) {
return null;
}
}
Aggregations