use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractActionHandlerImpl method getActionList.
@Override
public synchronized List<Action> getActionList(Object object) {
if (!(object instanceof Contract)) {
return null;
}
List<Action> userContractActionList = getActionList();
Collection<Functionality> functionalitySet = ((Contract) object).getFunctionalitySet();
for (Action action : userContractActionList) {
activateAction(action, functionalitySet);
}
return userContractActionList;
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ActDAOTest method testFindLastActsByContract.
/**
* Test of findAllContractsByUser method, of class ContractDAOImpl.
*/
@Test
public void testFindLastActsByContract() {
Contract contract = contractDAO.read((1L));
assertEquals(1, actDAO.findActsByContract(contract, 1, 2, null, false).size());
assertEquals(Long.valueOf(7), actDAO.findActsByContract(contract, 1, 2, null, false).iterator().next().getId());
Collection<Act> actSet = actDAO.findActsByContract(contract, 3, 2, null, false);
Iterator<Act> iter = actSet.iterator();
Date currentDate = null;
while (iter.hasNext()) {
Act act = iter.next();
if (currentDate != null) {
assertTrue(act.getBeginDate().before(currentDate));
}
currentDate = act.getBeginDate();
}
contract = contractDAO.read((2L));
assertEquals(0, actDAO.findActsByContract(contract, 1, 2, null, false).size());
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ActDAOTest method testFindNumberOfActByPeriodAndIp.
@Test
public void testFindNumberOfActByPeriodAndIp() {
Contract contract = contractDAO.read((1L));
DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date limitDate = null;
try {
limitDate = dfm.parse("2011-01-01 00:00:00");
} catch (ParseException ex) {
Logger.getLogger(ActDAOTest.class.getName()).log(Level.SEVERE, null, ex);
}
assertEquals(2, actDAO.findNumberOfActByPeriodAndIp(contract, limitDate, "127.0.0.1"));
assertEquals(0, actDAO.findNumberOfActByPeriodAndIp(contract, limitDate, "127.0.0.2"));
try {
limitDate = dfm.parse("2011-01-01 01:00:00");
} catch (ParseException ex) {
Logger.getLogger(ActDAOTest.class.getName()).log(Level.SEVERE, null, ex);
}
assertEquals(1, actDAO.findNumberOfActByPeriodAndIp(contract, limitDate, "127.0.0.1"));
assertEquals(0, actDAO.findNumberOfActByPeriodAndIp(contract, limitDate, "127.0.0.2"));
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ActDAOTest method testFindAllActsByContract.
/**
* Test of findAllContractsByUser method, of class ContractDAOImpl.
*/
@Test
public void testFindAllActsByContract() {
Contract contract = contractDAO.read((1L));
assertEquals(4, actDAO.findAllActsByContract(contract).size());
contract = contractDAO.read((2L));
assertEquals(3, actDAO.findAllActsByContract(contract).size());
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractDAOTest method testSaveOrUpdate.
/**
* Test of saveOrUpdate method, of class ContractDAOImpl.
*/
@Test
public void testSaveOrUpdate() {
Date beginDate = new Date();
Date endDate = new Date();
Date renewalDate = new Date();
int nbOfContract = contractDAO.findAll().size();
Contract contract = new Contract();
contract.setLabel("Contract-test");
contract.setBeginDate(beginDate);
contract.setEndDate(endDate);
contract.setRenewalDate(renewalDate);
contract.setPrice(200f);
contract.setPrice(200f);
contract.setUser(null);
contractDAO.saveOrUpdate(contract);
assertEquals(nbOfContract + 1, contractDAO.findAll().size());
}
Aggregations