Package org.libreplan.business.workingday

Examples of org.libreplan.business.workingday.ResourcesPerDay


        return new BaseMatcher<ResourcesPerDay>() {

            @Override
            public boolean matches(Object arg) {
                if (arg instanceof ResourcesPerDay) {
                    ResourcesPerDay r = (ResourcesPerDay) arg;
                    return r.getAmount().intValue() == integerPart
                            && getDecimalPart(r) == decimalPart;
                }
                return false;
            }

            private int getDecimalPart(ResourcesPerDay r) {
                BigDecimal onlyDecimal = r.getAmount().subtract(
                        new BigDecimal(r.getAmount().intValue()));
                BigDecimal decimalPartAsInt = onlyDecimal.movePointRight(4);
                int result = decimalPartAsInt.intValue();
                return result;
            }
View Full Code Here


        };
    }

    @Test
    public void theUnitsAmountCanBeADecimalValue() {
        ResourcesPerDay resourcesPerDay = ResourcesPerDay
                .amount(new BigDecimal(2.2));
        assertThat(resourcesPerDay, readsAs(2, 2000));
    }
View Full Code Here

        assertThat(resourcesPerDay, readsAs(2, 2000));
    }

    @Test
    public void theAmountIsConvertedToABigDecimalOfScale4() {
        ResourcesPerDay resourcesPerDay = ResourcesPerDay
                .amount(new BigDecimal(2.2));
        assertThat(resourcesPerDay.getAmount().scale(), equalTo(4));
    }
View Full Code Here

    public void ifTheAmountSpecifiedHasBiggerScaleThan4ItIsRoundedHalfUp() {
        BigDecimal[] examples = { new BigDecimal(2.11236),
                new BigDecimal(211235).movePointLeft(5),
                new BigDecimal(2.1124), new BigDecimal(2.112449) };
        for (BigDecimal example : examples) {
            ResourcesPerDay resourcesPerDay = ResourcesPerDay.amount(example);
            assertThat(resourcesPerDay.getAmount().scale(), equalTo(4));
            assertThat(resourcesPerDay, readsAs(2, 1124));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void canBeConvertedToDurationsGivenTheWorkingDayInDifferentGranularities() {
        ResourcesPerDay units = ResourcesPerDay.amount(2);
        for (Granularity each : Granularity.values()) {
            assertThat(units.asDurationGivenWorkingDayOf(EffortDuration
                    .elapsing(8, each)), equalTo(EffortDuration.elapsing(16,
                    each)));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void ifTheAmountIsDecimalTheSecondsAreMultiplied() {
        ResourcesPerDay resourcesPerDay = ResourcesPerDay
                .amount(new BigDecimal(2.4));
        assertThat(resourcesPerDay.asDurationGivenWorkingDayOf(hours(8)),
                equalTo(hours(19).and(12, Granularity.MINUTES)));
        assertThat(resourcesPerDay.asDurationGivenWorkingDayOf(hours(10)),
                equalTo(hours(24)));
        assertThat(resourcesPerDay.asDurationGivenWorkingDayOf(hours(2)),
                equalTo(hours(4).and(48, Granularity.MINUTES)));
    }
View Full Code Here

                equalTo(hours(4).and(48, Granularity.MINUTES)));
    }

    @Test
    public void theSecondsAreRoundedHalfUpUnlessItIsMinusThanOneSecond() {
        ResourcesPerDay resourcesPerDay = ResourcesPerDay
                .amount(new BigDecimal(2.4));
        assertThat(resourcesPerDay.asDurationGivenWorkingDayOf(seconds(1)),
                equalTo(seconds(2)));
        assertThat(resourcesPerDay.asDurationGivenWorkingDayOf(seconds(2)),
                equalTo(seconds(5)));
    }
View Full Code Here

                equalTo(seconds(5)));
    }

    @Test
    public void asSecondsMustReturnOneIfResultingAmountFromMultiplicationIsGreaterThanZero() {
        ResourcesPerDay resourcesPerDay = ResourcesPerDay
                .amount(new BigDecimal(0.1));
        assertThat(resourcesPerDay.asDurationGivenWorkingDayOf(seconds(1)),
                equalTo(seconds(1)));
    }
View Full Code Here

                equalTo(seconds(1)));
    }

    @Test
    public void twoResourcesPerDayAreEqualsIfNormalizeToTheSameAmount() {
        ResourcesPerDay a = ResourcesPerDay.amount(new BigDecimal(2.00001));
        ResourcesPerDay b = ResourcesPerDay.amount(2);
        assertEquals(a.hashCode(), b.hashCode());
        assertEquals(a, b);
    }
View Full Code Here

        assertEquals(a, b);
    }

    @Test
    public void ifTheAmountIsZeroMustReturnZero() {
        ResourcesPerDay amount = ResourcesPerDay.amount(BigDecimal.ZERO);
        EffortDuration result = amount.asDurationGivenWorkingDayOf(hours(8));
        assertThat(result, equalTo(zero()));
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.workingday.ResourcesPerDay

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.