Skip to content

Commit

Permalink
chore: initial commit of ee10 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and hantsy committed Oct 22, 2023
1 parent d38f4b2 commit aec42d1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@Startup
public class SampleDataGenerator {

@Inject private Logger logger;
private static final Logger LOGGER = Logger.getLogger(SampleDataGenerator.class.getName());

@PersistenceContext private EntityManager entityManager;
@Inject private HandlingEventFactory handlingEventFactory;
Expand All @@ -33,7 +33,7 @@ public class SampleDataGenerator {
@PostConstruct
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void loadSampleData() {
logger.info("Loading sample data.");
LOGGER.info("Loading sample data.");
unLoadAll(); // Fail-safe in case of application restart that does not trigger a JPA schema
// drop.
loadSampleLocations();
Expand All @@ -42,7 +42,7 @@ public void loadSampleData() {
}

private void unLoadAll() {
logger.info("Unloading all existing data.");
LOGGER.info("Unloading all existing data.");
// In order to remove handling events, must remove references in cargo.
// Dropping cargo first won't work since handling events have references
// to it.
Expand All @@ -66,7 +66,7 @@ private void unLoadAll() {
}

private void loadSampleLocations() {
logger.info("Loading sample locations.");
LOGGER.info("Loading sample locations.");

entityManager.persist(SampleLocations.HONGKONG);
entityManager.persist(SampleLocations.MELBOURNE);
Expand All @@ -84,7 +84,7 @@ private void loadSampleLocations() {
}

private void loadSampleVoyages() {
logger.info("Loading sample voyages.");
LOGGER.info("Loading sample voyages.");

entityManager.persist(SampleVoyages.HONGKONG_TO_NEW_YORK);
entityManager.persist(SampleVoyages.NEW_YORK_TO_DALLAS);
Expand All @@ -94,7 +94,7 @@ private void loadSampleVoyages() {
}

private void loadSampleCargos() {
logger.info("Loading sample cargo data.");
LOGGER.info("Loading sample cargo data.");

// Cargo ABC123. This one is en-route.
TrackingId trackingId1 = new TrackingId("ABC123");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,19 @@ public void testRegisterNew() {
.setParameter("trackingId", trackingId)
.getSingleResult();

assertThat( cargo.getOrigin()).isEqualTo(SampleLocations.CHICAGO);
assertThat( cargo.getRouteSpecification().getDestination()).isEqualTo(SampleLocations.STOCKHOLM);
assertThat(cargo.getOrigin()).isEqualTo(SampleLocations.CHICAGO);
assertThat(cargo.getRouteSpecification().getDestination())
.isEqualTo(SampleLocations.STOCKHOLM);
assertThat(cargo.getRouteSpecification().getArrivalDeadline()).isEqualTo(deadline);
assertThat(cargo.getDelivery().getTransportStatus()).isEqualTo(TransportStatus.NOT_RECEIVED);
assertThat(cargo.getDelivery().getTransportStatus())
.isEqualTo(TransportStatus.NOT_RECEIVED);
assertThat(cargo.getDelivery().getLastKnownLocation()).isEqualTo(Location.UNKNOWN);
assertThat( cargo.getDelivery().getCurrentVoyage()).isEqualTo(Voyage.NONE);
assertThat(cargo.getDelivery().getCurrentVoyage()).isEqualTo(Voyage.NONE);
assertThat(cargo.getDelivery().isMisdirected()).isFalse();
assertThat(cargo.getDelivery().getEstimatedTimeOfArrival()).isEqualTo(Delivery.ETA_UNKOWN);
assertThat( cargo.getDelivery().getNextExpectedActivity()).isEqualTo(Delivery.NO_ACTIVITY);
assertThat(cargo.getDelivery().getNextExpectedActivity()).isEqualTo(Delivery.NO_ACTIVITY);
assertThat(cargo.getDelivery().isUnloadedAtDestination()).isFalse();
assertThat( cargo.getDelivery().getRoutingStatus()).isEqualTo(RoutingStatus.NOT_ROUTED);
assertThat(cargo.getDelivery().getRoutingStatus()).isEqualTo(RoutingStatus.NOT_ROUTED);
assertThat(cargo.getItinerary()).isEqualTo(Itinerary.EMPTY_ITINERARY);
}

Expand Down Expand Up @@ -192,8 +194,10 @@ public void testAssignRoute() {
.getEstimatedTimeOfArrival()
.isBefore(deadline.atStartOfDay()))
.isTrue();
assertThat(cargo.getDelivery().getNextExpectedActivity().getType()).isEqualTo(HandlingEvent.Type.RECEIVE);
assertThat(cargo.getDelivery().getNextExpectedActivity().getLocation()).isEqualTo(SampleLocations.CHICAGO);
assertThat(cargo.getDelivery().getNextExpectedActivity().getType())
.isEqualTo(HandlingEvent.Type.RECEIVE);
assertThat(cargo.getDelivery().getNextExpectedActivity().getLocation())
.isEqualTo(SampleLocations.CHICAGO);
assertThat(cargo.getDelivery().getNextExpectedActivity().getVoyage()).isNull();
assertThat(cargo.getDelivery().isUnloadedAtDestination()).isFalse();
assertThat(cargo.getDelivery().getRoutingStatus()).isEqualTo(RoutingStatus.ROUTED);
Expand All @@ -211,18 +215,20 @@ public void testChangeDestination() {
.setParameter("trackingId", trackingId)
.getSingleResult();

assertThat( cargo.getOrigin()).isEqualTo(SampleLocations.CHICAGO);
assertThat( cargo.getRouteSpecification().getDestination()).isEqualTo(SampleLocations.HELSINKI);
assertThat(cargo.getOrigin()).isEqualTo(SampleLocations.CHICAGO);
assertThat(cargo.getRouteSpecification().getDestination())
.isEqualTo(SampleLocations.HELSINKI);
assertThat(cargo.getRouteSpecification().getArrivalDeadline()).isEqualTo(deadline);
assertThat(cargo.getItinerary()).isEqualTo(assigned);
assertThat( cargo.getDelivery().getTransportStatus()).isEqualTo(TransportStatus.NOT_RECEIVED);
assertThat(cargo.getDelivery().getTransportStatus())
.isEqualTo(TransportStatus.NOT_RECEIVED);
assertThat(cargo.getDelivery().getLastKnownLocation()).isEqualTo(Location.UNKNOWN);
assertThat( cargo.getDelivery().getCurrentVoyage()).isEqualTo(Voyage.NONE);
assertThat(cargo.getDelivery().getCurrentVoyage()).isEqualTo(Voyage.NONE);
assertThat(cargo.getDelivery().isMisdirected()).isFalse();
assertThat(cargo.getDelivery().getEstimatedTimeOfArrival()).isEqualTo(Delivery.ETA_UNKOWN);
assertThat(cargo.getDelivery().getNextExpectedActivity()).isEqualTo(Delivery.NO_ACTIVITY);
assertThat(cargo.getDelivery().isUnloadedAtDestination()).isFalse();
assertThat( cargo.getDelivery().getRoutingStatus()).isEqualTo(RoutingStatus.MISROUTED);
assertThat(cargo.getDelivery().getRoutingStatus()).isEqualTo(RoutingStatus.MISROUTED);
}

@Test
Expand All @@ -238,17 +244,19 @@ public void testChangeDeadline() {
.setParameter("trackingId", trackingId)
.getSingleResult();

assertThat( cargo.getOrigin()).isEqualTo(SampleLocations.CHICAGO);
assertThat(cargo.getRouteSpecification().getDestination()).isEqualTo(SampleLocations.HELSINKI);
assertThat(cargo.getOrigin()).isEqualTo(SampleLocations.CHICAGO);
assertThat(cargo.getRouteSpecification().getDestination())
.isEqualTo(SampleLocations.HELSINKI);
assertThat(cargo.getRouteSpecification().getArrivalDeadline()).isEqualTo(newDeadline);
assertThat(cargo.getItinerary()).isEqualTo(assigned);
assertThat( cargo.getDelivery().getTransportStatus()).isEqualTo(TransportStatus.NOT_RECEIVED);
assertThat( cargo.getDelivery().getLastKnownLocation()).isEqualTo(Location.UNKNOWN);
assertThat( cargo.getDelivery().getCurrentVoyage()).isEqualTo(Voyage.NONE);
assertThat(cargo.getDelivery().getTransportStatus())
.isEqualTo(TransportStatus.NOT_RECEIVED);
assertThat(cargo.getDelivery().getLastKnownLocation()).isEqualTo(Location.UNKNOWN);
assertThat(cargo.getDelivery().getCurrentVoyage()).isEqualTo(Voyage.NONE);
assertThat(cargo.getDelivery().isMisdirected()).isFalse();
assertThat(cargo.getDelivery().getEstimatedTimeOfArrival()).isEqualTo(Delivery.ETA_UNKOWN);
assertThat(cargo.getDelivery().getNextExpectedActivity()).isEqualTo(Delivery.NO_ACTIVITY);
assertThat(cargo.getDelivery().isUnloadedAtDestination()).isFalse();
assertThat( cargo.getDelivery().getRoutingStatus()).isEqualTo(RoutingStatus.MISROUTED);
assertThat(cargo.getDelivery().getRoutingStatus()).isEqualTo(RoutingStatus.MISROUTED);
}
}

0 comments on commit aec42d1

Please sign in to comment.