Package org.libreplan.business.resources.entities

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


    @Test
    @Transactional
    public void testCantAddCriterionSatisfactionWithTypeAllowMultipleResource() {
        Criterion criterion = CriterionDAOTest.createValidCriterion();
        Criterion otherCriterion = CriterionDAOTest.createValidCriterion();
        Worker worker = Worker.create("firstName", "surName", "2333232");
        ICriterionType<Criterion> criterionType = createTypeThatMatches(true,
                criterion,otherCriterion);

        Interval intervalA = Interval.range(date(2009,10,8),date(2009,10,25));
        Interval intervalB = Interval.range(date(2009,10,5),date(2009,10,9));
        Interval intervalC = Interval.range(date(2009,11,12),date(2009,11,16));
        Interval intervalE = Interval.range(date(2009,10,26),date(2009,10,30));
        worker.addSatisfaction(new CriterionWithItsType(criterionType,
                criterion), intervalA);
        //Same Criterion
        assertFalse(worker.canAddSatisfaction(new CriterionWithItsType(
                criterionType, criterion), intervalB));
        //Distinct Criterion
        assertTrue(worker.canAddSatisfaction(new CriterionWithItsType(
                criterionType, otherCriterion), intervalC));
        //without overlap
        assertTrue(worker.canAddSatisfaction(new CriterionWithItsType(
                criterionType, criterion), intervalE));
    }
View Full Code Here


                criterionType, criterion), intervalE));
    }

    public void testAddCriterionSatisfaction() {
        Criterion criterion = CriterionDAOTest.createValidCriterion();
        Worker worker = Worker.create("firstName", "surName", "2333232");
        ICriterionType<Criterion> criterionType = createTypeThatMatches(false,
                criterion);
        CriterionSatisfaction satisfaction = createValid(criterion, worker);
        worker.addSatisfaction(criterionType, satisfaction);
        assertThat(worker.getAllSatisfactions().size(), equalTo(1));
    }
View Full Code Here

    @Test(expected = IllegalStateException.class)
    @Transactional
    public void shouldntAdd() {
        Criterion criterion = CriterionDAOTest.createValidCriterion();
        Worker worker = Worker.create("firstName", "surName", "2333232");
        ICriterionType<?> type = new CriterionTypeBase("prueba","", false, false,
                true) {

            @Override
            public boolean contains(ICriterion c) {
                return true;
            }

            @Override
            public Criterion createCriterion(String name) {
                return null;
            }

            @Override
            public boolean criterionCanBeRelatedTo(
                    Class<? extends Resource> klass) {
                return false;
            }

            @Override
            public Criterion createCriterionWithoutNameYet() {
                return null;
            }
        };
        CriterionWithItsType criterionWithItsType = new CriterionWithItsType(
                type, criterion);
        LocalDate today = new LocalDate();
        assertFalse(worker.canAddSatisfaction(criterionWithItsType,
                Interval.from(today)));
        worker.addSatisfaction(criterionWithItsType);
    }
View Full Code Here

public class CriterionSatisfactionTest {

    @Test
    public void testFinish() {
        final Criterion criterion = CriterionDAOTest.createValidCriterion();
        Worker worker = Worker.create("firstName", "surName", "2333232");
        CriterionSatisfaction criterionSatisfaction = CriterionSatisfaction.create(year(2000), criterion, worker);
        LocalDate end = year(2006);
        criterionSatisfaction.finish(end);
        assertTrue(criterionSatisfaction.isFinished());
        assertEquals(end, criterionSatisfaction.getEndDate());
View Full Code Here

    }

    @Test
    public void canFinishWhenItStarted() {
        final Criterion criterion = CriterionDAOTest.createValidCriterion();
        Worker worker = Worker.create("firstName", "surName", "2333232");
        LocalDate start = year(2000);
        CriterionSatisfaction criterionSatisfaction = CriterionSatisfaction.create(start, criterion, worker);
        criterionSatisfaction.finish(start);
        assertTrue(criterionSatisfaction.isFinished());
    }
View Full Code Here

    }

    @Test(expected = IllegalArgumentException.class)
    public void testCantFinishBeforeStart() {
        final Criterion criterion = CriterionDAOTest.createValidCriterion();
        Worker worker = Worker.create("firstName", "surName", "2333232");
        CriterionSatisfaction criterionSatisfaction = CriterionSatisfaction.create(year(2000), criterion, worker);
        criterionSatisfaction.finish(year(1999));
    }
View Full Code Here

    }

    @Test
    public void testIsEnforcedAtDate() {
        final Criterion criterion = CriterionDAOTest.createValidCriterion();
        Worker worker = Worker.create("firstName", "surName", "2333232");
        CriterionSatisfaction criterionSatisfaction = CriterionSatisfaction.create(year(2000), criterion, worker);
        assertTrue(criterionSatisfaction.isEnforcedAt(year(3000)));
        assertTrue(criterionSatisfaction.isEnforcedAt(year(2000)));
        assertFalse(criterionSatisfaction.isEnforcedAt(year(1999)));
        criterionSatisfaction.finish(year(2005));
View Full Code Here

    }

    @Test
    public void testEnforcedAtSomePointInInterval() {
        final Criterion criterion = CriterionDAOTest.createValidCriterion();
        Worker worker = Worker.create("firstName", "surName", "2333232");
        CriterionSatisfaction criterionSatisfaction = CriterionSatisfaction.create(year(2000), criterion, worker);
        assertTrue(criterionSatisfaction.overlapsWith(Interval.range(
                year(2001), year(4000))));
        assertTrue(criterionSatisfaction.overlapsWith(Interval.range(
                year(2005), year(4000))));
View Full Code Here

    }

    @Test
    public void testCriterionSatisfactionsStartComparator() {
        final Criterion criterion = CriterionDAOTest.createValidCriterion();
        Worker worker = Worker.create("firstName", "surName", "2333232");
        Interval[] intervals = { Interval.from(year(1000)),
                Interval.range(year(1100), year(9000)),
                Interval.point(year(1101)), Interval.from(year(1200)),
                Interval.range(year(3000), year(4000)) };
        List<CriterionSatisfaction> orderedSatisfactions = new ArrayList<CriterionSatisfaction>();
View Full Code Here

        assertTrue(PredefinedCriterionTypes.CATEGORY.contains(managerCriterion));
    }

    @Test
    public void testCompounding() {
        Worker worker1 = Worker.create();
        Worker worker2 = Worker.create();

        ICriterion criterionForWorker1 = justThisResourcesCriterion(worker1);
        ICriterion criterionForWorker2 = justThisResourcesCriterion(worker2);
        ICriterion criterionForWorkers1And2 = justThisResourcesCriterion(
                worker1, worker2);
View Full Code Here

TOP

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

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.