Search in sources :

Example 16 with Contract

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;
}
Also used : Action(org.asqatasun.webapp.action.Action) Functionality(org.asqatasun.entity.functionality.Functionality) Contract(org.asqatasun.entity.contract.Contract)

Example 17 with Contract

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());
}
Also used : Act(org.asqatasun.entity.contract.Act) Contract(org.asqatasun.entity.contract.Contract) Date(java.util.Date) Test(org.junit.Test)

Example 18 with Contract

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"));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(java.text.ParseException) Contract(org.asqatasun.entity.contract.Contract) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 19 with Contract

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());
}
Also used : Contract(org.asqatasun.entity.contract.Contract) Test(org.junit.Test)

Example 20 with Contract

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());
}
Also used : Contract(org.asqatasun.entity.contract.Contract) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Contract (org.asqatasun.entity.contract.Contract)44 Secured (org.springframework.security.access.annotation.Secured)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)15 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)12 Test (org.junit.Test)7 Audit (org.asqatasun.entity.audit.Audit)5 User (org.asqatasun.entity.user.User)5 List (java.util.List)4 Date (java.util.Date)3 Scenario (org.asqatasun.entity.scenario.Scenario)3 Site (org.asqatasun.entity.subject.Site)3 WebResource (org.asqatasun.entity.subject.WebResource)3 Act (org.asqatasun.entity.contract.Act)2 Functionality (org.asqatasun.entity.functionality.Functionality)2 AuditResultSortCommand (org.asqatasun.webapp.command.AuditResultSortCommand)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1