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 2015/04/17 18:08:42 UTC
[30/50] [abbrv] zest-qi4j git commit: Replaced Joda Time with Java 8
Time API.
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
index 7adc9af..7e56141 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
@@ -17,22 +17,18 @@
*/
package org.qi4j.sample.dcicargo.sample_b.bootstrap.test;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.rules.TestName;
-import org.qi4j.api.composite.TransientBuilderFactory;
import org.qi4j.api.entity.EntityBuilder;
-import org.qi4j.api.query.QueryBuilderFactory;
import org.qi4j.api.service.ServiceReference;
import org.qi4j.api.structure.Application;
import org.qi4j.api.structure.Module;
import org.qi4j.api.unitofwork.UnitOfWork;
-import org.qi4j.api.unitofwork.UnitOfWorkFactory;
import org.qi4j.api.usecase.Usecase;
import org.qi4j.api.usecase.UsecaseBuilder;
import org.qi4j.api.value.ValueBuilder;
@@ -60,13 +56,15 @@ import org.slf4j.LoggerFactory;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* Base class for testing Context Interactions
*/
public class TestApplication
- extends BaseData
+ extends BaseData
{
// Logger for sub classes
protected Logger logger = LoggerFactory.getLogger( getClass() );
@@ -75,32 +73,32 @@ public class TestApplication
protected static RouteSpecificationFactoryService routeSpecFactory;
- final protected static Date TODAY = new Date();
- final protected static Date DAY1 = day( 1 );
- final protected static Date DAY2 = day( 2 );
- final protected static Date DAY3 = day( 3 );
- final protected static Date DAY4 = day( 4 );
- final protected static Date DAY5 = day( 5 );
- final protected static Date DAY6 = day( 6 );
- final protected static Date DAY7 = day( 7 );
- final protected static Date DAY8 = day( 8 );
- final protected static Date DAY9 = day( 9 );
- final protected static Date DAY10 = day( 10 );
- final protected static Date DAY11 = day( 11 );
- final protected static Date DAY12 = day( 12 );
- final protected static Date DAY13 = day( 13 );
- final protected static Date DAY14 = day( 14 );
- final protected static Date DAY15 = day( 15 );
- final protected static Date DAY16 = day( 16 );
- final protected static Date DAY17 = day( 17 );
- final protected static Date DAY18 = day( 18 );
- final protected static Date DAY19 = day( 19 );
- final protected static Date DAY20 = day( 20 );
- final protected static Date DAY21 = day( 21 );
- final protected static Date DAY22 = day( 22 );
- final protected static Date DAY23 = day( 23 );
- final protected static Date DAY24 = day( 24 );
- final protected static Date DAY25 = day( 25 );
+ final protected static ZonedDateTime TODAY = ZonedDateTime.now();
+ final protected static ZonedDateTime DAY1 = TODAY.plusDays( 1 );
+ final protected static ZonedDateTime DAY2 = TODAY.plusDays( 2 );
+ final protected static ZonedDateTime DAY3 = TODAY.plusDays( 3 );
+ final protected static ZonedDateTime DAY4 = TODAY.plusDays( 4 );
+ final protected static ZonedDateTime DAY5 = TODAY.plusDays( 5 );
+ final protected static ZonedDateTime DAY6 = TODAY.plusDays( 6 );
+ final protected static ZonedDateTime DAY7 = TODAY.plusDays( 7 );
+ final protected static ZonedDateTime DAY8 = TODAY.plusDays( 8 );
+ final protected static ZonedDateTime DAY9 = TODAY.plusDays( 9 );
+ final protected static ZonedDateTime DAY10 = TODAY.plusDays( 10 );
+ final protected static ZonedDateTime DAY11 = TODAY.plusDays( 11 );
+ final protected static ZonedDateTime DAY12 = TODAY.plusDays( 12 );
+ final protected static ZonedDateTime DAY13 = TODAY.plusDays( 13 );
+ final protected static ZonedDateTime DAY14 = TODAY.plusDays( 14 );
+ final protected static ZonedDateTime DAY15 = TODAY.plusDays( 15 );
+ final protected static ZonedDateTime DAY16 = TODAY.plusDays( 16 );
+ final protected static ZonedDateTime DAY17 = TODAY.plusDays( 17 );
+ final protected static ZonedDateTime DAY18 = TODAY.plusDays( 18 );
+ final protected static ZonedDateTime DAY19 = TODAY.plusDays( 19 );
+ final protected static ZonedDateTime DAY20 = TODAY.plusDays( 20 );
+ final protected static ZonedDateTime DAY21 = TODAY.plusDays( 21 );
+ final protected static ZonedDateTime DAY22 = TODAY.plusDays( 22 );
+ final protected static ZonedDateTime DAY23 = TODAY.plusDays( 23 );
+ final protected static ZonedDateTime DAY24 = TODAY.plusDays( 24 );
+ final protected static ZonedDateTime DAY25 = TODAY.plusDays( 25 );
protected static Voyage V201;
protected static Voyage V202;
@@ -113,8 +111,8 @@ public class TestApplication
final protected static boolean arrived = true;
final protected static boolean directed = false;
final protected static boolean misdirected = true;
- final protected static Date unknownETA = null;
- final protected static Date noSpecificDate = null;
+ final protected static ZonedDateTime unknownETA = null;
+ final protected static ZonedDateTime noSpecificDate = null;
final protected static Integer leg1 = 0;
final protected static Integer leg2 = 1;
final protected static Integer leg3 = 2;
@@ -123,8 +121,8 @@ public class TestApplication
final protected static Integer unknownLeg = 0;
final protected static NextHandlingEvent unknownNextHandlingEvent = null;
- protected Date deadline;
- protected Date arrival;
+ protected ZonedDateTime deadline;
+ protected ZonedDateTime arrival;
protected RouteSpecification routeSpec;
protected RouteSpecification newRouteSpec;
protected Delivery delivery;
@@ -155,13 +153,13 @@ public class TestApplication
}
@BeforeClass
- public static void setup() throws Exception
+ public static void setup()
+ throws Exception
{
System.out.println( "\n@@@@@@@@@@@ TEST SUITE @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" );
app = new Energy4Java().newApplication( new TestAssembler() );
app.activate();
Context.prepareContextBaseClass( findHostingModule() );
-
}
// Allow to test message output from exceptions after they have been thrown
@@ -178,7 +176,7 @@ public class TestApplication
{
logger.info( name.getMethodName() );
Usecase usecase = UsecaseBuilder.newUsecase( "Usecase:" + name );
- UnitOfWork uow = module.newUnitOfWork(usecase);
+ UnitOfWork uow = module.newUnitOfWork( usecase );
populateTestData();
ServiceReference<RouteSpecificationFactoryService> routeSpecFactoryServiceRef =
@@ -193,7 +191,7 @@ public class TestApplication
public void concludeTests()
{
UnitOfWork uow = module.currentUnitOfWork();
- if (uow != null)
+ if( uow != null )
{
uow.discard();
}
@@ -209,7 +207,9 @@ public class TestApplication
}
else
{
- throw new InternalError( "I have seen a case where a UoW is on the stack, but not opened. First is: " + uow.usecase().name() );
+ throw new InternalError( "I have seen a case where a UoW is on the stack, but not opened. First is: " + uow
+ .usecase()
+ .name() );
}
}
new Exception( "UnitOfWork not properly cleaned up" ).printStackTrace();
@@ -217,7 +217,8 @@ public class TestApplication
}
@AfterClass
- public static void terminateApplication() throws Exception
+ public static void terminateApplication()
+ throws Exception
{
if( app != null )
{
@@ -231,8 +232,8 @@ public class TestApplication
assertTrue( message, e.getMessage().contains( msg ) );
}
-
- private void populateTestData() throws Exception
+ private void populateTestData()
+ throws Exception
{
// UnLocode value objects
AUMEL = unlocode( "AUMEL" ); // Melbourne
@@ -270,54 +271,54 @@ public class TestApplication
// Voyage entity objects for testing
V201 = voyage( "V201", schedule(
- carrierMovement( HONGKONG, CHICAGO, DAY1, DAY5 ),
- carrierMovement( CHICAGO, NEWYORK, DAY5, DAY6 ),
- carrierMovement( NEWYORK, GOTHENBURG, DAY6, DAY12 )
+ carrierMovement( HONGKONG, CHICAGO, DAY1, DAY5 ),
+ carrierMovement( CHICAGO, NEWYORK, DAY5, DAY6 ),
+ carrierMovement( NEWYORK, GOTHENBURG, DAY6, DAY12 )
) );
V202 = voyage( "V202", schedule(
- carrierMovement( CHICAGO, NEWYORK, DAY3, DAY5 ),
- carrierMovement( NEWYORK, DALLAS, DAY7, DAY8 ),
- carrierMovement( DALLAS, ROTTERDAM, DAY10, DAY17 ),
- carrierMovement( ROTTERDAM, HAMBURG, DAY17, DAY19 ),
- carrierMovement( HAMBURG, GOTHENBURG, DAY20, DAY24 )
+ carrierMovement( CHICAGO, NEWYORK, DAY3, DAY5 ),
+ carrierMovement( NEWYORK, DALLAS, DAY7, DAY8 ),
+ carrierMovement( DALLAS, ROTTERDAM, DAY10, DAY17 ),
+ carrierMovement( ROTTERDAM, HAMBURG, DAY17, DAY19 ),
+ carrierMovement( HAMBURG, GOTHENBURG, DAY20, DAY24 )
) );
V203 = voyage( "V203", schedule(
- carrierMovement( NEWYORK, HAMBURG, DAY3, DAY12 ),
- carrierMovement( HAMBURG, ROTTERDAM, DAY13, DAY18 ),
- carrierMovement( ROTTERDAM, STOCKHOLM, DAY20, DAY23 ),
- carrierMovement( STOCKHOLM, HELSINKI, DAY24, DAY25 )
+ carrierMovement( NEWYORK, HAMBURG, DAY3, DAY12 ),
+ carrierMovement( HAMBURG, ROTTERDAM, DAY13, DAY18 ),
+ carrierMovement( ROTTERDAM, STOCKHOLM, DAY20, DAY23 ),
+ carrierMovement( STOCKHOLM, HELSINKI, DAY24, DAY25 )
) );
V204 = voyage( "V204", schedule(
- carrierMovement( TOKYO, HANGZHOU, DAY3, DAY6 ),
- carrierMovement( HANGZHOU, HONGKONG, DAY7, DAY8 ),
- carrierMovement( HONGKONG, NEWYORK, DAY9, DAY12 ),
- carrierMovement( NEWYORK, MELBOURNE, DAY13, DAY19 )
+ carrierMovement( TOKYO, HANGZHOU, DAY3, DAY6 ),
+ carrierMovement( HANGZHOU, HONGKONG, DAY7, DAY8 ),
+ carrierMovement( HONGKONG, NEWYORK, DAY9, DAY12 ),
+ carrierMovement( NEWYORK, MELBOURNE, DAY13, DAY19 )
) );
V205 = voyage( "V205", schedule(
- carrierMovement( HANGZHOU, MOGADISHU, DAY1, DAY2 ),
- carrierMovement( MOGADISHU, ROTTERDAM, DAY2, DAY4 ),
- carrierMovement( ROTTERDAM, NEWYORK, DAY4, DAY7 ),
- carrierMovement( NEWYORK, DALLAS, DAY9, DAY10 )
+ carrierMovement( HANGZHOU, MOGADISHU, DAY1, DAY2 ),
+ carrierMovement( MOGADISHU, ROTTERDAM, DAY2, DAY4 ),
+ carrierMovement( ROTTERDAM, NEWYORK, DAY4, DAY7 ),
+ carrierMovement( NEWYORK, DALLAS, DAY9, DAY10 )
) );
itinerary = itinerary(
- leg( V201, HONGKONG, CHICAGO, DAY1, DAY5 ),
- leg( V201, CHICAGO, NEWYORK, DAY5, DAY6 ),
- leg( V202, NEWYORK, DALLAS, DAY7, DAY8 ),
- leg( V202, DALLAS, ROTTERDAM, DAY10, DAY17 ),
- leg( V203, ROTTERDAM, STOCKHOLM, DAY20, DAY23 )
+ leg( V201, HONGKONG, CHICAGO, DAY1, DAY5 ),
+ leg( V201, CHICAGO, NEWYORK, DAY5, DAY6 ),
+ leg( V202, NEWYORK, DALLAS, DAY7, DAY8 ),
+ leg( V202, DALLAS, ROTTERDAM, DAY10, DAY17 ),
+ leg( V203, ROTTERDAM, STOCKHOLM, DAY20, DAY23 )
);
wrongItinerary = itinerary(
- leg( V201, HONGKONG, CHICAGO, DAY1, DAY5 ),
- leg( V201, CHICAGO, NEWYORK, DAY5, DAY6 ),
- leg( V204, NEWYORK, MELBOURNE, DAY13, DAY19 )
+ leg( V201, HONGKONG, CHICAGO, DAY1, DAY5 ),
+ leg( V201, CHICAGO, NEWYORK, DAY5, DAY6 ),
+ leg( V204, NEWYORK, MELBOURNE, DAY13, DAY19 )
);
}
public void assertDelivery( HandlingEventType handlingEventType,
Location location,
- Date completion,
+ ZonedDateTime completion,
Voyage voyage,
TransportStatus transportStatus,
@@ -325,23 +326,27 @@ public class TestApplication
RoutingStatus routingStatus,
Boolean isMisdirected,
- Date eta,
+ ZonedDateTime eta,
Integer itineraryProgress,
HandlingEventType nextHandlingEventType,
Location nextLocation,
- Date nextTime,
+ ZonedDateTime nextTime,
Voyage nextVoyage
- ) throws Exception
+ )
+ throws Exception
{
delivery = cargo.delivery().get();
// Last handling event
- if (delivery.lastHandlingEvent().get() != null
- || handlingEventType != null || location != null || completion != null || voyage != null)
+ if( delivery.lastHandlingEvent().get() != null
+ || handlingEventType != null || location != null || completion != null || voyage != null )
{
assertThat( "lastHandlingEvent - handlingEventType",
- delivery.lastHandlingEvent().get().handlingEventType().get(), is( equalTo( handlingEventType ) ) );
+ delivery.lastHandlingEvent()
+ .get()
+ .handlingEventType()
+ .get(), is( equalTo( handlingEventType ) ) );
assertThat( "lastHandlingEvent - location",
delivery.lastHandlingEvent().get().location().get(), is( equalTo( location ) ) );
assertThat( "lastHandlingEvent - completionTime",
@@ -356,7 +361,6 @@ public class TestApplication
assertThat( "isUnloadedAtDestination",
delivery.isUnloadedAtDestination().get(), is( equalTo( isUnloadedAtDestination ) ) );
-
// Routing and direction
assertThat( "routingStatus",
delivery.routingStatus().get(), is( equalTo( routingStatus ) ) );
@@ -367,42 +371,45 @@ public class TestApplication
assertThat( "itineraryProgressIndex",
delivery.itineraryProgressIndex().get(), is( equalTo( itineraryProgress ) ) );
-
// Next handling event
- if (nextHandlingEventType == null)
+ if( nextHandlingEventType == null )
{
assertThat( "nextHandlingEvent - handlingEventType",
- delivery.nextHandlingEvent().get(), is( equalTo( null ) ) );
+ delivery.nextHandlingEvent().get(), nullValue() );
}
else
{
assertThat( "nextHandlingEvent - handlingEventType",
- delivery.nextHandlingEvent().get().handlingEventType().get(), is( equalTo( nextHandlingEventType ) ) );
+ delivery.nextHandlingEvent()
+ .get()
+ .handlingEventType()
+ .get(), is( equalTo( nextHandlingEventType ) ) );
assertThat( "nextHandlingEvent - location",
delivery.nextHandlingEvent().get().location().get(), is( equalTo( nextLocation ) ) );
-
- if (delivery.nextHandlingEvent().get().time().get() != null)
+ if( delivery.nextHandlingEvent().get().time().get() != null )
{
// Estimating a new carrier arrival time might be calculated a second
// after initial dates are set, so we skip the seconds
- SimpleDateFormat parser = new SimpleDateFormat( "yyyy-MM-dd HH:mm" );
- String calculatedTime = parser.format( delivery.nextHandlingEvent().get().time().get() );
- String expectedTime = parser.format( nextTime );
- assertThat( "nextHandlingEvent - time", calculatedTime, is( equalTo( expectedTime ) ) );
+ ZonedDateTime calculatedTime = delivery.nextHandlingEvent().get().time().get();
+ assertThat( "nextHandlingEvent - time", calculatedTime, equalTo( nextTime ) );
}
else
- assertThat( "nextHandlingEvent - time", delivery.nextHandlingEvent().get().time().get(), is( equalTo( nextTime ) ) );
+ {
+ assertThat( "nextHandlingEvent - time", delivery.nextHandlingEvent()
+ .get()
+ .time()
+ .get(), is( equalTo( nextTime ) ) );
+ }
assertThat( "nextHandlingEvent - voyage",
delivery.nextHandlingEvent().get().voyage().get(), is( equalTo( nextVoyage ) ) );
}
}
-
public void assertDelivery( HandlingEventType handlingEventType,
Location location,
- Date completion,
+ ZonedDateTime completion,
Voyage voyage,
TransportStatus transportStatus,
@@ -410,18 +417,19 @@ public class TestApplication
RoutingStatus routingStatus,
Boolean isMisdirected,
- Date eta,
+ ZonedDateTime eta,
Integer itineraryProgress,
NextHandlingEvent noNextHandlingEvent
- ) throws Exception
+ )
+ throws Exception
{
assertDelivery( handlingEventType, location, completion, voyage,
transportStatus, isUnloadedAtDestination, routingStatus, isMisdirected, eta,
itineraryProgress, null, null, null, null );
}
- public void assertRouteSpec( Location origin, Location destination, Date earliestDeparture, Date deadline )
+ public void assertRouteSpec( Location origin, Location destination, ZonedDateTime earliestDeparture, ZonedDateTime deadline )
{
newRouteSpec = cargo.routeSpecification().get();
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
index 368ecf0..010801a 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
@@ -76,7 +76,7 @@ public class BookNewCargoTest extends TestApplication
{
deviation_2a_OriginAndDestinationSame();
thrown.expect( CannotCreateRouteSpecificationException.class, "Arrival deadline is in the past or Today." );
- new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( -1 ) ).getTrackingId();
+ new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, TODAY.minusDays( 1 ) ).getTrackingId();
}
@Test
@@ -85,7 +85,7 @@ public class BookNewCargoTest extends TestApplication
{
deviation_2b_DeadlineInThePastNotAccepted();
thrown.expect( CannotCreateRouteSpecificationException.class, "Arrival deadline is in the past or Today." );
- new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( 0 ) ).getTrackingId();
+ new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, TODAY ).getTrackingId();
}
@Test
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
index fc5b3f0..cbaac61 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
@@ -17,7 +17,7 @@
*/
package org.qi4j.sample.dcicargo.sample_b.context.test.booking.routing;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.junit.Before;
import org.junit.Test;
import org.qi4j.api.unitofwork.UnitOfWork;
@@ -60,8 +60,8 @@ public class AssignCargoToRouteTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
- delivery = delivery( TODAY, NOT_RECEIVED, NOT_ROUTED, unknownLeg );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, ZonedDateTime.now(), deadline = DAY24 );
+ delivery = delivery( TODAY.toInstant(), NOT_RECEIVED, NOT_ROUTED, unknownLeg );
cargo = CARGOS.createCargo( routeSpec, delivery, "ABC" );
trackingId = cargo.trackingId().get();
delivery = cargo.delivery().get();
@@ -71,7 +71,7 @@ public class AssignCargoToRouteTest extends TestApplication
public void precondition_x1_CannotReRouteClaimedCargo()
throws Exception
{
- cargo.delivery().set( delivery( TODAY, CLAIMED, ROUTED, unknownLeg ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), CLAIMED, ROUTED, unknownLeg ) );
thrown.expect( RoutingException.class, "Can't re-route claimed cargo" );
new AssignCargoToRoute( cargo, itinerary ).assign();
}
@@ -82,7 +82,7 @@ public class AssignCargoToRouteTest extends TestApplication
{
precondition_x1_CannotReRouteClaimedCargo();
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, NOT_ROUTED, unknownLeg ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, NOT_ROUTED, unknownLeg ) );
thrown.expect( UnsatisfyingRouteException.class, "Route specification was not satisfied with itinerary" );
new AssignCargoToRoute( cargo, wrongItinerary ).assign();
}
@@ -93,7 +93,7 @@ public class AssignCargoToRouteTest extends TestApplication
{
deviation_1a_UnsatisfyingItinerary();
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, NOT_ROUTED, unknownLeg ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, NOT_ROUTED, unknownLeg ) );
new AssignCargoToRoute( cargo, itinerary ).assign();
assertDelivery( null, null, null, null,
NOT_RECEIVED, notArrived,
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/routing/RegisterNewDestinationTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/routing/RegisterNewDestinationTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/routing/RegisterNewDestinationTest.java
index 38c548f..422c6fb 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/routing/RegisterNewDestinationTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/routing/RegisterNewDestinationTest.java
@@ -60,7 +60,7 @@ public class RegisterNewDestinationTest extends TestApplication
// Create new cargo
routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, TODAY, deadline = DAY24 );
- delivery = delivery( TODAY, NOT_RECEIVED, NOT_ROUTED, leg1 );
+ delivery = delivery( TODAY.toInstant(), NOT_RECEIVED, NOT_ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "ABC" );
trackingId = cargo.trackingId().get();
delivery = cargo.delivery().get();
@@ -70,7 +70,7 @@ public class RegisterNewDestinationTest extends TestApplication
public void precondition_x1_CannotChangeDestinationOfClaimedCargo()
throws Exception
{
- cargo.delivery().set( delivery( DAY1, CLAIMED, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( DAY1.toInstant(), CLAIMED, ROUTED, leg1 ) );
thrown.expect( ChangeDestinationException.class, "Can't change destination of claimed cargo" );
new RegisterNewDestination( cargo ).to( "USCHI" );
}
@@ -81,7 +81,7 @@ public class RegisterNewDestinationTest extends TestApplication
{
precondition_x1_CannotChangeDestinationOfClaimedCargo();
- cargo.delivery().set( delivery( DAY1, IN_PORT, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( DAY1.toInstant(), IN_PORT, ROUTED, leg1 ) );
thrown.expect( ChangeDestinationException.class, "Didn't recognize location 'XXXXX'" );
new RegisterNewDestination( cargo ).to( "XXXXX" );
}
@@ -92,7 +92,7 @@ public class RegisterNewDestinationTest extends TestApplication
{
deviation_1a_UnrecognizedLocation();
- cargo.delivery().set( delivery( DAY1, IN_PORT, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( DAY1.toInstant(), IN_PORT, ROUTED, leg1 ) );
thrown.expect( ChangeDestinationException.class, "New destination is same as old destination." );
new RegisterNewDestination( cargo ).to( "SESTO" );
}
@@ -104,7 +104,7 @@ public class RegisterNewDestinationTest extends TestApplication
deviation_1b_NewDestinationSameAsOldDestination();
cargo.routeSpecification().set( routeSpec );
- cargo.delivery().set( delivery( DAY1, NOT_RECEIVED, NOT_ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( DAY1.toInstant(), NOT_RECEIVED, NOT_ROUTED, leg1 ) );
assertRouteSpec( HONGKONG, STOCKHOLM, TODAY, DAY24 );
assertDelivery( null, null, null, null,
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/specification/DeriveUpdatedRouteSpecTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/specification/DeriveUpdatedRouteSpecTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/specification/DeriveUpdatedRouteSpecTest.java
index 7b859f0..ca1e284 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/specification/DeriveUpdatedRouteSpecTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/booking/specification/DeriveUpdatedRouteSpecTest.java
@@ -48,7 +48,7 @@ public class DeriveUpdatedRouteSpecTest extends TestApplication
// Create new cargo
routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, TODAY, deadline = DAY24 );
- delivery = delivery( TODAY, NOT_RECEIVED, ROUTED, unknownLeg );
+ delivery = delivery( TODAY.toInstant(), NOT_RECEIVED, ROUTED, unknownLeg );
cargo = CARGOS.createCargo( routeSpec, delivery, "ABC" );
cargo.itinerary().set( itinerary );
trackingId = cargo.trackingId().get();
@@ -101,7 +101,7 @@ public class DeriveUpdatedRouteSpecTest extends TestApplication
throws Exception
{
cargo.routeSpecification().set( routeSpec );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, ROUTED, unknownLeg ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, ROUTED, unknownLeg ) );
assertRouteSpec( HONGKONG, STOCKHOLM, TODAY, DAY24 );
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
index df136e2..7d3ae43 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
@@ -17,7 +17,7 @@
*/
package org.qi4j.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.junit.Before;
import org.junit.Test;
import org.qi4j.api.unitofwork.UnitOfWork;
@@ -53,8 +53,8 @@ public class InspectArrivedCargoTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
- delivery = delivery( TODAY, IN_PORT, ROUTED, leg5 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, ZonedDateTime.now(), deadline = DAY24 );
+ delivery = delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg5 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Arrived_CARGO" );
trackingId = cargo.trackingId().get();
}
@@ -65,7 +65,7 @@ public class InspectArrivedCargoTest extends TestApplication
{
// Cargo not routed
cargo.itinerary().set( null );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, NOT_ROUTED, leg5 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, NOT_ROUTED, leg5 ) );
// Unload in final destination (with no itinerary!)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY23, DAY23, trackingId, UNLOAD, STOCKHOLM, V203 );
@@ -92,7 +92,7 @@ public class InspectArrivedCargoTest extends TestApplication
{
// Misroute cargo - assign unsatisfying itinerary not going to Stockholm
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, MISROUTED, leg5 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, MISROUTED, leg5 ) );
// Unload in final destination (with wrong itinerary)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY23, DAY23, trackingId, UNLOAD, STOCKHOLM, V203 );
@@ -117,7 +117,7 @@ public class InspectArrivedCargoTest extends TestApplication
{
// Assign satisfying route going to Stockholm
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg5 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, ROUTED, leg5 ) );
// Unload in final destination (with satisfying itinerary)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY23, DAY23, trackingId, UNLOAD, STOCKHOLM, V203 );
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
index 6d58924..3bd52f6 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
@@ -17,7 +17,7 @@
*/
package org.qi4j.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.junit.Before;
import org.junit.Test;
import org.qi4j.api.unitofwork.UnitOfWork;
@@ -52,8 +52,8 @@ public class InspectCargoInCustomsTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
- delivery = delivery( TODAY, IN_PORT, ROUTED, leg1 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, ZonedDateTime.now(), deadline = DAY24 );
+ delivery = delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "CARGO_in_customs" );
trackingId = cargo.trackingId().get();
}
@@ -86,7 +86,7 @@ public class InspectCargoInCustomsTest extends TestApplication
{
// Cargo not routed
cargo.itinerary().set( null );
- cargo.delivery().set( delivery( TODAY, IN_PORT, NOT_ROUTED, leg5 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, NOT_ROUTED, leg5 ) );
// Handle in customs (without itinerary!)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, CUSTOMS, STOCKHOLM, noVoyage );
@@ -104,7 +104,7 @@ public class InspectCargoInCustomsTest extends TestApplication
{
// Misroute cargo - assign unsatisfying itinerary not going to Stockholm
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, MISROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, MISROUTED, leg3 ) );
// Handle in customs (with wrong itinerary)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY20, DAY20, trackingId, CUSTOMS, MELBOURNE, noVoyage );
@@ -122,7 +122,7 @@ public class InspectCargoInCustomsTest extends TestApplication
{
// Assign satisfying route going to Stockholm
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, MISROUTED, leg5 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, MISROUTED, leg5 ) );
// Handle in customs (without itinerary!)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY24, DAY24, trackingId, CUSTOMS, STOCKHOLM, noVoyage );
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
index 95ae56f..0ea1e31 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
@@ -17,7 +17,7 @@
*/
package org.qi4j.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.junit.Before;
import org.junit.Test;
import org.qi4j.api.unitofwork.UnitOfWork;
@@ -50,8 +50,8 @@ public class InspectClaimedCargoTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
- delivery = delivery( TODAY, IN_PORT, ROUTED, leg1 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, ZonedDateTime.now(), deadline = DAY24 );
+ delivery = delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Claimed_CARGO" );
trackingId = cargo.trackingId().get();
}
@@ -62,7 +62,7 @@ public class InspectClaimedCargoTest extends TestApplication
{
// Cargo not routed
cargo.itinerary().set( null );
- cargo.delivery().set( delivery( TODAY, IN_PORT, NOT_ROUTED, leg5 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, NOT_ROUTED, leg5 ) );
// Claim in final destination (without itinerary!)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, CLAIM, STOCKHOLM, noVoyage );
@@ -81,7 +81,7 @@ public class InspectClaimedCargoTest extends TestApplication
{
// Misroute cargo - assign unsatisfying itinerary not going to Stockholm
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, MISROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, MISROUTED, leg3 ) );
// Claim in final destination (with wrong itinerary)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY20, DAY20, trackingId, CLAIM, MELBOURNE, noVoyage );
@@ -99,7 +99,7 @@ public class InspectClaimedCargoTest extends TestApplication
{
// Assign satisfying route going to Stockholm
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg3 ) );
// Claim in midpoint before arrival at final destination
// Should this really be considered misdirected?!
@@ -117,7 +117,7 @@ public class InspectClaimedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg5 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg5 ) );
// Claim in final destination
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY24, DAY24, trackingId, CLAIM, STOCKHOLM, noVoyage );
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
index c436024..bb3e04c 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
@@ -17,7 +17,7 @@
*/
package org.qi4j.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.junit.Before;
import org.junit.Test;
import org.qi4j.api.unitofwork.UnitOfWork;
@@ -68,7 +68,7 @@ public class InspectLoadedCargoTest extends TestApplication
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
// Create new cargo
RouteSpecification routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, TODAY, deadline = DAY24 );
- Delivery delivery = delivery( TODAY, IN_PORT, ROUTED, leg1 );
+ Delivery delivery = delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Loaded_CARGO" );
trackingId = cargo.trackingId().get();
// delivery = cargo.delivery().get();
@@ -79,7 +79,7 @@ public class InspectLoadedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg1 ) );
// V202 doesn't expect a load in Hongkong - can't determine much more before we get a correct voyage schedule
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, LOAD, HONGKONG, V202 );
@@ -105,7 +105,7 @@ public class InspectLoadedCargoTest extends TestApplication
deviation_2a_WrongCarrierSchedule();
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg1 ) );
//
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, LOAD, HONGKONG, V201 );
@@ -123,7 +123,7 @@ public class InspectLoadedCargoTest extends TestApplication
deviation_2a_CarrierOnTime_ArrivalDate_Planned();
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg1 ) );
//
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY2, DAY2, trackingId, LOAD, HONGKONG, V201 );
@@ -142,7 +142,7 @@ public class InspectLoadedCargoTest extends TestApplication
// Cargo not routed
cargo.itinerary().set( null );
- cargo.delivery().set( delivery( TODAY, IN_PORT, NOT_ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, NOT_ROUTED, leg1 ) );
// Load cargo in Hong Kong (without an itinerary!)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, LOAD, HONGKONG, V201 );
@@ -169,7 +169,7 @@ public class InspectLoadedCargoTest extends TestApplication
// Misroute cargo - assign unsatisfying itinerary not going to Stockholm
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, MISROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, MISROUTED, leg1 ) );
// Load cargo in Hong Kong (with wrong itinerary)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, LOAD, HONGKONG, V201 );
@@ -196,7 +196,7 @@ public class InspectLoadedCargoTest extends TestApplication
deviation_3b_Misrouted_LoadLocationOfWrongItinerary_Origin();
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, MISROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, MISROUTED, leg1 ) );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, LOAD, NEWYORK, V201 );
thrown.expect( CargoMisroutedException.class, "MISROUTED! Route specification is not satisfied with itinerary" );
@@ -210,7 +210,7 @@ public class InspectLoadedCargoTest extends TestApplication
deviation_3b_Misrouted_LoadLocationOfWrongItinerary_Midpoint();
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, MISROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, MISROUTED, leg1 ) );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, LOAD, ROTTERDAM, V205 );
thrown.expect( CargoMisroutedException.class, "MISROUTED! Route specification is not satisfied with itinerary" );
@@ -225,7 +225,7 @@ public class InspectLoadedCargoTest extends TestApplication
// Assign satisfying route going to Stockholm
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg1 ) );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, LOAD, HONGKONG, V201 );
new InspectLoadedCargo( cargo, handlingEvent ).inspect();
@@ -270,7 +270,7 @@ public class InspectLoadedCargoTest extends TestApplication
// Move the cargo ahead on the route. Third leg of itinerary expects load in Dallas.
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg3 ) );
// Unexpected load in previous load location of itinerary (onto expected voyage) - can't go back in time.
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY7, DAY5, trackingId, LOAD, ROTTERDAM, V202 );
@@ -296,7 +296,7 @@ public class InspectLoadedCargoTest extends TestApplication
deviation_4a_Misdirected_UnexpectedLoadLocation();
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg3 ) );
// Unexpected load onto previous voyage (in expected location) - can't go back in time.
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY7, DAY7, trackingId, LOAD, NEWYORK, V201 );
@@ -322,7 +322,7 @@ public class InspectLoadedCargoTest extends TestApplication
deviation_4b_Misdirected_UnexpectedLoadVoyage_PreviousInItinerary();
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg3 ) );
// Unexpected load onto future voyage (in expected location) - can't jump ahead in route plan.
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY7, DAY7, trackingId, LOAD, NEWYORK, V203 );
@@ -337,7 +337,7 @@ public class InspectLoadedCargoTest extends TestApplication
deviation_4b_Misdirected_UnexpectedLoadVoyage_NextInItinerary();
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg3 ) );
// Unexpected load onto voyage not in itinerary
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY7, DAY7, trackingId, LOAD, NEWYORK, V204 );
@@ -352,7 +352,7 @@ public class InspectLoadedCargoTest extends TestApplication
deviation_4b_Misdirected_UnexpectedLoadVoyage_VoyageNotInItinerary();
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg3 ) );
// Unexpected load onto voyage not in itinerary - but the carrier is going to our expected arrival location!
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY9, DAY9, trackingId, LOAD, NEWYORK, V205 );
@@ -378,7 +378,7 @@ public class InspectLoadedCargoTest extends TestApplication
deviation_4c_Misdirected_UnexpectedLoadVoyage_Unplanned_ButGoingToWantedLocation();
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg3 ) );
// Unexpected voyage schedule change
V202 = voyage( "V202", schedule(
@@ -412,7 +412,7 @@ public class InspectLoadedCargoTest extends TestApplication
deviation_4d_Misdirected_ExpectedLoadVoyage_UnexpectedNewVoyageSchedule();
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, IN_PORT, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), IN_PORT, ROUTED, leg3 ) );
// Restore expected voyage schedule change
V202 = voyage( "V202", schedule(
@@ -444,8 +444,8 @@ public class InspectLoadedCargoTest extends TestApplication
success_Load();
// Risk zone destination
- routeSpec = routeSpecFactory.build( HANGZHOU, ROTTERDAM, new Date(), deadline = DAY24 );
- delivery = delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg1 );
+ routeSpec = routeSpecFactory.build( HANGZHOU, ROTTERDAM, ZonedDateTime.now(), deadline = DAY24 );
+ delivery = delivery( TODAY.toInstant(), ONBOARD_CARRIER, ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Naive" );
trackingId = cargo.trackingId().get();
itinerary = itinerary(
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
index 5fd01c5..772f63b 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
@@ -59,7 +59,7 @@ public class InspectReceivedCargoTest extends TestApplication
// Create new cargo
routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, TODAY, deadline = DAY24 );
- delivery = delivery( TODAY, NOT_RECEIVED, NOT_ROUTED, unknownLeg );
+ delivery = delivery( TODAY.toInstant(), NOT_RECEIVED, NOT_ROUTED, unknownLeg );
cargo = CARGOS.createCargo( routeSpec, delivery, "Received_CARGO" );
trackingId = cargo.trackingId().get();
}
@@ -93,7 +93,7 @@ public class InspectReceivedCargoTest extends TestApplication
{
// Cargo not routed
cargo.itinerary().set( null );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, NOT_ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, NOT_ROUTED, leg1 ) );
// Receive cargo in Hong Kong (without an itinerary!)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, RECEIVE, HONGKONG, noVoyage );
@@ -112,7 +112,7 @@ public class InspectReceivedCargoTest extends TestApplication
{
// Misroute cargo - assign unsatisfying itinerary not going to Stockholm
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, MISROUTED, unknownLeg ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, MISROUTED, unknownLeg ) );
assertDelivery( null, null, null, null,
NOT_RECEIVED, notArrived,
@@ -135,7 +135,7 @@ public class InspectReceivedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, MISROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, MISROUTED, leg1 ) );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, RECEIVE, NEWYORK, noVoyage );
@@ -153,7 +153,7 @@ public class InspectReceivedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, MISROUTED, unknownLeg ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, MISROUTED, unknownLeg ) );
assertDelivery( null, null, null, null,
NOT_RECEIVED, notArrived,
@@ -177,7 +177,7 @@ public class InspectReceivedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, MISROUTED, unknownLeg ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, MISROUTED, unknownLeg ) );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, RECEIVE, HANGZHOU, noVoyage );
@@ -195,7 +195,7 @@ public class InspectReceivedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, ROUTED, leg1 ) );
assertDelivery( null, null, null, null,
NOT_RECEIVED, notArrived,
@@ -227,7 +227,7 @@ public class InspectReceivedCargoTest extends TestApplication
{
// Assign satisfying route going to Stockholm
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, ROUTED, leg1 ) );
// Receipt in cargo/routeSpec destination = no transportation.
// This must be a unintended booking. Cargo owner should be notified.
@@ -252,7 +252,7 @@ public class InspectReceivedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, ROUTED, leg1 ) );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, RECEIVE, HANGZHOU, noVoyage );
thrown.expect( CargoMisdirectedException.class, "MISDIRECTED! Itinerary expected receipt in Hongkong (CNHKG)" );
@@ -264,7 +264,7 @@ public class InspectReceivedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, ROUTED, leg1 ) );
// Receive cargo as planned in origin
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, RECEIVE, HONGKONG, noVoyage );
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
index 0be3b89..a235cab 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
@@ -17,7 +17,7 @@
*/
package org.qi4j.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.junit.Before;
import org.junit.Test;
import org.qi4j.api.unitofwork.UnitOfWork;
@@ -52,8 +52,8 @@ public class InspectUnhandledCargoTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
- delivery = delivery( TODAY, NOT_RECEIVED, NOT_ROUTED, leg1 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, ZonedDateTime.now(), deadline = DAY24 );
+ delivery = delivery( TODAY.toInstant(), NOT_RECEIVED, NOT_ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Claimed_CARGO" );
trackingId = cargo.trackingId().get();
}
@@ -84,7 +84,7 @@ public class InspectUnhandledCargoTest extends TestApplication
{
// Cargo not routed
cargo.itinerary().set( null );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, NOT_ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, NOT_ROUTED, leg1 ) );
new InspectUnhandledCargo( cargo ).inspect();
@@ -100,7 +100,7 @@ public class InspectUnhandledCargoTest extends TestApplication
{
// Misroute cargo - assign unsatisfying itinerary not going to Stockholm
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, MISROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, MISROUTED, leg1 ) );
new InspectUnhandledCargo( cargo ).inspect();
@@ -116,7 +116,7 @@ public class InspectUnhandledCargoTest extends TestApplication
{
// Assign satisfying route going to Stockholm
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, NOT_RECEIVED, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), NOT_RECEIVED, ROUTED, leg1 ) );
new InspectUnhandledCargo( cargo ).inspect();
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
index 3ffa906..9a10404 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
@@ -17,7 +17,7 @@
*/
package org.qi4j.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.junit.Before;
import org.junit.Test;
import org.qi4j.api.unitofwork.UnitOfWork;
@@ -60,8 +60,8 @@ public class InspectUnloadedCargoTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
- delivery = delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg1 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, ZonedDateTime.now(), deadline = DAY24 );
+ delivery = delivery( TODAY.toInstant(), ONBOARD_CARRIER, ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Unloaded_CARGO" );
trackingId = cargo.trackingId().get();
}
@@ -88,7 +88,7 @@ public class InspectUnloadedCargoTest extends TestApplication
{
// Cargo not routed
cargo.itinerary().set( null );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, NOT_ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, NOT_ROUTED, leg1 ) );
// Unload in Chicago (without an itinerary!)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY5, DAY5, trackingId, UNLOAD, CHICAGO, V201 );
@@ -115,7 +115,7 @@ public class InspectUnloadedCargoTest extends TestApplication
{
// Misroute cargo - assign unsatisfying itinerary not going to Stockholm
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, MISROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, MISROUTED, leg1 ) );
// Unload in Hong Kong (with wrong itinerary)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, UNLOAD, HONGKONG, V201 );
@@ -141,7 +141,7 @@ public class InspectUnloadedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, MISROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, MISROUTED, leg1 ) );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, UNLOAD, NEWYORK, V201 );
thrown.expect( CargoMisroutedException.class, "MISROUTED! Route specification is not satisfied with itinerary" );
@@ -153,7 +153,7 @@ public class InspectUnloadedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( wrongItinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, MISROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, MISROUTED, leg1 ) );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, UNLOAD, ROTTERDAM, V204 );
thrown.expect( CargoMisroutedException.class, "MISROUTED! Route specification is not satisfied with itinerary" );
@@ -166,7 +166,7 @@ public class InspectUnloadedCargoTest extends TestApplication
{
// Assign satisfying route going to Stockholm
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg1 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, ROUTED, leg1 ) );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY5, DAY5, trackingId, UNLOAD, CHICAGO, V201 );
new InspectUnloadedCargo( cargo, handlingEvent ).inspect();
@@ -255,7 +255,7 @@ public class InspectUnloadedCargoTest extends TestApplication
{
// Move the cargo ahead on the route. Third leg of itinerary expects unload in Dallas.
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, ROUTED, leg3 ) );
// Unexpected unload in previous unload location of itinerary.
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY7, DAY7, trackingId, UNLOAD, NEWYORK, V201 );
@@ -279,7 +279,7 @@ public class InspectUnloadedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, ROUTED, leg3 ) );
// Unexpected load in next load location of itinerary (onto expected voyage) - can't jump ahead in route plan.
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY7, DAY7, trackingId, UNLOAD, GOTHENBURG, V202 );
@@ -292,7 +292,7 @@ public class InspectUnloadedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, ROUTED, leg3 ) );
// Unexpected load in unplanned location (onto expected voyage)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY7, DAY7, trackingId, UNLOAD, HAMBURG, V202 );
@@ -305,7 +305,7 @@ public class InspectUnloadedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg3 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, ROUTED, leg3 ) );
// Unload in expected location but from unexpected voyage - do we care? For now not.
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY10, DAY10, trackingId, UNLOAD, DALLAS, V205 );
@@ -323,7 +323,7 @@ public class InspectUnloadedCargoTest extends TestApplication
throws Exception
{
cargo.itinerary().set( itinerary );
- cargo.delivery().set( delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg4 ) );
+ cargo.delivery().set( delivery( TODAY.toInstant(), ONBOARD_CARRIER, ROUTED, leg4 ) );
// Expected unload in leg 4 unload location (Rotterdam)
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY17, DAY17, trackingId, UNLOAD, ROTTERDAM, V202 );
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
index 584c332..68c4fdf 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
@@ -17,8 +17,8 @@
*/
package org.qi4j.sample.dcicargo.sample_b.context.test.handling.parsing;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.time.Instant;
+import java.time.ZonedDateTime;
import org.junit.Before;
import org.junit.Test;
import org.qi4j.api.constraint.ConstraintViolationException;
@@ -38,7 +38,7 @@ import static org.qi4j.sample.dcicargo.sample_b.data.structure.delivery.Transpor
public class ParseHandlingEventDataTest extends TestApplication
{
static ParseHandlingEventData handlingEventParser;
- static String completionTime;
+ static String completionTime = Instant.now().toString();
@Before
public void prepareTest()
@@ -50,18 +50,18 @@ public class ParseHandlingEventDataTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
- delivery = delivery( TODAY, NOT_RECEIVED, ROUTED, unknownLeg );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, ZonedDateTime.now(), deadline = DAY24 );
+ delivery = delivery( TODAY.toInstant(), NOT_RECEIVED, ROUTED, unknownLeg );
cargo = CARGOS.createCargo( routeSpec, delivery, "ABC" );
trackingId = cargo.trackingId().get();
trackingIdString = trackingId.id().get();
cargo.itinerary().set( itinerary );
- completionTime = new SimpleDateFormat( "yyyy-MM-dd HH:mm" ).format( new Date() );
// Start ParseHandlingEventData service
ServiceReference<ParseHandlingEventData> ParseHandlingEventDataRef =
module.findService( ParseHandlingEventData.class );
handlingEventParser = ParseHandlingEventDataRef.get();
+
}
// Null
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
index a6ca313..7b4a256 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/qi4j/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
@@ -17,7 +17,7 @@
*/
package org.qi4j.sample.dcicargo.sample_b.context.test.handling.registration;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.junit.Before;
import org.junit.Test;
import org.qi4j.api.query.Query;
@@ -65,8 +65,8 @@ public class RegisterHandlingEventTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
- delivery = delivery( TODAY, NOT_RECEIVED, ROUTED, unknownLeg );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, ZonedDateTime.now(), deadline = DAY24 );
+ delivery = delivery( TODAY.toInstant(), NOT_RECEIVED, ROUTED, unknownLeg );
cargo = CARGOS.createCargo( routeSpec, delivery, "ABC" );
cargo.itinerary().set( itinerary );
trackingId = cargo.trackingId().get();
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/forum/src/main/java/org/qi4j/samples/forum/context/view/ViewPost.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/qi4j/samples/forum/context/view/ViewPost.java b/samples/forum/src/main/java/org/qi4j/samples/forum/context/view/ViewPost.java
index 93c8c64..45d4802 100644
--- a/samples/forum/src/main/java/org/qi4j/samples/forum/context/view/ViewPost.java
+++ b/samples/forum/src/main/java/org/qi4j/samples/forum/context/view/ViewPost.java
@@ -1,6 +1,6 @@
package org.qi4j.samples.forum.context.view;
-import java.util.Date;
+import java.time.ZoneId;
import org.qi4j.api.injection.scope.Structure;
import org.qi4j.api.injection.scope.Uses;
import org.qi4j.api.property.Numbers;
@@ -51,7 +51,7 @@ public class ViewPost
Post post = module.currentUnitOfWork().newEntity( Post.class );
post.message().set( message );
post.createdBy().set( poster.self() );
- post.createdOn().set( new Date( module.currentUnitOfWork().currentTime() ) );
+ post.createdOn().set( module.currentUnitOfWork().currentTime().atZone( ZoneId.systemDefault() ) );
post.replyTo().set( viewPost.self() );
self().lastPost().set( post );
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/forum/src/main/java/org/qi4j/samples/forum/data/entity/Post.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/qi4j/samples/forum/data/entity/Post.java b/samples/forum/src/main/java/org/qi4j/samples/forum/data/entity/Post.java
index 6757332..3771d5b 100644
--- a/samples/forum/src/main/java/org/qi4j/samples/forum/data/entity/Post.java
+++ b/samples/forum/src/main/java/org/qi4j/samples/forum/data/entity/Post.java
@@ -1,6 +1,6 @@
package org.qi4j.samples.forum.data.entity;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.qi4j.api.association.Association;
import org.qi4j.api.common.Optional;
import org.qi4j.api.entity.EntityComposite;
@@ -31,5 +31,5 @@ public interface Post
Property<User> createdBy();
- Property<Date> createdOn();
+ Property<ZonedDateTime> createdOn();
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/forum/src/main/java/org/qi4j/samples/forum/domainevent/DomainEventValue.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/qi4j/samples/forum/domainevent/DomainEventValue.java b/samples/forum/src/main/java/org/qi4j/samples/forum/domainevent/DomainEventValue.java
index b1e1a98..081a8d1 100644
--- a/samples/forum/src/main/java/org/qi4j/samples/forum/domainevent/DomainEventValue.java
+++ b/samples/forum/src/main/java/org/qi4j/samples/forum/domainevent/DomainEventValue.java
@@ -1,5 +1,6 @@
package org.qi4j.samples.forum.domainevent;
+import java.time.Instant;
import java.util.List;
import org.qi4j.api.common.UseDefaults;
import org.qi4j.api.property.Property;
@@ -15,7 +16,7 @@ public interface DomainEventValue
Property<String> version();
// When the event occurred
- Property<Long> timestamp();
+ Property<Instant> timestamp();
// Selected objects
@UseDefaults
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Booking.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Booking.java b/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Booking.java
index cf5142b..851e918 100644
--- a/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Booking.java
+++ b/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Booking.java
@@ -18,7 +18,7 @@
package org.qi4j.sample.rental.domain;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.qi4j.api.association.Association;
import org.qi4j.api.common.Optional;
import org.qi4j.api.entity.EntityComposite;
@@ -37,9 +37,9 @@ public interface Booking
@Optional
// if not set, the pickup has not occurred yet.
- Property<Date> pickedupTime();
+ Property<ZonedDateTime> pickedupTime();
@Optional
// if not set, the return has not occurred yet.
- Property<Date> returnedTime();
+ Property<ZonedDateTime> returnedTime();
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Car.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Car.java b/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Car.java
index 0f26bcb..0651d3e 100644
--- a/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Car.java
+++ b/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Car.java
@@ -18,7 +18,7 @@
package org.qi4j.sample.rental.domain;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.qi4j.api.association.Association;
import org.qi4j.api.common.Optional;
import org.qi4j.api.entity.EntityComposite;
@@ -37,10 +37,10 @@ public interface Car
Association<CarCategory> category();
@Optional
- Property<Date> purchasedDate();
+ Property<ZonedDateTime> purchasedDate();
@Optional
- Property<Date> soldDate();
+ Property<ZonedDateTime> soldDate();
Booking currentBooking();
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Period.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Period.java b/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Period.java
index ac783cd..7976166 100644
--- a/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Period.java
+++ b/samples/rental/src/main/java/org/qi4j/sample/rental/domain/Period.java
@@ -18,14 +18,14 @@
package org.qi4j.sample.rental.domain;
-import java.util.Date;
+import java.time.ZonedDateTime;
import org.qi4j.api.property.Property;
import org.qi4j.api.value.ValueComposite;
public interface Period
extends ValueComposite
{
- Property<Date> startOfPeriod();
+ Property<ZonedDateTime> startOfPeriod();
- Property<Date> endOfPeriod();
+ Property<ZonedDateTime> endOfPeriod();
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/rental/src/main/java/org/qi4j/sample/rental/domain/RentalShop.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/qi4j/sample/rental/domain/RentalShop.java b/samples/rental/src/main/java/org/qi4j/sample/rental/domain/RentalShop.java
index 5941854..e9989dd 100644
--- a/samples/rental/src/main/java/org/qi4j/sample/rental/domain/RentalShop.java
+++ b/samples/rental/src/main/java/org/qi4j/sample/rental/domain/RentalShop.java
@@ -20,7 +20,7 @@ package org.qi4j.sample.rental.domain;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.util.Date;
+import java.time.ZonedDateTime;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -53,13 +53,13 @@ public interface RentalShop
Booking book( Customer customer, Car car, Period plannedPeriod );
- void pickup( Booking booking, Date time );
+ void pickup( Booking booking, ZonedDateTime time );
- void returned( Booking booking, Date time );
+ void returned( Booking booking, ZonedDateTime time );
- void boughtCar( Car car, Date purchasedate );
+ void boughtCar( Car car, ZonedDateTime purchasedate );
- void soldCar( Car car, Date soldDate );
+ void soldCar( Car car, ZonedDateTime soldDate );
Car createCar( String category, String modelName, String licensePlate );
@@ -190,23 +190,23 @@ public interface RentalShop
return booking;
}
- public void pickup( Booking booking, Date time )
+ public void pickup( Booking booking, ZonedDateTime time )
{
booking.pickedupTime().set( time );
}
- public void returned( Booking booking, Date time )
+ public void returned( Booking booking, ZonedDateTime time )
{
booking.returnedTime().set( time );
}
- public void boughtCar( Car car, Date purchaseDate )
+ public void boughtCar( Car car, ZonedDateTime purchaseDate )
{
state.carsOwned().add( car );
car.purchasedDate().set( purchaseDate );
}
- public void soldCar( Car car, Date soldDate )
+ public void soldCar( Car car, ZonedDateTime soldDate )
{
state.carsOwned().remove( car );
car.soldDate().set( soldDate );
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/rental/src/main/java/org/qi4j/sample/rental/domain/dev/InitialData.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/qi4j/sample/rental/domain/dev/InitialData.java b/samples/rental/src/main/java/org/qi4j/sample/rental/domain/dev/InitialData.java
index c34ebfe..bd87617 100644
--- a/samples/rental/src/main/java/org/qi4j/sample/rental/domain/dev/InitialData.java
+++ b/samples/rental/src/main/java/org/qi4j/sample/rental/domain/dev/InitialData.java
@@ -18,9 +18,10 @@
package org.qi4j.sample.rental.domain.dev;
+import java.time.Duration;
+import java.time.ZonedDateTime;
import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
+import java.util.Random;
import org.qi4j.api.composite.TransientComposite;
import org.qi4j.api.injection.scope.Structure;
import org.qi4j.api.mixin.Mixins;
@@ -106,22 +107,14 @@ public interface InitialData
private Period createRandomPeriod()
{
- Calendar cal = Calendar.getInstance();
- cal.setTime( new Date() );
- cal.add( Calendar.DATE, Math.abs( (int) ( Math.random() * 5.0 ) ) );
- cal.set( Calendar.HOUR_OF_DAY, 15 );
- cal.set( Calendar.MINUTE, 0 );
- cal.set( Calendar.SECOND, 0 );
- Date earliestPickup = cal.getTime();
+ Random random = new Random();
+ ZonedDateTime pickup = ZonedDateTime.now().plusDays( random.nextInt( 5 ) );
+ Duration duration = Duration.ofDays( random.nextInt( 20 ) );
+ ZonedDateTime returned = pickup.plus( duration );
- cal.add( Calendar.DATE, Math.abs( (int) ( Math.random() * 30.0 ) ) );
- cal.set( Calendar.HOUR_OF_DAY, 12 );
- cal.set( Calendar.MINUTE, 0 );
- cal.set( Calendar.SECOND, 0 );
- Date latestReturn = cal.getTime();
ValueBuilder<Period> builder = vbf.newValueBuilder( Period.class );
- builder.prototype().startOfPeriod().set( earliestPickup );
- builder.prototype().endOfPeriod().set( latestReturn );
+ builder.prototype().startOfPeriod().set( pickup );
+ builder.prototype().endOfPeriod().set( returned );
return builder.newInstance();
}
@@ -141,55 +134,55 @@ public interface InitialData
{
Car car;
car = shop.createCar( "SUV", "Volvo XC90", "WHO 7878" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "SUV", "BMW X5", "WIT 23" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "SUV", "Volvo XC90", "WHO 7879" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "SUV", "Volvo XC90", "WHO 7880" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "SUV", "BMW X5", "WIT 24" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "SUV", "BMW X5", "WIT 25" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "SUV", "BMW X5", "WIT 26" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "SUV", "BMW X5", "WIT 27" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 40" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 41" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 42" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 43" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 44" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 45" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "Sedan", "BMW 318i", "WRY 900" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "Sedan", "BMW 318i", "WRY 901" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
car = shop.createCar( "Sedan", "BMW 318i", "WRY 902" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, ZonedDateTime.now() );
cars.add( car );
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/struts2Hello/src/main/java/org/qi4j/library/struts2/example/actions/HelloWorldAction.java
----------------------------------------------------------------------
diff --git a/samples/struts2Hello/src/main/java/org/qi4j/library/struts2/example/actions/HelloWorldAction.java b/samples/struts2Hello/src/main/java/org/qi4j/library/struts2/example/actions/HelloWorldAction.java
index 9805936..91d8def 100644
--- a/samples/struts2Hello/src/main/java/org/qi4j/library/struts2/example/actions/HelloWorldAction.java
+++ b/samples/struts2Hello/src/main/java/org/qi4j/library/struts2/example/actions/HelloWorldAction.java
@@ -23,11 +23,10 @@ import com.opensymphony.xwork2.conversion.annotations.TypeConversion;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.Validation;
+import java.time.Instant;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
-import java.util.Date;
-
@Validation
@Conversion
@Results( { @Result( name = "input", value = "/jsp/index.jsp" ), @Result( value = "/jsp/helloWorld.jsp" ) } )
@@ -37,17 +36,17 @@ public class HelloWorldAction
private static final long serialVersionUID = 1L;
- private Date now;
+ private Instant now;
private String name;
@TypeConversion( converter = "org.qi4j.library.struts2.example.converters.DateConverter" )
@RequiredFieldValidator( message = "Please enter the date" )
- public void setDateNow( Date dateNow )
+ public void setDateNow( Instant dateNow )
{
now = dateNow;
}
- public Date getDateNow()
+ public Instant getDateNow()
{
return now;
}