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);
}
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());
}
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));
}
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());
}
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);
}
Aggregations