Search in sources :

Example 21 with Shift

use of com.qcadoo.mes.basic.shift.Shift in project mes by qcadoo.

the class OrderRealizationDaysResolverTest method shouldResolveRealizationDay1.

@Test
public final void shouldResolveRealizationDay1() {
    // given
    DateTime startDate = new DateTime(2014, 8, 14, 10, 0, 0);
    List<Shift> shifts = ImmutableList.of(shift1, shift2, shift3);
    // when
    // - 1st order realization day is Thursday,
    // - it's a first day of order realization,
    // - shift starting order doesn't start day before,
    OrderRealizationDay realizationDay = orderRealizationDaysResolver.find(startDate, 1, true, shifts);
    // then
    assertRealizationDayState(realizationDay, 1, startDate.toLocalDate(), shifts);
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 22 with Shift

use of com.qcadoo.mes.basic.shift.Shift in project mes by qcadoo.

the class OrderRealizationDaysResolverTest method shouldNotResultInAnInfiniteCycleIfThereIsNoShiftsDefined.

@Test
public final void shouldNotResultInAnInfiniteCycleIfThereIsNoShiftsDefined() {
    // given
    DateTime startDate = new DateTime(2014, 8, 14, 3, 0, 0);
    List<Shift> shifts = ImmutableList.of();
    // when
    OrderRealizationDay realizationDay = orderRealizationDaysResolver.find(startDate, 1, true, shifts);
    // then
    assertRealizationDayState(realizationDay, 1, startDate.toLocalDate(), ImmutableList.<Shift>of());
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 23 with Shift

use of com.qcadoo.mes.basic.shift.Shift in project mes by qcadoo.

the class OrderRealizationDaysResolverTest method shouldProduceStreamWithCorrectFirstDayDate.

@Test
public final void shouldProduceStreamWithCorrectFirstDayDate() {
    // given
    DateTime startDate = new DateTime(2014, 12, 4, 23, 0, 0);
    List<Shift> shifts = ImmutableList.of(shift1, shift2, shift3);
    // when
    LazyStream<OrderRealizationDay> stream = orderRealizationDaysResolver.asStreamFrom(startDate, shifts);
    // then
    Optional<OrderRealizationDay> firstRealizationDay = FluentIterable.from(stream).limit(1).first();
    assertTrue(firstRealizationDay.isPresent());
    assertRealizationDayState(firstRealizationDay.get(), 1, startDate.toLocalDate(), ImmutableList.of(shift1));
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 24 with Shift

use of com.qcadoo.mes.basic.shift.Shift in project mes by qcadoo.

the class OrderRealizationDaysResolverTest method shouldNotResultInAnInfiniteCycleIfShiftsNeverWorks.

@Test
public final void shouldNotResultInAnInfiniteCycleIfShiftsNeverWorks() {
    // given
    DateTime startDate = new DateTime(2014, 8, 14, 3, 0, 0);
    Shift lazyShift = mockShift(new TimeRange(SH_1_START, SH_1_END), ImmutableSet.<Integer>of());
    List<Shift> shifts = ImmutableList.of(lazyShift);
    // when
    OrderRealizationDay realizationDay = orderRealizationDaysResolver.find(startDate, 1, true, shifts);
    // then
    assertRealizationDayState(realizationDay, 1, startDate.toLocalDate(), ImmutableList.<Shift>of());
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) TimeRange(com.qcadoo.commons.dateTime.TimeRange) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 25 with Shift

use of com.qcadoo.mes.basic.shift.Shift in project mes by qcadoo.

the class OrderRealizationDaysResolverTest method shouldProduceStreamOfRealizationDays1.

@Test
public final void shouldProduceStreamOfRealizationDays1() {
    // given
    DateTime startDate = new DateTime(2014, 8, 14, 3, 0, 0);
    List<Shift> shifts = ImmutableList.of(shift1, shift2, shift3);
    // when
    LazyStream<OrderRealizationDay> stream = orderRealizationDaysResolver.asStreamFrom(startDate, shifts);
    // then
    OrderRealizationDay[] streamVals = FluentIterable.from(stream).limit(5).toArray(OrderRealizationDay.class);
    assertRealizationDayState(streamVals[0], 0, startDate.toLocalDate().minusDays(1), ImmutableList.of(shift1));
    assertRealizationDayState(streamVals[1], 1, startDate.toLocalDate(), shifts);
    assertRealizationDayState(streamVals[2], 2, startDate.toLocalDate().plusDays(1), shifts);
    assertRealizationDayState(streamVals[3], 5, startDate.toLocalDate().plusDays(4), shifts);
    assertRealizationDayState(streamVals[4], 6, startDate.toLocalDate().plusDays(5), shifts);
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

Shift (com.qcadoo.mes.basic.shift.Shift)37 DateTime (org.joda.time.DateTime)30 Entity (com.qcadoo.model.api.Entity)12 Test (org.junit.Test)11 TimeRange (com.qcadoo.commons.dateTime.TimeRange)9 DateTimeRange (com.qcadoo.mes.basic.util.DateTimeRange)8 Date (java.util.Date)7 LocalTime (org.joda.time.LocalTime)7 LocalDate (org.joda.time.LocalDate)6 BigDecimal (java.math.BigDecimal)3 DailyProgressContainer (com.qcadoo.mes.productionPerShift.domain.DailyProgressContainer)2 ErrorMessage (com.qcadoo.model.api.validators.ErrorMessage)2 Calendar (java.util.Calendar)2 HSSFCell (org.apache.poi.hssf.usermodel.HSSFCell)2 Function (com.google.common.base.Function)1 Optional (com.google.common.base.Optional)1 Predicate (com.google.common.base.Predicate)1 FluentIterable (com.google.common.collect.FluentIterable)1 Lists (com.google.common.collect.Lists)1 DateRange (com.qcadoo.commons.dateTime.DateRange)1