コード例 #1
0
        public void testUpdateOnHandlingWhenMisdirected()
        {
            // Unload in L.HAMBURG, which is the wrong location
            HandlingActivity handlingActivity = new HandlingActivity(HandlingActivityType.UNLOAD,
                                                                     L.HAMBURG,
                                                                     V.DALLAS_TO_HELSINKI);
            Delivery newDelivery = delivery.OnHandling(handlingActivity);

            Assert.AreEqual(Voyage.None, newDelivery.CurrentVoyage);
            Assert.AreEqual(L.HAMBURG, newDelivery.LastKnownLocation);
            Assert.AreEqual(TransportStatus.IN_PORT, newDelivery.TransportStatus);

            // Next handling activity is undefined. Need a new itinerary to know what to do.

            Assert.IsFalse(newDelivery.IsUnloadedIn(routeSpecification.Destination));

            Assert.AreEqual(RoutingStatus.ROUTED, routeSpecification.StatusOf(itinerary));

            Assert.IsTrue(delivery.LastUpdatedOn < (newDelivery.LastUpdatedOn));

            // New route specification, old itinerary
            RouteSpecification newRouteSpecification = routeSpecification.WithOrigin(L.HAMBURG);

            Assert.AreEqual(RoutingStatus.MISROUTED, newRouteSpecification.StatusOf(itinerary));

            Itinerary newItinerary = new Itinerary(Leg.DeriveLeg(V.DALLAS_TO_HELSINKI, L.HAMBURG, L.STOCKHOLM));

            Assert.AreEqual(RoutingStatus.ROUTED, newRouteSpecification.StatusOf(newItinerary));
            Assert.AreEqual(TransportStatus.IN_PORT, newDelivery.TransportStatus);
        }
コード例 #2
0
        public void compareMatches()
        {
            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(V.pacific1, L.TOKYO, L.LONGBEACH),
                                                Leg.DeriveLeg(V.continental2, L.LONGBEACH, L.DALLAS));

            LegActivityMatch startMatch = LegActivityMatch.Match(Leg.DeriveLeg(V.pacific1, L.TOKYO, L.LONGBEACH),
                                                                 HandlingActivity.LoadOnto(V.pacific1).In(L.TOKYO),
                                                                 itinerary);

            Assert.That(startMatch.HandlingActivity, Is.EqualTo(HandlingActivity.LoadOnto(V.pacific1).In(L.TOKYO)));
            Assert.That(startMatch.Leg, Is.EqualTo(Leg.DeriveLeg(V.pacific1, L.TOKYO, L.LONGBEACH)));

            LegActivityMatch endMatch = LegActivityMatch.Match(Leg.DeriveLeg(V.pacific1, L.TOKYO, L.LONGBEACH),
                                                               HandlingActivity.UnloadOff(V.pacific1).In(L.LONGBEACH),
                                                               itinerary);

            Assert.That(endMatch.HandlingActivity, Is.EqualTo(HandlingActivity.UnloadOff(V.pacific1).In(L.LONGBEACH)));
            Assert.That(endMatch.Leg, Is.EqualTo(Leg.DeriveLeg(V.pacific1, L.TOKYO, L.LONGBEACH)));

            LegActivityMatch nextMatch = LegActivityMatch.Match(Leg.DeriveLeg(V.continental2, L.LONGBEACH, L.DALLAS),
                                                                HandlingActivity.LoadOnto(V.continental2).In(L.LONGBEACH),
                                                                itinerary);

            Assert.That(nextMatch.HandlingActivity,
                        Is.EqualTo(HandlingActivity.LoadOnto(V.continental2).In(L.LONGBEACH)));
            Assert.That(nextMatch.Leg, Is.EqualTo(Leg.DeriveLeg(V.continental2, L.LONGBEACH, L.DALLAS)));

            Assert.That(startMatch.CompareTo(endMatch), Is.EqualTo(-1));
            Assert.That(endMatch.CompareTo(startMatch), Is.EqualTo(1));
            Assert.That(endMatch.CompareTo(nextMatch), Is.EqualTo(-1));
            Assert.That(nextMatch.CompareTo(endMatch), Is.EqualTo(1));

            Assert.That(startMatch.CompareTo(startMatch), Is.EqualTo(0));
        }
コード例 #3
0
        public void toCargoRoutingDTO()
        {
            var origin      = L.HONGKONG;
            var destination = L.LONGBEACH;
            var cargo       = new Cargo(new TrackingId("XYZ"), new RouteSpecification(origin, destination, DateTime.Now));

            var itinerary = new Itinerary(
                Leg.DeriveLeg(SampleVoyages.pacific1, L.HONGKONG, L.TOKYO),
                Leg.DeriveLeg(SampleVoyages.pacific1, L.TOKYO, L.LONGBEACH)
                );

            cargo.AssignToRoute(itinerary);

            var dto = DTOAssembler.toDTO(cargo);

            Assert.AreEqual(2, dto.getLegs().Count());

            LegDTO legDTO = dto.getLegs().ElementAt(0);

            Assert.AreEqual("PAC1", legDTO.getVoyageNumber());
            Assert.AreEqual("CNHKG", legDTO.getFrom());
            Assert.AreEqual("JNTKO", legDTO.getTo());

            legDTO = dto.getLegs().ElementAt(1);
            Assert.AreEqual("PAC1", legDTO.getVoyageNumber());
            Assert.AreEqual("JNTKO", legDTO.getFrom());
            Assert.AreEqual("USLBG", legDTO.getTo());
        }
コード例 #4
0
 private Leg toLeg(TransitEdge edge)
 {
     return(Leg.DeriveLeg(
                voyageRepository.find(new VoyageNumber(edge.getVoyageNumber())),
                locationRepository.find(new UnLocode(edge.getFromUnLocode())),
                locationRepository.find(new UnLocode(edge.getToUnLocode()))
                ));
 }
コード例 #5
0
        public void testIfCargoIsOnTrack()
        {
            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(voyage, L.SHANGHAI, L.ROTTERDAM),
                                                Leg.DeriveLeg(voyage, L.ROTTERDAM, L.GOTHENBURG));

            // HandlingActivity.Load(cargo, HandlingActivityType.RECEIVE, L.SHANGHAI, toDate("2009-05-03"))
            //Happy path
            HandlingActivity receiveShanghai = new HandlingActivity(HandlingActivityType.RECEIVE, L.SHANGHAI);

            Assert.IsTrue(itinerary.IsExpectedActivity(receiveShanghai));

            HandlingActivity loadShanghai = new HandlingActivity(HandlingActivityType.LOAD, L.SHANGHAI, voyage);

            Assert.IsTrue(itinerary.IsExpectedActivity(loadShanghai));

            HandlingActivity unloadRotterdam = new HandlingActivity(HandlingActivityType.UNLOAD, L.ROTTERDAM, voyage);

            Assert.IsTrue(itinerary.IsExpectedActivity(unloadRotterdam));

            HandlingActivity loadRotterdam = new HandlingActivity(HandlingActivityType.LOAD, L.ROTTERDAM, voyage);

            Assert.IsTrue(itinerary.IsExpectedActivity(loadRotterdam));

            HandlingActivity unloadGothenburg = new HandlingActivity(HandlingActivityType.UNLOAD, L.GOTHENBURG, voyage);

            Assert.IsTrue(itinerary.IsExpectedActivity(unloadGothenburg));

            HandlingActivity claimGothenburg = new HandlingActivity(HandlingActivityType.CLAIM, L.GOTHENBURG);

            Assert.IsTrue(itinerary.IsExpectedActivity(claimGothenburg));

            //TODO Customs event can only be interpreted properly by knowing the destination of the cargo.
            // This can be inferred from the Itinerary, but it isn't definitive. So, do we answer based on
            // the end of the itinerary (even though this would probably not be used in the app) or do we
            // ignore this at itinerary level somehow and leave it purely as a cargo responsibility.
            // (See customsClearancePoint tests in CargoTest)
            //    HandlingActivity customsGothenburg = new HandlingActivity(CUSTOMS, L.GOTHENBURG);
            //    Assert.IsTrue(itinerary.isExpectedActivity(customsGothenburg));

            //Received at the wrong location
            HandlingActivity receiveHangzou = new HandlingActivity(HandlingActivityType.RECEIVE, L.HANGZOU);

            Assert.IsFalse(itinerary.IsExpectedActivity(receiveHangzou));

            //Loaded to onto the wrong ship, correct location
            HandlingActivity loadRotterdam666 = new HandlingActivity(HandlingActivityType.LOAD, L.ROTTERDAM, wrongVoyage);

            Assert.IsFalse(itinerary.IsExpectedActivity(loadRotterdam666));

            //Unloaded from the wrong ship in the wrong location
            HandlingActivity unloadHelsinki = new HandlingActivity(HandlingActivityType.UNLOAD, L.HELSINKI, wrongVoyage);

            Assert.IsFalse(itinerary.IsExpectedActivity(unloadHelsinki));

            HandlingActivity claimRotterdam = new HandlingActivity(HandlingActivityType.CLAIM, L.ROTTERDAM);

            Assert.IsFalse(itinerary.IsExpectedActivity(claimRotterdam));
        }
コード例 #6
0
        public void legThatFollowsPartOfAVoyage()
        {
            Leg chicagoToDallas = Leg.DeriveLeg(voyage, L.CHICAGO, L.DALLAS);

            Assert.AreEqual(chicagoToDallas.LoadTime, DateTime.Parse("2008-10-24 21:25"));
            Assert.AreEqual(chicagoToDallas.LoadLocation, L.CHICAGO);
            Assert.AreEqual(chicagoToDallas.UnloadTime, DateTime.Parse("2008-10-25 19:30"));
            Assert.AreEqual(chicagoToDallas.UnloadLocation, L.DALLAS);
        }
コード例 #7
0
        public void legThatFollowsAnEntireVoyage()
        {
            Leg newYorkToDallas = Leg.DeriveLeg(voyage, L.NEWYORK, L.DALLAS);

            Assert.AreEqual(newYorkToDallas.LoadTime, DateTime.Parse("2008-10-24 07:00"));
            Assert.AreEqual(newYorkToDallas.LoadLocation, L.NEWYORK);
            Assert.AreEqual(newYorkToDallas.UnloadTime, DateTime.Parse("2008-10-25 19:30"));
            Assert.AreEqual(newYorkToDallas.UnloadLocation, L.DALLAS);
        }
コード例 #8
0
        public void matchActivity()
        {
            Leg newYorkToDallas = Leg.DeriveLeg(voyage, L.NEWYORK, L.DALLAS);

            Assert.True(newYorkToDallas.MatchesActivity(HandlingActivity.LoadOnto(voyage).In(L.NEWYORK)));
            Assert.True(newYorkToDallas.MatchesActivity(HandlingActivity.UnloadOff(voyage).In(L.DALLAS)));
            Assert.False(newYorkToDallas.MatchesActivity(HandlingActivity.LoadOnto(voyage).In(L.DALLAS)));
            Assert.False(newYorkToDallas.MatchesActivity(HandlingActivity.UnloadOff(voyage).In(L.NEWYORK)));
        }
コード例 #9
0
        public void deriveActivities()
        {
            Leg newYorkToDallas = Leg.DeriveLeg(voyage, L.NEWYORK, L.DALLAS);

            Assert.That(newYorkToDallas.DeriveLoadActivity(),
                        Is.EqualTo(HandlingActivity.LoadOnto(voyage).In(L.NEWYORK)));
            Assert.That(newYorkToDallas.DeriveUnloadActivity(),
                        Is.EqualTo(HandlingActivity.UnloadOff(voyage).In(L.DALLAS)));
        }
コード例 #10
0
        private Cargo setUpCargoWithItinerary(Location origin, Location midpoint, Location destination)
        {
            Cargo cargo = new Cargo(new TrackingId("CARGO1"), new RouteSpecification(origin, destination, DateTime.Now));

            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(crazyVoyage, origin, midpoint),
                                                Leg.DeriveLeg(crazyVoyage, midpoint, destination));

            cargo.AssignToRoute(itinerary);
            return(cargo);
        }
コード例 #11
0
 protected void setUp()
 {
     routeSpecification = new RouteSpecification(L.HANGZOU, L.STOCKHOLM, DateTime.Parse("2008-11-03"));
     itinerary          = new Itinerary(
         Leg.DeriveLeg(V.HONGKONG_TO_NEW_YORK, L.HANGZOU, L.NEWYORK),
         Leg.DeriveLeg(V.NEW_YORK_TO_DALLAS, L.NEWYORK, L.DALLAS),
         Leg.DeriveLeg(V.DALLAS_TO_HELSINKI, L.DALLAS, L.STOCKHOLM));
     delivery = Delivery.BeforeHandling();
     Thread.Sleep(1);
 }
コード例 #12
0
        public void testNextLeg()
        {
            Leg shanghaiToLongBeach = Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH);
            Leg longBeachToNewYork  = Leg.DeriveLeg(transcontinental, L.LONGBEACH, L.NEWYORK);
            Leg newYorkToRotterdam  = Leg.DeriveLeg(atlantic, L.NEWYORK, L.ROTTERDAM);

            Itinerary itinerary = new Itinerary(shanghaiToLongBeach, longBeachToNewYork, newYorkToRotterdam);

            Assert.That(itinerary.NextLeg(shanghaiToLongBeach), Is.EqualTo(longBeachToNewYork));
            Assert.That(itinerary.NextLeg(longBeachToNewYork), Is.EqualTo(newYorkToRotterdam));
            Assert.IsNull(itinerary.NextLeg(newYorkToRotterdam));
        }
コード例 #13
0
        private Cargo shanghaiSeattleChicagoOnPacific2AndContinental3()
        {
            Cargo cargo = new Cargo(new TrackingId("CARGO1"),
                                    new RouteSpecification(L.SHANGHAI, L.CHICAGO, DateTime.Parse("2009-12-24")));

            // A cargo with no itinerary is not misdirected
            Assert.IsFalse(cargo.IsMisdirected);

            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(V.pacific2, L.SHANGHAI, L.SEATTLE),
                                                Leg.DeriveLeg(V.continental3, L.SEATTLE, L.CHICAGO));

            cargo.AssignToRoute(itinerary);
            return(cargo);
        }
コード例 #14
0
        internal static Itinerary fromDTO(RouteCandidateDTO routeCandidateDTO,
                                          VoyageRepository voyageRepository,
                                          LocationRepository locationRepository)
        {
            var legs = new List <Leg>(routeCandidateDTO.getLegs().Count());

            foreach (LegDTO legDTO in routeCandidateDTO.getLegs())
            {
                var voyageNumber = new VoyageNumber(legDTO.getVoyageNumber());
                var voyage       = voyageRepository.find(voyageNumber);
                var from         = locationRepository.find(new UnLocode(legDTO.getFrom()));
                var to           = locationRepository.find(new UnLocode(legDTO.getTo()));
                legs.Add(Leg.DeriveLeg(voyage, from, to));
            }
            return(new Itinerary(legs));
        }
コード例 #15
0
        public void testRoutingStatus()
        {
            Cargo cargo = new Cargo(new TrackingId("XYZ"),
                                    new RouteSpecification(L.STOCKHOLM, L.MELBOURNE, DateTime.Now));
            Itinerary          good           = new Itinerary(Leg.DeriveLeg(northernRail, L.SEATTLE, L.NEWYORK));
            Itinerary          bad            = new Itinerary(Leg.DeriveLeg(crazyVoyage, L.HAMBURG, L.HONGKONG));
            RouteSpecification acceptOnlyGood = new RouteSpecification(L.SEATTLE, L.NEWYORK, DateTime.Now);

            cargo.SpecifyNewRoute(acceptOnlyGood);
            Assert.AreEqual(RoutingStatus.NOT_ROUTED, cargo.RoutingStatus);

            cargo.AssignToRoute(bad);
            Assert.AreEqual(RoutingStatus.MISROUTED, cargo.RoutingStatus);

            cargo.AssignToRoute(good);
            Assert.AreEqual(RoutingStatus.ROUTED, cargo.RoutingStatus);
        }
コード例 #16
0
        public void testIsReadyToClaimWithDestinationSameAsCustomsClearancePoint()
        {
            Cargo cargo = new Cargo(new TrackingId("CARGO1"),
                                    new RouteSpecification(L.SHANGHAI, L.SEATTLE, DateTime.Parse("2009-12-24")));
            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(V.pacific2, L.SHANGHAI, L.SEATTLE));

            cargo.AssignToRoute(itinerary);
            Assert.IsTrue(cargo.RouteSpecification.Destination.sameAs(cargo.CustomsClearancePoint));
            Assert.IsFalse(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.UnloadOff(V.pacific2).In(L.SEATTLE));
            Assert.IsFalse(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.CustomsIn(L.SEATTLE));
            Assert.IsTrue(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.ClaimIn(L.SEATTLE));
            Assert.IsFalse(cargo.IsReadyToClaim);
        }
コード例 #17
0
        public void testSave()
        {
            TrackingId trackingId  = new TrackingId("AAA");
            Location   origin      = locationRepository.find(SampleLocations.STOCKHOLM.UnLocode);
            Location   destination = locationRepository.find(SampleLocations.MELBOURNE.UnLocode);

            Cargo cargo = new Cargo(trackingId, new RouteSpecification(origin, destination, DateTime.Now));

            cargoRepository.store(cargo);

            getSession().Flush();
            getSession().Clear();

            cargo = cargoRepository.find(trackingId);
            Assert.IsNull(cargo.Itinerary);

            cargo.AssignToRoute(
                new Itinerary(Leg.DeriveLeg(voyageRepository.find(new VoyageNumber("0101")),
                                            locationRepository.find(SampleLocations.STOCKHOLM.UnLocode),
                                            locationRepository.find(SampleLocations.MELBOURNE.UnLocode))));

            flush();

            var map = GenericTemplate.QueryForObjectDelegate(CommandType.Text,
                                                             String.Format("select * from Cargo where tracking_id = '{0}'", trackingId.Value),
                                                             (r, i) => new { TRACKING_ID = r["TRACKING_ID"] });

            Assert.AreEqual("AAA", map.TRACKING_ID);

            long originId = (long)getSession().GetIdentifier(cargo);
            //Assert.AreEqual(originId, map.get("SPEC_ORIGIN_ID"));

            long destinationId = (long)getSession().GetIdentifier(cargo);

            //Assert.AreEqual(destinationId, map.get("SPEC_DESTINATION_ID"));

            getSession().Clear();

            Cargo loadedCargo = cargoRepository.find(trackingId);

            Assert.AreEqual(1, loadedCargo.Itinerary.Legs.Count());
        }
コード例 #18
0
        public void testLatestLeg()
        {
            Leg shanghaiToLongBeach = Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH);
            Leg longBeachToNewYork  = Leg.DeriveLeg(transcontinental, L.LONGBEACH, L.NEWYORK);
            Leg newYorkToRotterdam  = Leg.DeriveLeg(atlantic, L.NEWYORK, L.ROTTERDAM);

            Itinerary itinerary = new Itinerary(shanghaiToLongBeach, longBeachToNewYork, newYorkToRotterdam);

            HandlingActivity notOnRoute        = HandlingActivity.LoadOnto(pacific).In(L.STOCKHOLM);
            HandlingActivity loadInShanghai    = HandlingActivity.LoadOnto(pacific).In(L.SHANGHAI);
            HandlingActivity unloadInLongbeach = HandlingActivity.UnloadOff(pacific).In(L.LONGBEACH);

            Assert.That(itinerary.StrictlyPriorOf(loadInShanghai, unloadInLongbeach), Is.EqualTo(loadInShanghai));
            Assert.That(itinerary.StrictlyPriorOf(unloadInLongbeach, loadInShanghai), Is.EqualTo(loadInShanghai));

            Assert.That(itinerary.StrictlyPriorOf(unloadInLongbeach, notOnRoute), Is.EqualTo(unloadInLongbeach));
            Assert.That(itinerary.StrictlyPriorOf(notOnRoute, loadInShanghai), Is.EqualTo(loadInShanghai));

            Assert.IsNull(itinerary.StrictlyPriorOf(unloadInLongbeach, unloadInLongbeach));
        }
コード例 #19
0
        public void testIsReadyToClaimWithDestinationDifferentFromCustomsClearancePoint()
        {
            Cargo cargo = new Cargo(new TrackingId("CARGO1"),
                                    new RouteSpecification(L.HONGKONG, L.NEWYORK, DateTime.Parse("2009-12-24")));
            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(V.pacific1, L.HONGKONG, L.LONGBEACH),
                                                Leg.DeriveLeg(V.continental2, L.LONGBEACH, L.NEWYORK));

            cargo.AssignToRoute(itinerary);
            Assert.IsFalse(cargo.RouteSpecification.Destination.sameAs(cargo.CustomsClearancePoint));
            Assert.IsFalse(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.UnloadOff(V.pacific1).In(L.LONGBEACH));
            Assert.IsFalse(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.LoadOnto(V.continental2).In(L.LONGBEACH));
            Assert.IsFalse(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.UnloadOff(V.continental2).In(L.NEWYORK));
            Assert.IsTrue(cargo.IsReadyToClaim);
        }
コード例 #20
0
        public void toRouteCandidateDTO()
        {
            var itinerary = new Itinerary(
                Leg.DeriveLeg(SampleVoyages.pacific1, L.HONGKONG, L.TOKYO),
                Leg.DeriveLeg(SampleVoyages.pacific1, L.TOKYO, L.LONGBEACH)
                );

            var dto = DTOAssembler.toDTO(itinerary);

            Assert.AreEqual(2, dto.getLegs().Count());
            LegDTO legDTO = dto.getLegs().ElementAt(0);

            Assert.AreEqual("PAC1", legDTO.getVoyageNumber());
            Assert.AreEqual("CNHKG", legDTO.getFrom());
            Assert.AreEqual("JNTKO", legDTO.getTo());

            legDTO = dto.getLegs().ElementAt(1);
            Assert.AreEqual("PAC1", legDTO.getVoyageNumber());
            Assert.AreEqual("JNTKO", legDTO.getFrom());
            Assert.AreEqual("USLBG", legDTO.getTo());
        }
コード例 #21
0
        public void setupCargo()
        {
            TrackingIdFactoryInMem trackingIdFactory = new TrackingIdFactoryInMem();

            // Creating new voyages to avoid rescheduling shared ones, breaking other tests
            voyage1 = new Voyage(new VoyageNumber("V1"), V.HONGKONG_TO_NEW_YORK.Schedule);
            voyage2 = new Voyage(new VoyageNumber("V2"), V.NEW_YORK_TO_DALLAS.Schedule);
            voyage3 = new Voyage(new VoyageNumber("V3"), V.DALLAS_TO_HELSINKI.Schedule);

            TrackingId         trackingId         = trackingIdFactory.nextTrackingId();
            RouteSpecification routeSpecification = new RouteSpecification(L.HANGZOU,
                                                                           L.STOCKHOLM,
                                                                           DateTime.Parse("2008-12-23"));

            cargo = new Cargo(trackingId, routeSpecification);
            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(voyage1, L.HANGZOU, L.NEWYORK),
                                                Leg.DeriveLeg(voyage2, L.NEWYORK, L.DALLAS),
                                                Leg.DeriveLeg(voyage3, L.DALLAS, L.STOCKHOLM));

            cargo.AssignToRoute(itinerary);
        }
コード例 #22
0
        public void testCustomsClearancePoint()
        {
            //cargo destination NYC
            Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(L.SHANGHAI, L.NEWYORK, DateTime.Now));

            Assert.That(cargo.CustomsClearancePoint, Is.EqualTo(Location.None));

            //SHA-LGB-NYC
            cargo.AssignToRoute(new Itinerary(Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH),
                                              Leg.DeriveLeg(transcontinental, L.LONGBEACH, L.NEWYORK)));
            Assert.AreEqual(L.LONGBEACH, cargo.CustomsClearancePoint);

            //SHA-SEA-NYC
            cargo.AssignToRoute(new Itinerary(Leg.DeriveLeg(pacific, L.SHANGHAI, L.SEATTLE),
                                              Leg.DeriveLeg(northernRail, L.SEATTLE, L.NEWYORK)));
            Assert.AreEqual(L.SEATTLE, cargo.CustomsClearancePoint);

            //cargo destination LGB
            //SHA-LGB
            cargo.SpecifyNewRoute(new RouteSpecification(L.SHANGHAI, L.LONGBEACH, DateTime.Now));
            cargo.AssignToRoute(new Itinerary(Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH)));
            Assert.AreEqual(L.LONGBEACH, cargo.CustomsClearancePoint);

            //Cargo destination HAMBURG
            //SHA-LGB-NYC This itinerary does not take
            // the cargo into its CustomsZone, so no clearancePoint.
            cargo.SpecifyNewRoute(new RouteSpecification(L.SHANGHAI, L.HAMBURG, DateTime.Now));
            cargo.AssignToRoute(new Itinerary(Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH),
                                              Leg.DeriveLeg(transcontinental, L.LONGBEACH, L.NEWYORK)));
            Assert.IsNull(cargo.CustomsClearancePoint);

            //Cargo destination NEWYORK on SHA-LGB-CHI
            //This itinerary does not take the cargo to its destination,
            //but it does enter the CustomsZone, so it has a clearancePoint.
            cargo.SpecifyNewRoute(new RouteSpecification(L.SHANGHAI, L.NEWYORK, DateTime.Now));
            cargo.AssignToRoute(new Itinerary(Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH),
                                              Leg.DeriveLeg(transcontinental, L.LONGBEACH, L.CHICAGO)));
            Assert.AreEqual(L.LONGBEACH, cargo.CustomsClearancePoint);
        }
コード例 #23
0
        public void testReplaceItinerary()
        {
            Cargo cargo   = cargoRepository.find(new TrackingId("FGH"));
            long  cargoId = (long)getSession().GetIdentifier(cargo);

            Assert.AreEqual(3,
                            GenericTemplate.ExecuteScalar(CommandType.Text,
                                                          String.Format("select count(*) from Leg where cargo_id = {0}", cargoId)));

            Location  legFrom      = locationRepository.find(new UnLocode("DEHAM"));
            Location  legTo        = locationRepository.find(new UnLocode("FIHEL"));
            Itinerary newItinerary = new Itinerary(Leg.DeriveLeg(SampleVoyages.atlantic2, legFrom, legTo));

            cargo.AssignToRoute(newItinerary);

            cargoRepository.store(cargo);
            flush();

            Assert.AreEqual(1,
                            GenericTemplate.ExecuteScalar(CommandType.Text,
                                                          String.Format("select count(*) from Leg where cargo_id = {0}", cargoId)));
        }
コード例 #24
0
        public void testIsMisdirectedAfterRerouting()
        {
            Cargo cargo = shanghaiSeattleChicagoOnPacific2AndContinental3();

            cargo.Handled(HandlingActivity.LoadOnto(V.pacific2).In(L.SHANGHAI));
            Assert.IsFalse(cargo.IsMisdirected);

            // Cargo destination is changed by customer mid-route
            RouteSpecification newRouteSpec =
                cargo.RouteSpecification.WithOrigin(cargo.LastKnownLocation).WithDestination(L.NEWYORK);

            cargo.SpecifyNewRoute(newRouteSpec);
            // Misrouted, but not misdirected. Delivery is still accoring to plan (itinerary),
            // but not according to desire (route specification).
            Assert.IsFalse(cargo.IsMisdirected);
            Assert.IsTrue(cargo.RoutingStatus == RoutingStatus.MISROUTED);

            /**
             * This is a perfect example of how LegActivityMatch is a modelling breakthrough.
             * It allows us to easily construct an itinerary that completes the remainder of the
             * old itinerary and appends the new and different path.
             */
            Leg       currentLeg   = cargo.Itinerary.MatchLeg(cargo.MostRecentHandlingActivity).Leg;
            Itinerary newItinerary = new Itinerary(currentLeg, Leg.DeriveLeg(V.continental3, L.SEATTLE, L.NEWYORK));

            cargo.AssignToRoute(newItinerary);
            Assert.IsFalse(cargo.IsMisdirected);

            cargo.Handled(HandlingActivity.UnloadOff(V.pacific2).In(L.SEATTLE));
            Assert.IsFalse(cargo.IsMisdirected);

            cargo.Handled(HandlingActivity.LoadOnto(V.continental3).In(L.SEATTLE));
            Assert.IsFalse(cargo.IsMisdirected);

            cargo.Handled(HandlingActivity.UnloadOff(V.continental3).In(L.NEWYORK));
            Assert.IsFalse(cargo.IsMisdirected);
        }
コード例 #25
0
        public void testTruncatedAfter()
        {
            Leg shanghaiToLongBeach = Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH);
            Leg longBeachToNewYork  = Leg.DeriveLeg(transcontinental, L.LONGBEACH, L.NEWYORK);
            Leg newYorkToRotterdam  = Leg.DeriveLeg(atlantic, L.NEWYORK, L.ROTTERDAM);

            Itinerary itinerary = new Itinerary(shanghaiToLongBeach, longBeachToNewYork, newYorkToRotterdam);

            Itinerary toNewYork = itinerary.TruncatedAfter(L.NEWYORK);

            Assert.AreEqual(new[] { shanghaiToLongBeach, longBeachToNewYork }.ToList(), toNewYork.Legs);

            Itinerary toChicago = itinerary.TruncatedAfter(L.CHICAGO);

            Assert.AreEqual(
                new[] { shanghaiToLongBeach, Leg.DeriveLeg(transcontinental, L.LONGBEACH, L.CHICAGO) }.ToList(),
                toChicago.Legs);

            Itinerary toRotterdam = itinerary.TruncatedAfter(L.ROTTERDAM);

            Assert.AreEqual(
                new[] { shanghaiToLongBeach, longBeachToNewYork, Leg.DeriveLeg(atlantic, L.NEWYORK, L.ROTTERDAM) }.ToList(),
                toRotterdam.Legs);
        }
コード例 #26
0
        public void testMatchingLeg()
        {
            Leg       shanghaiToRotterdam   = Leg.DeriveLeg(voyage, L.SHANGHAI, L.ROTTERDAM);
            Leg       rotterdamToGothenburg = Leg.DeriveLeg(voyage, L.ROTTERDAM, L.GOTHENBURG);
            Itinerary itinerary             = new Itinerary(shanghaiToRotterdam, rotterdamToGothenburg);

            Assert.That(itinerary.MatchLeg(HandlingActivity.ReceiveIn(L.SHANGHAI)).Leg,
                        Is.EqualTo(shanghaiToRotterdam));
            Assert.That(itinerary.MatchLeg(HandlingActivity.LoadOnto(voyage).In(L.SHANGHAI)).Leg,
                        Is.EqualTo(shanghaiToRotterdam));
            Assert.That(itinerary.MatchLeg(HandlingActivity.UnloadOff(voyage).In(L.ROTTERDAM)).Leg,
                        Is.EqualTo(shanghaiToRotterdam));
            Assert.That(itinerary.MatchLeg(HandlingActivity.ClaimIn(L.GOTHENBURG)).Leg,
                        Is.EqualTo(rotterdamToGothenburg));

            Assert.IsNull(itinerary.MatchLeg(HandlingActivity.LoadOnto(wrongVoyage).In(L.SHANGHAI)).Leg);
            Assert.IsNull(itinerary.MatchLeg(HandlingActivity.LoadOnto(wrongVoyage).In(L.NEWYORK)).Leg);

            Assert.IsNull(itinerary.MatchLeg(HandlingActivity.UnloadOff(wrongVoyage).In(L.ROTTERDAM)).Leg);
            Assert.IsNull(itinerary.MatchLeg(HandlingActivity.UnloadOff(wrongVoyage).In(L.NEWYORK)).Leg);

            Assert.IsNull(itinerary.MatchLeg(HandlingActivity.ReceiveIn(L.NEWYORK)).Leg);
            Assert.IsNull(itinerary.MatchLeg(HandlingActivity.ClaimIn(L.NEWYORK)).Leg);
        }
コード例 #27
0
 public void endLocationNotOnVoyage()
 {
     Leg.DeriveLeg(voyage, L.CHICAGO, L.HELSINKI);
 }
コード例 #28
0
 public void locationsInWrongOrder()
 {
     Leg.DeriveLeg(voyage, L.DALLAS, L.CHICAGO);
 }
コード例 #29
0
 public void startLocationNotOnVoyage()
 {
     Leg.DeriveLeg(voyage, L.HONGKONG, L.DALLAS);
 }
コード例 #30
0
        public void intermediateLocations()
        {
            Leg leg = Leg.DeriveLeg(SampleVoyages.HONGKONG_TO_NEW_YORK, L.HONGKONG, L.NEWYORK);

            Assert.AreEqual(new[] { L.HANGZOU, L.TOKYO, L.MELBOURNE }.ToList(), leg.IntermediateLocations);
        }