You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2016/08/19 12:18:37 UTC
[03/25] zest-java git commit: ZEST-124 - Replaced Joda Time API with
Java Time API,
and I also removed the java.util.Date support and all uses except where
required when interfacing with other systems.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
index 8044a3e..ca0f9fc 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
@@ -19,7 +19,8 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueComposite;
@@ -38,11 +39,11 @@ public interface Leg
{
Association<Location> loadLocation();
- Property<Date> loadTime();
+ Property<LocalDate> loadDate();
Association<Voyage> voyage();
- Property<Date> unloadTime();
+ Property<LocalDate> unloadDate();
Association<Location> unloadLocation();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
index dca0c20..5391319 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage;
-import java.util.Date;
+import java.time.LocalDate;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueComposite;
@@ -37,7 +37,7 @@ public interface CarrierMovement
Association<Location> arrivalLocation();
- Property<Date> departureTime();
+ Property<LocalDate> departureDate();
- Property<Date> arrivalTime();
+ Property<LocalDate> arrivalDate();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java
index 9c0dccb..0237052 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java
@@ -20,7 +20,10 @@
package org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form;
import com.google.code.joliratools.StatelessAjaxEventBehavior;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.LocalTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
import java.util.Map;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -35,9 +38,8 @@ import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.validation.validator.DateValidator;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalTime;
+
+import static java.util.Date.from;
//import org.wicketstuff.stateless.StatelessAjaxEventBehavior;
@@ -50,18 +52,17 @@ public class DateTextFieldWithPicker extends DateTextField
DatePicker datePicker;
// Configurable widget options
- LocalDate earliestDate;
- LocalDate selectedDate;
+ private LocalDate earliestDate;
+ private LocalDate selectedDate;
- final static String YUI_DATE_FORMAT = "MM/dd/yyyy";
+ private final static DateTimeFormatter YUI_DATE_FORMAT = DateTimeFormatter.ofPattern( "MM/dd/yyyy" );
public DateTextFieldWithPicker( String id, String label, Component model )
{
-// this( id, new PropertyModel<Date>( model, id ), new StyleDateConverter( "S-", true ) );
- this( id, label, new PropertyModel<Date>( model, id ), new PatternDateConverter( "yyyy-MM-dd", true ) );
+ this( id, label, new PropertyModel<>( model, id ), new PatternDateConverter( "yyyy-MM-dd", true ) );
}
- public DateTextFieldWithPicker( String id, String label, IModel<Date> model, DateConverter converter )
+ public DateTextFieldWithPicker( String id, String label, IModel<java.util.Date> model, DateConverter converter )
{
super( id, model, converter );
@@ -189,9 +190,7 @@ public class DateTextFieldWithPicker extends DateTextField
// Input field validation - date should be _after_ minimumDate (not the same)
LocalDate minimumDate = newEarliestDate.minusDays( 1 );
- Date convertedMinimumDate = new DateTime( minimumDate.toDateTime( new LocalTime() ) ).toDate();
- add( DateValidator.minimum( convertedMinimumDate ) );
-
+ add( DateValidator.minimum( from( minimumDate.atTime( LocalTime.now() ).toInstant( ZoneOffset.UTC ) ) ) );
return this;
}
@@ -213,17 +212,17 @@ public class DateTextFieldWithPicker extends DateTextField
{
if( selectedDate != null )
{
- return selectedDate.toString( YUI_DATE_FORMAT );
+ return YUI_DATE_FORMAT.format( selectedDate );
}
// Select today or earliest date (if later) as default
return earliestDate == null ?
- new LocalDate().toString( YUI_DATE_FORMAT ) :
- earliestDate.toString( YUI_DATE_FORMAT );
+ YUI_DATE_FORMAT.format( LocalDate.now() ) :
+ YUI_DATE_FORMAT.format( earliestDate );
}
private String getEarliestDateStr()
{
- return earliestDate == null ? "" : earliestDate.toString( YUI_DATE_FORMAT );
+ return earliestDate == null ? "" : YUI_DATE_FORMAT.format( earliestDate );
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/prevnext/PrevNext.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/prevnext/PrevNext.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/prevnext/PrevNext.java
index 3c69a82..c6c955e 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/prevnext/PrevNext.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/prevnext/PrevNext.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.prevnext;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -45,14 +46,14 @@ public class PrevNext extends Panel
private static final long serialVersionUID = 1L;
};
- public static void registerIds( Session session, ArrayList<String> ids )
+ public static void registerIds( Session session, List<String> ids )
{
if( ids == null || ids.isEmpty() )
{
throw new RuntimeException( "Please register a list of ids." );
}
- session.setMetaData( PREV_NEXT_PANEL_KEY, ids );
+ session.setMetaData( PREV_NEXT_PANEL_KEY, (Serializable) ids );
session.bind();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.html
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.html b/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.html
index e16a0a2..a0f6d15 100644
--- a/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.html
+++ b/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.html
@@ -93,9 +93,9 @@
<tr wicket:id="legs">
<td wicket:id="voyage"></td>
<td wicket:id="loadLocation"></td>
- <td wicket:id="loadTime"></td>
+ <td wicket:id="loadDate"></td>
<td wicket:id="unloadLocation"></td>
- <td wicket:id="unloadTime"></td>
+ <td wicket:id="unloadDate"></td>
</tr>
</tbody>
</table>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.html
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.html b/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.html
index fc3ea2e..3cf259f 100644
--- a/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.html
+++ b/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.html
@@ -51,9 +51,9 @@
<tr wicket:id="legs">
<td wicket:id="voyage"></td>
<td wicket:id="loadLocation"></td>
- <td wicket:id="loadTime"></td>
+ <td wicket:id="loadDate"></td>
<td wicket:id="unloadLocation"></td>
- <td wicket:id="unloadTime"></td>
+ <td wicket:id="unloadDate"></td>
</tr>
</tbody>
</table>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
index fffcb68..2256c1a 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
@@ -19,12 +19,11 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.ZoneOffset;
import java.util.List;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.junit.Before;
-import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.sample.dcicargo.sample_a.bootstrap.test.TestApplication;
import org.apache.zest.sample.dcicargo.sample_a.context.support.FoundNoRoutesException;
import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
@@ -37,10 +36,13 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Transport
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
+import org.junit.Before;
+import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* Test of Book New Cargo use case.
@@ -51,10 +53,10 @@ import static org.junit.Assert.*;
* Test method names describe the test purpose. The prefix refers to the step in the use case.
*/
public class BookNewCargoTest
- extends TestApplication
+ extends TestApplication
{
- private static final Date TODAY = new Date();
+ private static final LocalDate TODAY = LocalDate.now();
private UnitOfWorkFactory uowf;
@Before
@@ -66,7 +68,8 @@ public class BookNewCargoTest
}
@Test( expected = RouteException.class )
- public void deviation2a_OriginAndDestinationSame() throws Exception
+ public void deviation2a_OriginAndDestinationSame()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -75,7 +78,8 @@ public class BookNewCargoTest
}
@Test( expected = RouteException.class )
- public void deviation_2b_1_DeadlineInThePastNotAccepted() throws Exception
+ public void deviation_2b_1_DeadlineInThePastNotAccepted()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -85,7 +89,8 @@ public class BookNewCargoTest
}
@Test( expected = RouteException.class )
- public void deviation_2b_2_DeadlineTodayIsTooEarly() throws Exception
+ public void deviation_2b_2_DeadlineTodayIsTooEarly()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -95,7 +100,8 @@ public class BookNewCargoTest
}
@Test
- public void deviation_2b_3_DeadlineTomorrowIsOkay() throws Exception
+ public void deviation_2b_3_DeadlineTomorrowIsOkay()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -105,7 +111,8 @@ public class BookNewCargoTest
}
@Test
- public void step_2_CreateNewCargo() throws Exception
+ public void step_2_CreateNewCargo()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -124,16 +131,22 @@ public class BookNewCargoTest
// Test route specification
assertThat( cargo.routeSpecification().get().destination().get(), is( equalTo( STOCKHOLM ) ) );
// day(17) here is calculated a few milliseconds after initial day(17), so it will be later...
- assertThat( cargo.routeSpecification().get().arrivalDeadline().get(), equalTo( day( 17 ) ));
+ assertThat( cargo.routeSpecification().get().arrivalDeadline().get(), equalTo( day( 17 ) ) );
// (Itinerary is not assigned yet)
// Test derived delivery snapshot
Delivery delivery = cargo.delivery().get();
- assertThat( delivery.timestamp().get().after( TODAY ), is( equalTo( true ) ) ); // TODAY is set first
+ assertThat( delivery.timestamp()
+ .get()
+ .isAfter( TODAY.atStartOfDay()
+ .toInstant( ZoneOffset.UTC ) ), is( equalTo( true ) ) ); // TODAY is set first
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.NOT_ROUTED ) ) );
assertThat( delivery.transportStatus().get(), is( equalTo( TransportStatus.NOT_RECEIVED ) ) );
- assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
+ assertThat( delivery.nextExpectedHandlingEvent()
+ .get()
+ .handlingEventType()
+ .get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().location().get(), is( equalTo( HONGKONG ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( null ) ) );
assertThat( delivery.lastHandlingEvent().get(), is( equalTo( null ) ) );
@@ -145,7 +158,8 @@ public class BookNewCargoTest
}
@Test( expected = FoundNoRoutesException.class )
- public void deviation_3a_NoRoutesCanBeThatFast() throws Exception
+ public void deviation_3a_NoRoutesCanBeThatFast()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -159,7 +173,8 @@ public class BookNewCargoTest
}
@Test
- public void step_3_CalculatePossibleRoutes() throws Exception
+ public void step_3_CalculatePossibleRoutes()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -174,7 +189,7 @@ public class BookNewCargoTest
List<Itinerary> routeCandidates = new BookNewCargo( cargo ).routeCandidates();
// Check possible routes
- for (Itinerary itinerary : routeCandidates)
+ for( Itinerary itinerary : routeCandidates )
{
assertThat( "First load location equals origin location.",
itinerary.firstLeg().loadLocation().get(),
@@ -183,13 +198,15 @@ public class BookNewCargoTest
itinerary.lastLeg().unloadLocation().get(),
is( equalTo( cargo.routeSpecification().get().destination().get() ) ) );
assertThat( "Cargo will be delivered in time.",
- itinerary.finalArrivalDate().before( cargo.routeSpecification().get().arrivalDeadline().get() ),
+ itinerary.finalArrivalDate()
+ .isBefore( cargo.routeSpecification().get().arrivalDeadline().get() ),
is( equalTo( true ) ) );
}
}
@Test
- public void step_5_AssignCargoToRoute() throws Exception
+ public void step_5_AssignCargoToRoute()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -197,7 +214,7 @@ public class BookNewCargoTest
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
// Create valid cargo
- Date deadline = day( 30 );
+ LocalDate deadline = day( 30 );
TrackingId trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, deadline ).book();
Cargo cargo = uow.get( Cargo.class, trackingId.id().get() );
@@ -219,6 +236,6 @@ public class BookNewCargoTest
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.ROUTED ) ) );
// ETA (= Unload time of last Leg) is before Deadline (set in previous test)
- assertTrue( delivery.eta().get().before( deadline ) );
+ assertTrue( delivery.eta().get().isBefore( deadline ) );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
index 53c90d4..a5455c8 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
@@ -19,11 +19,10 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking;
-import java.util.Date;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.junit.Before;
-import org.junit.Test;
+import java.time.LocalDate;
+import java.time.ZoneOffset;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.sample.dcicargo.sample_a.bootstrap.test.TestApplication;
import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity;
@@ -39,10 +38,19 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingE
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
+import org.junit.Before;
+import org.junit.Test;
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType.*;
+import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType.CLAIM;
+import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType.CUSTOMS;
+import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType.LOAD;
+import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType.UNLOAD;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* Tests of the Build Delivery Snapshot subfunction use case.
@@ -56,9 +64,9 @@ import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.Ha
* FIXME: Test methods call each other to allow ordered execution, ie. tests are not indepedants !
*/
public class BuildDeliverySnapshotTest
- extends TestApplication
+ extends TestApplication
{
- final Date TODAY = new Date();
+ private final LocalDate TODAY = LocalDate.now();
private Location HONGKONG;
private Location STOCKHOLM;
@@ -110,36 +118,40 @@ public class BuildDeliverySnapshotTest
leg( V200T, NEWYORK, DALLAS, day( 9 ), day( 12 ) ),
leg( V300A, DALLAS, STOCKHOLM, day( 13 ), day( 16 ) )
);
-
-
}
// DERIVE WITH ROUTE SPECIFICATION ==============================================================================
@Test( expected = RouteException.class )
- public void deviation_2a_InvalidRouteSpecification_sameLocations() throws Exception
+ public void deviation_2a_InvalidRouteSpecification_sameLocations()
+ throws Exception
{
RouteSpecification routeSpec = routeSpecification( HONGKONG, HONGKONG, day( 20 ) );
new BuildDeliverySnapshot( routeSpec ).get();
}
@Test( expected = RouteException.class )
- public void deviation_2b_InvalidRouteSpecification_tooEarlyDeadline() throws Exception
+ public void deviation_2b_InvalidRouteSpecification_tooEarlyDeadline()
+ throws Exception
{
RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, TODAY );
new BuildDeliverySnapshot( routeSpec ).get();
}
@Test
- public void deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification() throws Exception
+ public void deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification()
+ throws Exception
{
RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, day( 20 ) );
Delivery delivery = new BuildDeliverySnapshot( routeSpec ).get();
- assertThat( delivery.timestamp().get().after( TODAY ), is( equalTo( true ) ) ); // TODAY is set first
+ assertThat( delivery.timestamp().get().isAfter( TODAY.atStartOfDay().toInstant( ZoneOffset.UTC ) ), is( equalTo( true ) ) ); // TODAY is set first
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.NOT_ROUTED ) ) );
assertThat( delivery.transportStatus().get(), is( equalTo( TransportStatus.NOT_RECEIVED ) ) );
- assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
+ assertThat( delivery.nextExpectedHandlingEvent()
+ .get()
+ .handlingEventType()
+ .get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().location().get(), is( equalTo( HONGKONG ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( null ) ) );
assertThat( delivery.lastHandlingEvent().get(), is( equalTo( null ) ) );
@@ -150,11 +162,11 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.isUnloadedAtDestination().get(), is( equalTo( false ) ) );
}
-
// DERIVE WITH NON-ROUTED CARGO ==============================================================================
@Test
- public void deviation_2c_ItineraryIsUnknown_buildFromNonRoutedCargo() throws Exception
+ public void deviation_2c_ItineraryIsUnknown_buildFromNonRoutedCargo()
+ throws Exception
{
deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification();
@@ -162,13 +174,14 @@ public class BuildDeliverySnapshotTest
RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, day( 20 ) );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
Delivery delivery = new BuildDeliverySnapshot( routeSpec ).get();
- Cargo cargo = CARGOS.createCargo( routeSpec, delivery, "ABCD" );
+ CARGOS.createCargo( routeSpec, delivery, "ABCD" );
// Same as previous test (just build from cargo instead)
- assertThat( delivery.timestamp().get().after( TODAY ), is( equalTo( true ) ) ); // TODAY is set first
+ assertThat( delivery.timestamp().get().isAfter( TODAY.atStartOfDay().toInstant( ZoneOffset.UTC ) ), is( equalTo( true ) ) ); // TODAY is set first
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.NOT_ROUTED ) ) );
assertThat( delivery.transportStatus().get(), is( equalTo( TransportStatus.NOT_RECEIVED ) ) );
- assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
+ assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(),
+ is( equalTo( HandlingEventType.RECEIVE ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().location().get(), is( equalTo( HONGKONG ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( null ) ) );
assertThat( delivery.lastHandlingEvent().get(), is( equalTo( null ) ) );
@@ -179,11 +192,11 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.isUnloadedAtDestination().get(), is( equalTo( false ) ) );
}
-
// DERIVE WITH ROUTE SPECIFICATION + ITINERARY (Routed cargo) ==============================================
@Test
- public void deviation_2d_UnsatisfyingItinerary_wrongOrigin() throws Exception
+ public void deviation_2d_UnsatisfyingItinerary_wrongOrigin()
+ throws Exception
{
deviation_2c_ItineraryIsUnknown_buildFromNonRoutedCargo();
@@ -205,7 +218,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_2d_UnsatisfyingItinerary_wrongDestination() throws Exception
+ public void deviation_2d_UnsatisfyingItinerary_wrongDestination()
+ throws Exception
{
deviation_2d_UnsatisfyingItinerary_wrongOrigin();
@@ -220,7 +234,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_2d_UnsatisfyingItinerary_missedDeadline() throws Exception
+ public void deviation_2d_UnsatisfyingItinerary_missedDeadline()
+ throws Exception
{
deviation_2d_UnsatisfyingItinerary_wrongDestination();
@@ -230,17 +245,18 @@ public class BuildDeliverySnapshotTest
Delivery delivery = new BuildDeliverySnapshot( cargo ).get();
// Route specification not satisfied by itinerary
- assertFalse( routeSpec.arrivalDeadline().get().after( itinerary.finalArrivalDate() ) );
+ assertFalse( routeSpec.arrivalDeadline().get().isAfter( itinerary.finalArrivalDate() ) );
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.MISROUTED ) ) );
}
@Test
- public void deviation_3a_CargoHasNoHandlingHistory() throws Exception
+ public void deviation_3a_CargoHasNoHandlingHistory()
+ throws Exception
{
deviation_2d_UnsatisfyingItinerary_missedDeadline();
- Date arrival = day( 16 );
- Date deadline = day( 20 );
+ LocalDate arrival = day( 16 );
+ LocalDate deadline = day( 20 );
// Itinerary will satisfy route specification
RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, deadline );
cargo.routeSpecification().set( routeSpec );
@@ -249,12 +265,18 @@ public class BuildDeliverySnapshotTest
// Route specification satisfied by itinerary
assertThat( itinerary.firstLeg().loadLocation().get(), is( equalTo( routeSpec.origin().get() ) ) );
assertThat( itinerary.lastLeg().unloadLocation().get(), is( equalTo( routeSpec.destination().get() ) ) );
- assertTrue( routeSpec.arrivalDeadline().get().after( itinerary.finalArrivalDate() ) );
+ assertTrue( routeSpec.arrivalDeadline().get().isAfter( itinerary.finalArrivalDate() ) );
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.ROUTED ) ) );
- assertThat( delivery.timestamp().get().after( TODAY ), is( equalTo( true ) ) ); // TODAY is set first
+ assertThat( delivery.timestamp()
+ .get()
+ .isAfter( TODAY.atStartOfDay()
+ .toInstant( ZoneOffset.UTC ) ), is( equalTo( true ) ) ); // TODAY is set first
assertThat( delivery.transportStatus().get(), is( equalTo( TransportStatus.NOT_RECEIVED ) ) );
- assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
+ assertThat( delivery.nextExpectedHandlingEvent()
+ .get()
+ .handlingEventType()
+ .get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().location().get(), is( equalTo( HONGKONG ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( null ) ) );
assertThat( delivery.lastHandlingEvent().get(), is( equalTo( null ) ) );
@@ -265,11 +287,11 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.isUnloadedAtDestination().get(), is( equalTo( false ) ) );
}
-
// DERIVE WITH ROUTE SPECIFICATION + ITINERARY + LAST HANDLING EVENT ============================================
@Test
- public void deviation_4a_RECEIVE_1a_UnexpectedPort() throws Exception
+ public void deviation_4a_RECEIVE_1a_UnexpectedPort()
+ throws Exception
{
deviation_3a_CargoHasNoHandlingHistory();
@@ -295,7 +317,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4a_RECEIVE_1b_ExpectedPort() throws Exception
+ public void deviation_4a_RECEIVE_1b_ExpectedPort()
+ throws Exception
{
deviation_4a_RECEIVE_1a_UnexpectedPort();
@@ -317,9 +340,9 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( V100S ) ) );
}
-
@Test
- public void deviation_4b_LOAD_2a_UnexpectedPort() throws Exception
+ public void deviation_4b_LOAD_2a_UnexpectedPort()
+ throws Exception
{
deviation_4a_RECEIVE_1b_ExpectedPort();
@@ -341,7 +364,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4b_LOAD_2b_ExpectedPort() throws Exception
+ public void deviation_4b_LOAD_2b_ExpectedPort()
+ throws Exception
{
deviation_4b_LOAD_2a_UnexpectedPort();
@@ -365,7 +389,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary() throws Exception
+ public void deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary()
+ throws Exception
{
deviation_4b_LOAD_2b_ExpectedPort();
@@ -387,7 +412,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary() throws Exception
+ public void deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary()
+ throws Exception
{
deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary();
@@ -414,9 +440,9 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( V200T ) ) );
}
-
@Test
- public void deviation_4c_UNLOAD_1a_UnexpectedPort() throws Exception
+ public void deviation_4c_UNLOAD_1a_UnexpectedPort()
+ throws Exception
{
deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary();
@@ -455,7 +481,7 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.MISROUTED ) ) );
// Old planned arrival time is still satisfying new deadline
- assertTrue( routeSpec.arrivalDeadline().get().after( itinerary.finalArrivalDate() ) );
+ assertTrue( routeSpec.arrivalDeadline().get().isAfter( itinerary.finalArrivalDate() ) );
// We don't know what's next before a new itinerary has been chosen
assertThat( delivery.nextExpectedHandlingEvent().get(), is( equalTo( null ) ) );
@@ -474,10 +500,10 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.isUnloadedAtDestination().get(), is( equalTo( false ) ) );
// New itinerary that satisfy the new route specification. New origin departure from Tokyo.
- Date arrival= day( 19 );
+ LocalDate arrival = day( 19 );
itinerary = itinerary(
- leg( V400S, TOKYO, HAMBURG, day( 9 ), day( 16 ) ),
- leg( V500S, HAMBURG, STOCKHOLM, day( 17 ), arrival )
+ leg( V400S, TOKYO, HAMBURG, day( 9 ), day( 16 ) ),
+ leg( V500S, HAMBURG, STOCKHOLM, day( 17 ), arrival )
);
// Customer reroutes cargo. This is a possible step in the cargo booking process.
@@ -509,7 +535,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4c_UNLOAD_1b_ExpectedMidpointLocation() throws Exception
+ public void deviation_4c_UNLOAD_1b_ExpectedMidpointLocation()
+ throws Exception
{
deviation_4c_UNLOAD_1a_UnexpectedPort();
@@ -535,7 +562,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4c_UNLOAD_1c_Destination() throws Exception
+ public void deviation_4c_UNLOAD_1c_Destination()
+ throws Exception
{
deviation_4c_UNLOAD_1b_ExpectedMidpointLocation();
@@ -562,9 +590,9 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( null ) ) );
}
-
@Test
- public void deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort() throws Exception
+ public void deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort()
+ throws Exception
{
deviation_4c_UNLOAD_1c_Destination();
@@ -589,9 +617,9 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.nextExpectedHandlingEvent().get(), is( equalTo( null ) ) );
}
-
@Test
- public void deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort() throws Exception
+ public void deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort()
+ throws Exception
{
deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort();
@@ -617,7 +645,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4e_CLAIM_1b_CargoIsInDestinationPort() throws Exception
+ public void deviation_4e_CLAIM_1b_CargoIsInDestinationPort()
+ throws Exception
{
deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
index 7a801ea..416c3ab 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling;
-import java.util.Date;
+import java.time.LocalDate;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -49,10 +49,10 @@ import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.Ha
public class RegisterHandlingEventTest
extends TestApplication
{
- Date time;
- String trackId;
- String msg;
- private Date arrival;
+ private LocalDate date;
+ private String trackId;
+ private String msg;
+ private LocalDate arrival;
private Cargo cargo;
private TrackingId trackingId;
private Cargos CARGOS;
@@ -84,7 +84,7 @@ public class RegisterHandlingEventTest
arrival = day( 16 ) )
);
new BookNewCargo( cargo, itinerary ).assignCargoToRoute();
- time = day( 1 );
+ date = day( 1 );
trackId = trackingId.id().get();
}
@@ -93,62 +93,62 @@ public class RegisterHandlingEventTest
@Test
public void deviation_2a_MissingRegistrationTime() throws Exception
{
- msg = register( null, time, trackId, "RECEIVE", "CNHKG", null );
+ msg = register( null, date, trackId, "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Registration time was null. All parameters have to be passed." ) ) );
}
@Test
public void deviation_2a_MissingCompletionTime() throws Exception
{
- msg = register( time, null, trackId, "RECEIVE", "CNHKG", null );
+ msg = register( date, null, trackId, "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Completion time was null. All parameters have to be passed." ) ) );
}
@Test
public void deviation_2a_MissingTrackingId() throws Exception
{
- msg = register( time, time, null, "RECEIVE", "CNHKG", null );
+ msg = register( date, date, null, "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Tracking id was null. All parameters have to be passed." ) ) );
}
@Test
public void deviation_2a_EmptyTrackingId() throws Exception
{
- msg = register( time, time, "", "RECEIVE", "CNHKG", null );
+ msg = register( date, date, "", "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Tracking id cannot be empty." ) ) );
}
@Test
public void deviation_2a_MissingEventType() throws Exception
{
- msg = register( time, time, trackId, null, "CNHKG", null );
+ msg = register( date, date, trackId, null, "CNHKG", null );
assertThat( msg, is( equalTo( "Event type was null. All parameters have to be passed." ) ) );
}
@Test
public void deviation_2a_EmptyEventType() throws Exception
{
- msg = register( time, time, trackId, "", "CNHKG", null );
+ msg = register( date, date, trackId, "", "CNHKG", null );
assertThat( msg, is( equalTo( "Event type cannot be empty." ) ) );
}
@Test
public void deviation_2a_MissingUnlocode() throws Exception
{
- msg = register( time, time, trackId, "RECEIVE", null, null );
+ msg = register( date, date, trackId, "RECEIVE", null, null );
assertThat( msg, is( equalTo( "UnLocode was null. All parameters have to be passed." ) ) );
}
@Test
public void deviation_2a_EmptyUnlocode() throws Exception
{
- msg = register( time, time, trackId, "RECEIVE", "", null );
+ msg = register( date, date, trackId, "RECEIVE", "", null );
assertThat( msg, is( equalTo( "UnLocode cannot be empty." ) ) );
}
@Test
public void step_2_CompleteData__Receive_in_Hong_Kong() throws Exception
{
- new RegisterHandlingEvent( time, time, trackId, "RECEIVE", "CNHKG", null ).register();
+ new RegisterHandlingEvent( date, date, trackId, "RECEIVE", "CNHKG", null ).register();
}
@@ -157,7 +157,7 @@ public class RegisterHandlingEventTest
@Test
public void deviation_3a_HandlingTypeNotRecognized() throws Exception
{
- msg = register( time, time, trackId, "RECEIPT", "CNHKG", null );
+ msg = register( date, date, trackId, "RECEIPT", "CNHKG", null );
assertThat( msg, is( equalTo(
"'RECEIPT' is not a valid handling event type. Valid types are: [RECEIVE, LOAD, UNLOAD, CUSTOMS, CLAIM]" ) ) );
}
@@ -165,7 +165,7 @@ public class RegisterHandlingEventTest
@Test
public void deviation_3b_NoCargoWithTrackingId() throws Exception
{
- msg = register( time, time, "XXX", "RECEIVE", "CNHKG", null );
+ msg = register( date, date, "XXX", "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Found no cargo with tracking id 'XXX'." ) ) );
}
@@ -175,42 +175,42 @@ public class RegisterHandlingEventTest
TrackingId nonRoutedTrackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( 17 ) ).createCargo( "NonRoutedCargo" );
String nonRouted = nonRoutedTrackingId.id().get();
- msg = register( time, time, nonRouted, "RECEIVE", "CNHKG", null );
+ msg = register( date, date, nonRouted, "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Can't create handling event for non-routed cargo '" + nonRouted + "'." ) ) );
}
@Test
public void deviation_3d_NoLocationWithUnlocode() throws Exception
{
- msg = register( time, time, trackId, "RECEIVE", "ZZZZZ", null );
+ msg = register( date, date, trackId, "RECEIVE", "ZZZZZ", null );
assertThat( msg, is( equalTo( "Unknown location: ZZZZZ" ) ) );
}
@Test
public void deviation_3e_1a_MissingVoyageNumber() throws Exception
{
- msg = register( time, time, trackId, "LOAD", "CNHKG", null );
+ msg = register( date, date, trackId, "LOAD", "CNHKG", null );
assertThat( msg, is( equalTo( "Handling event LOAD requires a voyage. No voyage number submitted." ) ) );
}
@Test
public void deviation_3e_1b_MissingVoyage() throws Exception
{
- msg = register( time, time, trackId, "LOAD", "CNHKG", "V600S" );
+ msg = register( date, date, trackId, "LOAD", "CNHKG", "V600S" );
assertThat( msg, is( equalTo( "Found no voyage with voyage number 'V600S'." ) ) );
}
@Test
public void deviation_3f_SkipVoyageNumberSilentlyWhenProhibited() throws Exception
{
- new RegisterHandlingEvent( time, time, trackId, "RECEIVE", "CNHKG", "V100S" ).register();
+ new RegisterHandlingEvent( date, date, trackId, "RECEIVE", "CNHKG", "V100S" ).register();
assertThat( cargo.delivery().get().currentVoyage().get(), is( equalTo( null ) ) );
}
@Test
public void step_3_to_5_ValidRegistration__Load_in_Hong_Kong() throws Exception
{
- new RegisterHandlingEvent( time, time, trackId, "LOAD", "CNHKG", "V100S" ).register();
+ new RegisterHandlingEvent( date, date, trackId, "LOAD", "CNHKG", "V100S" ).register();
Delivery delivery = cargo.delivery().get();
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.ROUTED ) ) );
@@ -226,8 +226,8 @@ public class RegisterHandlingEventTest
}
- private String register( Date registrationTime,
- Date completionTime,
+ private String register( LocalDate registrationDate,
+ LocalDate completionDate,
String trackingIdString,
String eventTypeString,
String unLocodeString,
@@ -235,8 +235,8 @@ public class RegisterHandlingEventTest
{
try
{
- new RegisterHandlingEvent( registrationTime,
- completionTime,
+ new RegisterHandlingEvent( registrationDate,
+ completionDate,
trackingIdString,
eventTypeString,
unLocodeString,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/GraphTraversalService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/GraphTraversalService.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/GraphTraversalService.java
index 8e09c0d..754188b 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/GraphTraversalService.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/GraphTraversalService.java
@@ -21,7 +21,7 @@ package org.apache.zest.sample.dcicargo.pathfinder_b.api;
import java.rmi.Remote;
import java.rmi.RemoteException;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.List;
/**
@@ -40,7 +40,7 @@ public interface GraphTraversalService extends Remote
*
* @throws RemoteException RMI problem
*/
- List<TransitPath> findShortestPath( Date departureDate, String originUnLocode, String destinationUnLocode )
+ List<TransitPath> findShortestPath( LocalDate departureDate, String originUnLocode, String destinationUnLocode )
throws RemoteException;
List<TransitPath> getVoyages()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitEdge.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitEdge.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitEdge.java
index 98dd39c..82174d5 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitEdge.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitEdge.java
@@ -20,7 +20,7 @@
package org.apache.zest.sample.dcicargo.pathfinder_b.api;
import java.io.Serializable;
-import java.util.Date;
+import java.time.LocalDate;
/**
* Represents an edge in a path through a graph,
@@ -32,23 +32,23 @@ public final class TransitEdge implements Serializable
private final String voyageNumber;
private final String fromUnLocode;
private final String toUnLocode;
- private final Date fromDate;
- private final Date toDate;
+ private final LocalDate fromDate;
+ private final LocalDate toDate;
/**
* Constructor.
*
- * @param voyageNumber
- * @param fromUnLocode
- * @param toUnLocode
- * @param fromDate
- * @param toDate
+ * @param voyageNumber The voyage number
+ * @param fromUnLocode The UNLO code of the originating port
+ * @param toUnLocode The UNLO code of the destination port
+ * @param fromDate The starting date of the voyage
+ * @param toDate The last day of the voyage
*/
public TransitEdge( final String voyageNumber,
final String fromUnLocode,
final String toUnLocode,
- final Date fromDate,
- final Date toDate
+ final LocalDate fromDate,
+ final LocalDate toDate
)
{
this.voyageNumber = voyageNumber;
@@ -73,12 +73,12 @@ public final class TransitEdge implements Serializable
return toUnLocode;
}
- public Date getFromDate()
+ public LocalDate getFromDate()
{
return fromDate;
}
- public Date getToDate()
+ public LocalDate getToDate()
{
return toDate;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitPath.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitPath.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitPath.java
index 818e9ca..d03403e 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitPath.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitPath.java
@@ -20,7 +20,6 @@
package org.apache.zest.sample.dcicargo.pathfinder_b.api;
import java.io.Serializable;
-import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.List;
@@ -64,11 +63,11 @@ public final class TransitPath implements Serializable
{
sb.append( "\n Leg " ).append( i );
sb.append( " Load " );
- sb.append( new SimpleDateFormat( "yyyy-MM-dd" ).format( edge.getFromDate() ) );
+ sb.append( edge.getFromDate() );
sb.append( " " ).append( edge.getFromUnLocode() );
sb.append( " " ).append( edge.getVoyageNumber() );
sb.append( " Unload " );
- sb.append( new SimpleDateFormat( "yyyy-MM-dd" ).format( edge.getToDate() ) );
+ sb.append( edge.getToDate() );
sb.append( " " ).append( edge.getToUnLocode() );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphDAO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphDAO.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphDAO.java
index 46cea8c..3ff7a87 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphDAO.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphDAO.java
@@ -19,10 +19,10 @@
*/
package org.apache.zest.sample.dcicargo.pathfinder_b.internal;
+import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import java.util.Random;
import org.apache.zest.sample.dcicargo.pathfinder_b.api.TransitEdge;
@@ -30,42 +30,36 @@ import org.apache.zest.sample.dcicargo.pathfinder_b.api.TransitPath;
public class GraphDAO
{
+ private List<TransitPath> voyages = new ArrayList<>();
- private static final Random random = new Random();
- private static final long ONE_MIN_MS = 1000 * 60;
- private static final long ONE_HOUR_MS = ONE_MIN_MS * 60;
- private static final long ONE_DAY_MS = ONE_HOUR_MS * 24;
-
- private List<TransitPath> voyages = new ArrayList<TransitPath>();
-
- public List<String> listLocations()
+ private List<String> listLocations()
{
- return new ArrayList<String>( Arrays.asList(
+ return new ArrayList<>( Arrays.asList(
"CNHKG", "AUMEL", "SESTO", "FIHEL", "USCHI", "JNTKO", "DEHAM", "CNSHA", "NLRTM", "SEGOT", "CNHGH", "SOMGQ", "USNYC", "USDAL"
) );
}
- public List<TransitPath> voyages()
+ List<TransitPath> voyages()
{
if( voyages.size() > 0 )
{
return voyages;
}
- Date departureDate = new Date();
+ LocalDate departureDate = LocalDate.now();
for( int i = 0; i < 50; i++ )
{
List<String> locations = getRandomChunkOfLocations( listLocations() );
- final List<TransitEdge> transitEdges = new ArrayList<TransitEdge>( locations.size() - 1 );
+ final List<TransitEdge> transitEdges = new ArrayList<>( locations.size() - 1 );
final String voyageNumber = "V" + ( 101 + i );
// Origin and destination of voyage schedule
String from = locations.remove( 0 );
String destination = locations.remove( 0 );
- Date date = nextDate( departureDate );
- Date fromDate;
- Date toDate;
+ LocalDate date = nextDate( departureDate );
+ LocalDate fromDate;
+ LocalDate toDate;
// Carrier movements
for( final String to : locations )
@@ -90,9 +84,9 @@ public class GraphDAO
return voyages;
}
- private Date nextDate( Date date )
+ private LocalDate nextDate( LocalDate date )
{
- return new Date( date.getTime() + ONE_DAY_MS + ( random.nextInt( 1000 ) - 500 ) * ONE_MIN_MS );
+ return date.plusDays(1);
}
private List<String> getRandomChunkOfLocations( List<String> allLocations )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphTraversalServiceImpl.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphTraversalServiceImpl.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphTraversalServiceImpl.java
index 197efd1..c7b6484 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphTraversalServiceImpl.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphTraversalServiceImpl.java
@@ -20,9 +20,9 @@
package org.apache.zest.sample.dcicargo.pathfinder_b.internal;
import java.rmi.RemoteException;
+import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import java.util.Random;
import org.apache.zest.sample.dcicargo.pathfinder_b.api.GraphTraversalService;
@@ -42,7 +42,7 @@ public class GraphTraversalServiceImpl
}
// Combine existing voyages to create a route.
- public List<TransitPath> findShortestPath( final Date departureDate,
+ public List<TransitPath> findShortestPath( final LocalDate departureDate,
final String originUnLocode,
final String destinationUnLocode
)
@@ -56,7 +56,7 @@ public class GraphTraversalServiceImpl
do
{
String expectedDeparture = originUnLocode;
- Date lastArrivalTime = departureDate;
+ LocalDate lastArrivalTime = departureDate;
// Transit edges (itinerary legs)
final List<TransitEdge> routeEdges = new ArrayList<TransitEdge>();
@@ -81,13 +81,13 @@ public class GraphTraversalServiceImpl
final String departure = voyageEdge.getFromUnLocode();
final String arrival = voyageEdge.getToUnLocode();
- final Date departureTime = voyageEdge.getFromDate();
- final Date arrivalTime = voyageEdge.getToDate();
+ final LocalDate departureTime = voyageEdge.getFromDate();
+ final LocalDate arrivalTime = voyageEdge.getToDate();
boolean expectsDeparture = departure.equals( expectedDeparture );
boolean uniqueDeparture = !oldDepartures.contains( departure );
boolean uniqueArrival = !oldDepartures.contains( arrival );
- boolean afterLastArrivalTime = departureTime.after( lastArrivalTime );
+ boolean afterLastArrivalTime = departureTime.isAfter( lastArrivalTime );
if( expectsDeparture && uniqueDeparture && uniqueArrival && afterLastArrivalTime )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/DCISampleApplication_b.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/DCISampleApplication_b.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/DCISampleApplication_b.java
index 628fbda..6e25291 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/DCISampleApplication_b.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/DCISampleApplication_b.java
@@ -19,7 +19,6 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.bootstrap;
-import java.util.Date;
import org.apache.wicket.ConverterLocator;
import org.apache.wicket.Page;
import org.apache.wicket.datetime.PatternDateConverter;
@@ -58,7 +57,8 @@ public class DCISampleApplication_b
getMarkupSettings().setStripWicketTags( true );
// Default date format (we don't care for now about the hour of the day)
- ( (ConverterLocator) getConverterLocator() ).set( Date.class, new PatternDateConverter( "yyyy-MM-dd", true ) );
+ ( (ConverterLocator) getConverterLocator() ).set( java.util.Date.class,
+ new PatternDateConverter( "yyyy-MM-dd", true ) );
}
private void mountPages()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
index abd4e05..08a9bb7 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
@@ -19,10 +19,13 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.bootstrap.sampledata;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.List;
+import java.util.Random;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.parsing.dto.ParsedHandlingEventData;
@@ -45,6 +48,7 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
*/
public abstract class BaseData
{
+ private static Random random = new Random();
protected UnLocode AUMEL;
protected UnLocode CNHGH;
protected UnLocode CNHKG;
@@ -73,13 +77,13 @@ public abstract class BaseData
return unlocode.newInstance();
}
- protected CarrierMovement carrierMovement( Location depLoc, Location arrLoc, Date depTime, Date arrTime )
+ protected CarrierMovement carrierMovement( Location depLoc, Location arrLoc, LocalDate depDate, LocalDate arrDate )
{
ValueBuilder<CarrierMovement> carrierMovement = vbf.newValueBuilder( CarrierMovement.class );
carrierMovement.prototype().departureLocation().set( depLoc );
carrierMovement.prototype().arrivalLocation().set( arrLoc );
- carrierMovement.prototype().departureTime().set( depTime );
- carrierMovement.prototype().arrivalTime().set( arrTime );
+ carrierMovement.prototype().departureDate().set( depDate );
+ carrierMovement.prototype().arrivalDate().set( arrDate );
return carrierMovement.newInstance();
}
@@ -92,14 +96,14 @@ public abstract class BaseData
return schedule.newInstance();
}
- protected Leg leg( Voyage voyage, Location load, Location unload, Date loadTime, Date unloadTime )
+ protected Leg leg( Voyage voyage, Location load, Location unload, LocalDate loadDate, LocalDate unloadDate )
{
ValueBuilder<Leg> leg = vbf.newValueBuilder( Leg.class );
leg.prototype().voyage().set( voyage );
leg.prototype().loadLocation().set( load );
leg.prototype().unloadLocation().set( unload );
- leg.prototype().loadTime().set( loadTime );
- leg.prototype().unloadTime().set( unloadTime );
+ leg.prototype().loadDate().set( loadDate );
+ leg.prototype().unloadDate().set( unloadDate );
return leg.newInstance();
}
@@ -118,13 +122,13 @@ public abstract class BaseData
Boolean isUnloadedAtDestination,
RoutingStatus routingStatus,
Boolean isMisdirected,
- Date eta,
+ LocalDate eta,
Integer itineraryProgressIndex,
NextHandlingEvent nextHandlingEvent
)
{
ValueBuilder<Delivery> delivery = vbf.newValueBuilder( Delivery.class );
- delivery.prototype().timestamp().set( new Date() );
+ delivery.prototype().timestamp().set( Instant.now() );
delivery.prototype().lastHandlingEvent().set( lastHandlingEvent );
delivery.prototype().transportStatus().set( transportStatus );
delivery.prototype().isUnloadedAtDestination().set( isUnloadedAtDestination );
@@ -137,14 +141,14 @@ public abstract class BaseData
}
// Delivery with only mandatory values
- protected Delivery delivery( Date date,
+ protected Delivery delivery( LocalDate date,
TransportStatus transportStatus,
RoutingStatus routingStatus,
Integer itineraryProgressIndex
)
{
ValueBuilder<Delivery> delivery = vbf.newValueBuilder( Delivery.class );
- delivery.prototype().timestamp().set( date );
+ delivery.prototype().timestamp().set( date.atStartOfDay().toInstant( ZoneOffset.UTC ) );
delivery.prototype().transportStatus().set( transportStatus );
delivery.prototype().routingStatus().set( routingStatus );
delivery.prototype().itineraryProgressIndex().set( itineraryProgressIndex );
@@ -153,20 +157,20 @@ public abstract class BaseData
protected NextHandlingEvent nextHandlingEvent( HandlingEventType handlingEventType,
Location location,
- Date time,
+ LocalDate time,
Voyage voyage
)
{
ValueBuilder<NextHandlingEvent> nextHandlingEvent = vbf.newValueBuilder( NextHandlingEvent.class );
nextHandlingEvent.prototype().handlingEventType().set( handlingEventType );
nextHandlingEvent.prototype().location().set( location );
- nextHandlingEvent.prototype().time().set( time );
+ nextHandlingEvent.prototype().date().set( time );
nextHandlingEvent.prototype().voyage().set( voyage );
return nextHandlingEvent.newInstance();
}
- protected ParsedHandlingEventData parsedHandlingEventData( Date registrationTime,
- Date completionTime,
+ protected ParsedHandlingEventData parsedHandlingEventData( LocalDate registrationDate,
+ LocalDate completionDate,
String trackingIdString,
HandlingEventType handlingEventType,
String unLocodeString,
@@ -175,8 +179,8 @@ public abstract class BaseData
throws Exception
{
ValueBuilder<ParsedHandlingEventData> attempt = vbf.newValueBuilder( ParsedHandlingEventData.class );
- attempt.prototype().registrationTime().set( registrationTime );
- attempt.prototype().completionTime().set( completionTime );
+ attempt.prototype().registrationDate().set( registrationDate );
+ attempt.prototype().completionDate().set( completionDate );
attempt.prototype().trackingIdString().set( trackingIdString );
attempt.prototype().handlingEventType().set( handlingEventType );
attempt.prototype().unLocodeString().set( unLocodeString );
@@ -185,10 +189,8 @@ public abstract class BaseData
return attempt.newInstance();
}
- protected static Date day( int days )
+ protected static LocalDate day( int days )
{
- Date today = new Date();
- long aDay = 24 * 60 * 60 * 1000;
- return new Date( today.getTime() + days * aDay );
+ return LocalDate.now().plusDays( days );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
index ad43acf..aee65fd 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
@@ -19,8 +19,8 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.bootstrap.sampledata;
+import java.time.LocalDate;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.UUID;
@@ -57,9 +57,6 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.itinerary.Itinera
import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.CarrierMovement;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -147,7 +144,7 @@ public interface SampleDataService
routeSpec.print();
NextHandlingEvent nextEvent = null;
- Date time = null;
+ LocalDate date = null;
String port = null;
String voyageNumber = null;
Voyage voyage;
@@ -182,8 +179,7 @@ public interface SampleDataService
}
final RouteSpecification unsatisfiedRouteSpec =
- routeSpecFactory.build( origin, badDest, new Date(), new DateTime().plusDays( 25 )
- .toDate() );
+ routeSpecFactory.build( origin, badDest, LocalDate.now(), LocalDate.now().plusDays( 25 ) );
cargo.routeSpecification().set( unsatisfiedRouteSpec );
new InspectUnhandledCargo( cargo ).inspect();
@@ -194,7 +190,7 @@ public interface SampleDataService
{
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
port = nextEvent.location().get().getCode();
- final Date mockTime = new Date();
+ final LocalDate mockTime = LocalDate.now();
registerEvent( mockTime, mockTime, trackingId, RECEIVE, port, null );
}
@@ -202,7 +198,7 @@ public interface SampleDataService
if( i == 15 )
{
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
port = nextEvent.location().get().getCode();
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
@@ -247,21 +243,21 @@ public interface SampleDataService
}
while( wrongVoyage == null && depth++ < 10 );
- registerEvent( time, time, trackingId, LOAD, port, wrongVoyage );
+ registerEvent( date, date, trackingId, LOAD, port, wrongVoyage );
}
// LOAD
if( i > 15 )
{
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
port = nextEvent.location().get().getCode();
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
- registerEvent( time, time, trackingId, LOAD, port, voyageNumber );
+ registerEvent( date, date, trackingId, LOAD, port, voyageNumber );
// Cargo is now on board carrier
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
type = nextEvent.handlingEventType().get();
port = nextEvent.location().get().getCode();
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
@@ -282,21 +278,21 @@ public interface SampleDataService
break;
}
}
- registerEvent( time, time, trackingId, UNLOAD, wrongPort, voyageNumber );
+ registerEvent( date, date, trackingId, UNLOAD, wrongPort, voyageNumber );
}
// UNLOAD
if( i > 17 )
{
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
port = nextEvent.location().get().getCode();
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
- registerEvent( time, time, trackingId, UNLOAD, port, voyageNumber );
+ registerEvent( date, date, trackingId, UNLOAD, port, voyageNumber );
// Cargo is now in midpoint location
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
type = nextEvent.handlingEventType().get();
port = nextEvent.location().get().getCode();
}
@@ -304,13 +300,13 @@ public interface SampleDataService
// CUSTOMS: Customs handling in midpoint location (doesn't affect misdirection status)
if( i == 19 )
{
- registerEvent( time, time, trackingId, CUSTOMS, port, null );
+ registerEvent( date, date, trackingId, CUSTOMS, port, null );
}
// MISDIRECT: Unexpected claim before reaching destination
if( i == 20 )
{
- registerEvent( time, time, trackingId, CLAIM, port, null );
+ registerEvent( date, date, trackingId, CLAIM, port, null );
}
// Complete all LOAD/UNLOADS
@@ -320,10 +316,10 @@ public interface SampleDataService
{
//noinspection ConstantConditions
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
- registerEvent( time, time, trackingId, type, port, voyageNumber );
+ registerEvent( date, date, trackingId, type, port, voyageNumber );
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
port = nextEvent.location().get().getCode();
type = nextEvent.handlingEventType().get();
}
@@ -333,7 +329,7 @@ public interface SampleDataService
// CLAIM at destination - this ends the life cycle of the cargo delivery
if( i == 22 )
{
- registerEvent( time, time, trackingId, CLAIM, port, null );
+ registerEvent( date, date, trackingId, CLAIM, port, null );
}
// Add more cases if needed...
@@ -372,7 +368,7 @@ public interface SampleDataService
Location origin;
Location destination;
Random random = new Random();
- Date deadline;
+ LocalDate deadline;
String uuid;
String id;
try
@@ -388,9 +384,7 @@ public interface SampleDataService
}
while( destination.equals( origin ) );
- deadline = new LocalDate().plusDays( 35 + random.nextInt( 10 ) )
- .toDateTime( new LocalTime() )
- .toDate();
+ deadline = LocalDate.now().plusDays( 35 + random.nextInt( 10 ) );
// Build sortable random tracking ids
uuid = UUID.randomUUID().toString().toUpperCase();
@@ -407,8 +401,8 @@ public interface SampleDataService
}
}
- private void registerEvent( Date registrationTime,
- Date completionTime,
+ private void registerEvent( LocalDate registrationDate,
+ LocalDate completionDate,
String trackingIdString,
HandlingEventType handlingEventType,
String unLocodeString,
@@ -417,8 +411,8 @@ public interface SampleDataService
throws Exception
{
ValueBuilder<ParsedHandlingEventData> event = vbf.newValueBuilder( ParsedHandlingEventData.class );
- event.prototype().registrationTime().set( registrationTime );
- event.prototype().completionTime().set( completionTime );
+ event.prototype().registrationDate().set( registrationDate );
+ event.prototype().completionDate().set( completionDate );
event.prototype().trackingIdString().set( trackingIdString );
event.prototype().handlingEventType().set( handlingEventType );
event.prototype().unLocodeString().set( unLocodeString );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
index 082b706..ae4a1e8 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
@@ -71,7 +71,7 @@ public class TrackingQueries extends Queries
QueryBuilder<HandlingEventEntity> qb = qbf.newQueryBuilder( HandlingEventEntity.class )
.where( QueryExpressions.eq( eventTemplate.trackingId().get().id(), trackingIdString ) );
return uowf.currentUnitOfWork().newQuery( qb )
- .orderBy( orderBy( eventTemplate.completionTime() ) );
+ .orderBy( orderBy( eventTemplate.completionDate() ) );
}
};
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
index 60f7f09..8f96aed 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.communication.query.dto;
-import java.util.Date;
+import java.time.LocalDate;
import org.apache.zest.api.common.Optional;
import org.apache.zest.api.property.Property;
import org.apache.zest.library.conversion.values.Unqualified;
@@ -39,7 +39,7 @@ import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.DTO;
@Unqualified
public interface HandlingEventDTO extends DTO
{
- Property<Date> completionTime();
+ Property<LocalDate> completionDate();
Property<TrackingId> trackingId();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/BookNewCargoPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/BookNewCargoPage.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/BookNewCargoPage.java
index 2c70545..7c19a97 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/BookNewCargoPage.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/BookNewCargoPage.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.communication.web.booking;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.List;
import org.apache.wicket.Session;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -29,7 +29,6 @@ import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.joda.time.LocalDate;
import org.apache.zest.sample.dcicargo.sample_b.communication.query.CommonQueries;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.BookNewCargo;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.tracking.TrackingId;
@@ -59,7 +58,7 @@ public class BookNewCargoPage extends BookingBasePage
{
// Set by Wicket property resolvers:
private String origin, destination;
- private Date deadline;
+ private LocalDate deadline;
public BookNewCargoForm()
{
@@ -109,7 +108,7 @@ public class BookNewCargoPage extends BookingBasePage
// Deadline
final DateTextFieldWithPicker deadlineField = new DateTextFieldWithPicker( "deadline", "Arrival deadline", this );
- deadlineField.earliestDate( new LocalDate().plusDays( 1 ) );
+ deadlineField.earliestDate( LocalDate.now().plusDays( 1 ) );
final ComponentFeedbackPanel deadlineFeedback = new ComponentFeedbackPanel(
"deadlineFeedback", deadlineField );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
index 3451e49..65f568f 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.communication.web.booking;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.devutils.stateless.StatelessComponent;
@@ -46,6 +46,8 @@ import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.color.Erro
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.link.LinkPanel;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.prevnext.PrevNext;
+import static java.time.ZoneOffset.UTC;
+import static java.util.Date.from;
import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.MISROUTED;
import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.NOT_ROUTED;
import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.CLAIMED;
@@ -163,14 +165,16 @@ public class CargoDetailsPage extends BookingBasePage
Leg leg = item.getModelObject();
item.add( new Label( "loadLocation", leg.loadLocation().get().getCode() ) );
- item.add( new Label( "loadTime", new Model<Date>( leg.loadTime().get() ) ) );
+ Instant loadTime = leg.loadDate().get().atStartOfDay().toInstant( UTC );
+ item.add( new Label( "loadDate", new Model<>( from( loadTime ) ) ) );
item.add( new Label( "voyage", leg.voyage().get().voyageNumber().get().number().get() ) );
Boolean isMisrouted = routingStatus == MISROUTED && item.getIndex() == ( getList().size() - 1 );
- item.add( new Label( "unloadLocation", leg.unloadLocation().get().getCode() )
- .add( new ErrorColor( isMisrouted ) ) );
+ item.add( new Label( "unloadLocation",
+ leg.unloadLocation().get().getCode() ).add( new ErrorColor( isMisrouted ) ) );
- item.add( new Label( "unloadTime", new Model<Date>( leg.unloadTime().get() ) ) );
+ Instant unloadTime = leg.unloadDate().get().atStartOfDay().toInstant( UTC );
+ item.add( new Label( "unloadDate", new Model<>( from( unloadTime ) ) ) );
}
} );
}