use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderHooksTest method shouldReturnTrueForNullDates.
@Test
public void shouldReturnTrueForNullDates() throws Exception {
// given
DateRange dateRange = new DateRange(null, null);
given(orderDatesService.getCalculatedDates(order)).willReturn(dateRange);
// when
boolean result = orderHooks.checkOrderDates(orderDD, order);
// then
assertTrue(result);
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderHooksTest method shouldReturnTrueForNullFromDate.
@Test
public void shouldReturnTrueForNullFromDate() throws Exception {
// given
DateRange dateRange = new DateRange(null, new Date());
given(orderDatesService.getCalculatedDates(order)).willReturn(dateRange);
// when
boolean result = orderHooks.checkOrderDates(orderDD, order);
// then
assertTrue(result);
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class Shift method buildDateRangeFrom.
private DateRange buildDateRangeFrom(final TimeRange timeRange, final Date date) {
DateTime dateTime = new DateTime(date);
DateTime midnight = dateTime.withTimeAtStartOfDay();
DateTime from;
DateTime to;
if (timeRange.startsDayBefore()) {
if (dateTime.toLocalTime().isBefore(timeRange.getFrom())) {
from = timeRange.getFrom().toDateTime(midnight.minusDays(1));
to = timeRange.getTo().toDateTime(midnight);
} else {
from = timeRange.getFrom().toDateTime(midnight);
to = timeRange.getTo().toDateTime(midnight.plusDays(1));
}
} else {
from = timeRange.getFrom().toDateTime(midnight);
to = timeRange.getTo().toDateTime(midnight);
}
return new DateRange(from.toDate(), to.toDate());
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderDatesServiceTest method shouldReturnDateRangeWithEffectiveStartAndEffectiveEndDate.
@Test
public final void shouldReturnDateRangeWithEffectiveStartAndEffectiveEndDate() {
// given
Date plannedStartDate = new DateTime(2012, 12, 30, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.DATE_FROM, plannedStartDate);
Date plannedEndDate = new DateTime(2013, 1, 1, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.DATE_TO, plannedEndDate);
Date correctedStartDate = new DateTime(2013, 1, 3, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.CORRECTED_DATE_FROM, correctedStartDate);
Date correctedEndDate = new DateTime(2013, 1, 5, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.CORRECTED_DATE_TO, correctedEndDate);
Date effectiveStartDate = new DateTime(2013, 2, 3, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.EFFECTIVE_DATE_FROM, effectiveStartDate);
Date effectiveEndDate = new DateTime(2013, 2, 8, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.EFFECTIVE_DATE_TO, effectiveEndDate);
// when
DateRange dateRange = orderDatesService.getCalculatedDates(order);
// then
assertEquals(effectiveStartDate, dateRange.getFrom());
assertEquals(effectiveEndDate, dateRange.getTo());
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderDatesServiceTest method shouldReturnDateRangeWithPlannedStartDate.
@Test
public final void shouldReturnDateRangeWithPlannedStartDate() {
// given
Date plannedStartDate = new DateTime(2013, 01, 01, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.DATE_FROM, plannedStartDate);
// when
DateRange dateRange = orderDatesService.getCalculatedDates(order);
// then
assertEquals(plannedStartDate, dateRange.getFrom());
assertNull(dateRange.getTo());
}
Aggregations