Search in sources :

Example 6 with DateRange

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());
}
Also used : DateRange(com.qcadoo.commons.dateTime.DateRange) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 7 with DateRange

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());
}
Also used : DateRange(com.qcadoo.commons.dateTime.DateRange) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 8 with DateRange

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());
}
Also used : DateRange(com.qcadoo.commons.dateTime.DateRange) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 9 with DateRange

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());
}
Also used : DateRange(com.qcadoo.commons.dateTime.DateRange) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 10 with DateRange

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");
}
Also used : DateRange(com.qcadoo.commons.dateTime.DateRange) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DateRange (com.qcadoo.commons.dateTime.DateRange)29 Test (org.junit.Test)25 Date (java.util.Date)24 DateTime (org.joda.time.DateTime)20 Entity (com.qcadoo.model.api.Entity)2 Shift (com.qcadoo.mes.basic.shift.Shift)1 EntityList (com.qcadoo.model.api.EntityList)1 LocalTime (org.joda.time.LocalTime)1