Package org.libreplan.business.resources.entities

Examples of org.libreplan.business.resources.entities.Criterion


        List<Criterion> list = criterionDAO.list(Criterion.class);
        assertEquals(previous + 2, list.size());
    }

    private Criterion givenASavedCriterionWithAnExistentType() {
        Criterion c = givenACriterionWithAnExistentType();
        criterionDAO.save(c);
        return c;
    }
View Full Code Here


    @Test(expected = DataIntegrityViolationException.class)
    @Transactional
    public void schemaEnsuresCannotExistTwoDifferentCriterionsWithSameNameAndType()
            throws ValidationException {
        Criterion c = givenASavedCriterionWithAnExistentType();
        Criterion repeated = anotherCriterionWithSameNameAndType(c);
        criterionDAO.save(repeated);
        criterionDAO.flush();
    }
View Full Code Here

    public void thereIsOtherWithSameNameAndTypeWorksIsolatedFromCurrentTransaction() {
        transactionService.runOnTransaction(new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                Criterion saved = givenASavedCriterionWithAnExistentType();
                assertFalse(criterionDAO.thereIsOtherWithSameNameAndType(saved));
                return null;
            }
        });
    }
View Full Code Here

        });
    }

    @Test
    public void thereIsNoOtherIfItsTheSame() {
        Criterion c = transactionService
                .runOnTransaction(new IOnTransaction<Criterion>() {

            @Override
            public Criterion execute() {
                return givenASavedCriterionWithAnExistentType();
View Full Code Here

        assertFalse(criterionDAO.thereIsOtherWithSameNameAndType(c));
    }

    @Test
    public void ifItsDifferentThereIsOther() {
        Criterion c = transactionService
                .runOnTransaction(new IOnTransaction<Criterion>() {

                    @Override
                    public Criterion execute() {
                        return givenASavedCriterionWithAnExistentType();
                    }
                });
        Criterion copy = Criterion.create(c.getName(), c.getType());
        assertTrue(criterionDAO.thereIsOtherWithSameNameAndType(copy));
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void noOtherIfTheCriterionDoesntExist() {
        Criterion criterion = givenUniquelyNamedCriterion();
        assertFalse(criterionDAO.thereIsOtherWithSameNameAndType(criterion));
    }
View Full Code Here

        assertNotNull(criterionSatisfaction.getId());
        assertTrue(satisfactionDAO.exists(criterionSatisfaction.getId()));
    }

    private CriterionSatisfaction createValidCriterionSatisfaction(int year) {
        Criterion criterion = CriterionDAOTest.createValidCriterion();
        saveCriterionType(criterion);
        criterionDAO.save(criterion);
        Worker worker = Worker.create("firstname", "surname", "nif");
        workerDAO.save(worker);
        CriterionSatisfaction criterionSatisfaction = CriterionSatisfaction.create(year(year), criterion, worker);
View Full Code Here

    }

    @Test(expected = InvalidDataAccessApiUsageException.class)
    @Transactional
    public void testNotSaveWithTransientCriterionAndWorker() {
        Criterion criterion = CriterionDAOTest.createValidCriterion();
        saveCriterionType(criterion);
        Worker worker = Worker.create("firstname", "surname", "nif");
        CriterionSatisfaction criterionSatisfaction = CriterionSatisfaction.create(year(2007), criterion, worker);
        satisfactionDAO.save(criterionSatisfaction);
    }
View Full Code Here

            if (StringUtils.isBlank(criterionWrapper.dto.code)) {
                throw new ValidationException("missing code in a criterion");
            }

            try {
                Criterion criterion = criterionType.getCriterionByCode(
                    criterionWrapper.dto.code);
                criterion.updateUnvalidated(
                    StringUtils.trim(criterionWrapper.dto.name),
                    criterionWrapper.dto.active);
            } catch (InstanceNotFoundException e) {
                criterionType.getCriterions().add(toEntityWithoutChildren(
                    criterionWrapper.dto, criterionType, null));
            }

        }

        /* 3: Update relationships. */
        for (CriterionDTOWithParentCode criterionWrapper : criterionWrappers) {

            Criterion criterion = criterionType.getExistingCriterionByCode(
                criterionWrapper.dto.code);
            Criterion newCriterionParent = null;

            if (criterionWrapper.parentCode != null) {
                newCriterionParent = criterionType.getExistingCriterionByCode(
                    criterionWrapper.parentCode);
            }
View Full Code Here

    }

    private static Criterion addCriterion(CriterionType criterionType,
        CriterionDTO criterionDTO, Criterion criterionParent) {

        Criterion criterion = toEntityWithoutChildren(criterionDTO,
            criterionType, criterionParent);
        criterionType.getCriterions().add(criterion);

        for (CriterionDTO childDTO : criterionDTO.children) {
            Criterion child = addCriterion(criterionType, childDTO, criterion);
            criterion.getChildren().add(child);
        }

        return criterion;
View Full Code Here

TOP

Related Classes of org.libreplan.business.resources.entities.Criterion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.