use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderDatesServiceTest method shouldReturnDateRangeWithCorrectedStartDate.
@Test
public final void shouldReturnDateRangeWithCorrectedStartDate() {
// given
Date plannedStartDate = new DateTime(2013, 1, 1, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.DATE_FROM, plannedStartDate);
Date correctedStartDate = new DateTime(2013, 1, 5, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.CORRECTED_DATE_FROM, correctedStartDate);
// when
DateRange dateRange = orderDatesService.getCalculatedDates(order);
// then
assertEquals(correctedStartDate, dateRange.getFrom());
assertNull(dateRange.getTo());
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderDatesServiceTest method shouldReturnDateRangeWithEffectiveStartDate3.
@Test
public final void shouldReturnDateRangeWithEffectiveStartDate3() {
// given
Date plannedStartDate = new DateTime(2013, 1, 1, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.DATE_FROM, plannedStartDate);
Date effectiveStartDate = new DateTime(2013, 2, 8, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.EFFECTIVE_DATE_FROM, effectiveStartDate);
// when
DateRange dateRange = orderDatesService.getCalculatedDates(order);
// then
assertEquals(effectiveStartDate, dateRange.getFrom());
assertNull(dateRange.getTo());
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderDatesServiceTest method shouldReturnDateRangeWithEffectiveEndDate3.
@Test
public final void shouldReturnDateRangeWithEffectiveEndDate3() {
// given
Date correctedEndDate = new DateTime(2013, 1, 5, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.CORRECTED_DATE_TO, correctedEndDate);
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
assertNull(dateRange.getFrom());
assertEquals(effectiveEndDate, dateRange.getTo());
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderDatesServiceTest method shouldReturnDateRangeWithCorrectedEndDate2.
@Test
public final void shouldReturnDateRangeWithCorrectedEndDate2() {
// given
Date correctedEndDate = new DateTime(2013, 1, 5, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.CORRECTED_DATE_TO, correctedEndDate);
// when
DateRange dateRange = orderDatesService.getCalculatedDates(order);
// then
assertNull(dateRange.getFrom());
assertEquals(correctedEndDate, dateRange.getTo());
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderHooksTest method shouldReturnFalseForInvalidOrderDates.
@Test
public void shouldReturnFalseForInvalidOrderDates() throws Exception {
// given
DateRange dateRange = new DateRange(new Date(), new Date(System.currentTimeMillis() - 10000));
given(orderDatesService.getCalculatedDates(order)).willReturn(dateRange);
given(orderDD.getField(OrderFields.FINISH_DATE)).willReturn(dateToField);
// when
boolean result = orderHooks.checkOrderDates(orderDD, order);
// then
assertFalse(result);
verify(order).addError(dateToField, "orders.validate.global.error.datesOrder");
}
Aggregations