Exemplo n.º 1
0
        public void testSave()
        {
            var unLocode = new UnLocode("SESTO");

            var           trackingId     = new TrackingId("XYZ");
            var           completionTime = DateTime.Parse("2008-01-01");
            HandlingEvent @event         = HandlingEventFactory.createHandlingEvent(completionTime,
                                                                                    trackingId,
                                                                                    null,
                                                                                    unLocode,
                                                                                    HandlingActivityType.CLAIM,
                                                                                    null);

            HandlingEventRepository.store(@event);

            flush();

            var result = GenericTemplate.QueryForObjectDelegate(CommandType.Text,
                                                                String.Format("select * from HandlingEvent where sequence_number = {0}", @event.SequenceNumber),
                                                                (r, i) => new { CARGO_ID = r["CARGO_ID"], COMPLETIONTIME = r["COMPLETIONTIME"] });

            Assert.AreEqual(1L, result.CARGO_ID);
            Assert.AreEqual(completionTime, result.COMPLETIONTIME);
            // TODO: the rest of the columns
        }
Exemplo n.º 2
0
 public CargoUpdater(SystemEvents systemEvents,
                     CargoRepository cargoRepository,
                     HandlingEventRepository handlingEventRepository)
 {
     this.systemEvents = systemEvents;
     this.cargoRepository = cargoRepository;
     this.handlingEventRepository = handlingEventRepository;
 }
Exemplo n.º 3
0
 public ReportPusher(ReportSubmission reportSubmission,
                     CargoRepository cargoRepository,
                     HandlingEventRepository handlingEventRepository)
 {
     this.reportSubmission        = reportSubmission;
     this.cargoRepository         = cargoRepository;
     this.handlingEventRepository = handlingEventRepository;
 }
 public HandlingEventServiceImpl(HandlingEventRepository handlingEventRepository,
                                 SystemEvents systemEvents,
                                 HandlingEventFactory handlingEventFactory)
 {
     this.handlingEventRepository = handlingEventRepository;
     this.systemEvents = systemEvents;
     this.handlingEventFactory = handlingEventFactory;
 }
Exemplo n.º 5
0
 public HandlingEventServiceImpl(HandlingEventRepository handlingEventRepository,
                                 SystemEvents systemEvents,
                                 HandlingEventFactory handlingEventFactory)
 {
     this.handlingEventRepository = handlingEventRepository;
     this.systemEvents            = systemEvents;
     this.handlingEventFactory    = handlingEventFactory;
 }
Exemplo n.º 6
0
 public ReportPusher(ReportSubmission reportSubmission,
                     CargoRepository cargoRepository,
                     HandlingEventRepository handlingEventRepository)
 {
     this.reportSubmission = reportSubmission;
     this.cargoRepository = cargoRepository;
     this.handlingEventRepository = handlingEventRepository;
 }
Exemplo n.º 7
0
        public void testFindEventsForCargo()
        {
            Cargo cargo = CargoRepository.find(new TrackingId("XYZ"));
            IEnumerable <HandlingEvent> handlingEvents =
                HandlingEventRepository.lookupHandlingHistoryOfCargo(cargo).distinctEventsByCompletionTime();

            Assert.AreEqual(12, handlingEvents.Count());
        }
Exemplo n.º 8
0
 public CargoUpdater(SystemEvents systemEvents,
                     CargoRepository cargoRepository,
                     HandlingEventRepository handlingEventRepository)
 {
     this.systemEvents            = systemEvents;
     this.cargoRepository         = cargoRepository;
     this.handlingEventRepository = handlingEventRepository;
 }
Exemplo n.º 9
0
        public void testMostRecentHandling()
        {
            Cargo         cargo         = CargoRepository.find(new TrackingId("XYZ"));
            HandlingEvent handlingEvent = HandlingEventRepository.mostRecentHandling(cargo);

            Assert.AreEqual(cargo, handlingEvent.Cargo);
            Assert.AreEqual(DateTime.Parse("2007-09-27 04:00"), handlingEvent.CompletionTime);

            Assert.AreEqual(HandlingActivity.ClaimIn(SampleLocations.MELBOURNE), handlingEvent.Activity);
            Assert.AreEqual(handlingEvent.Activity, HandlingActivity.ClaimIn(SampleLocations.MELBOURNE));
        }
Exemplo n.º 10
0
 public void setUp()
 {
     systemEvents = MockRepository.GenerateMock<SystemEvents>();
     cargoRepository = new CargoRepositoryInMem();
     handlingEventRepository = new HandlingEventRepositoryInMem();
     locationRepository = new LocationRepositoryInMem();
     voyageRepository = new VoyageRepositoryInMem();
     trackingIdFactory = new TrackingIdFactoryInMem();
     handlingEventFactory = new HandlingEventFactory(cargoRepository, voyageRepository, locationRepository);
     cargoUpdater = new CargoUpdater(systemEvents, cargoRepository, handlingEventRepository);
 }
Exemplo n.º 11
0
 public void setUp()
 {
     systemEvents            = MockRepository.GenerateMock <SystemEvents>();
     cargoRepository         = new CargoRepositoryInMem();
     handlingEventRepository = new HandlingEventRepositoryInMem();
     locationRepository      = new LocationRepositoryInMem();
     voyageRepository        = new VoyageRepositoryInMem();
     trackingIdFactory       = new TrackingIdFactoryInMem();
     handlingEventFactory    = new HandlingEventFactory(cargoRepository, voyageRepository, locationRepository);
     cargoUpdater            = new CargoUpdater(systemEvents, cargoRepository, handlingEventRepository);
 }
        protected void setUp()
        {
            cargoRepository = MockRepository.GenerateMock<CargoRepository>();
            voyageRepository = MockRepository.GenerateMock<VoyageRepository>();
            handlingEventRepository = MockRepository.GenerateMock<HandlingEventRepository>();
            locationRepository = MockRepository.GenerateMock<LocationRepository>();
            systemEvents = MockRepository.GenerateMock<SystemEvents>();

            HandlingEventFactory handlingEventFactory = new HandlingEventFactory(cargoRepository,
                voyageRepository,
                locationRepository);
            service = new HandlingEventServiceImpl(handlingEventRepository, systemEvents, handlingEventFactory);
        }
Exemplo n.º 13
0
        public void testFindByCargoId()
        {
            TrackingId trackingId = new TrackingId("FGH");
            Cargo      cargo      = cargoRepository.find(trackingId);

            Assert.AreEqual(SampleLocations.HONGKONG, cargo.RouteSpecification.Origin);
            Assert.AreEqual(SampleLocations.HELSINKI, cargo.RouteSpecification.Destination);

            IEnumerable <HandlingEvent> events =
                HandlingEventRepository.lookupHandlingHistoryOfCargo(cargo).distinctEventsByCompletionTime();

            Assert.AreEqual(2, events.Count());

            HandlingEvent firstEvent = events.ElementAt(0);

            assertHandlingEvent(cargo, firstEvent, HandlingActivityType.RECEIVE, SampleLocations.HONGKONG, 100, 160, Voyage.None);

            HandlingEvent secondEvent = events.ElementAt(1);

            Voyage hongkongMelbourneTokyoAndBack =
                new Voyage.Builder(new VoyageNumber("0303"), SampleLocations.HONGKONG).addMovement(SampleLocations.MELBOURNE,
                                                                                                   new DateTime(1),
                                                                                                   new DateTime(2)).addMovement(SampleLocations.TOKYO, new DateTime(3), new DateTime(4)).addMovement(SampleLocations.HONGKONG,
                                                                                                                                                                                                     new DateTime(5),
                                                                                                                                                                                                     new DateTime(6)).build();

            assertHandlingEvent(cargo,
                                secondEvent,
                                HandlingActivityType.LOAD,
                                SampleLocations.HONGKONG,
                                150,
                                110,
                                hongkongMelbourneTokyoAndBack);

            IEnumerable <Leg> legs = cargo.Itinerary.Legs;

            Assert.AreEqual(3, legs.Count());

            Leg firstLeg = legs.ElementAt(0);

            assertLeg(firstLeg, "0101", SampleLocations.HONGKONG, SampleLocations.MELBOURNE);

            Leg secondLeg = legs.ElementAt(1);

            assertLeg(secondLeg, "0101", SampleLocations.MELBOURNE, SampleLocations.STOCKHOLM);

            Leg thirdLeg = legs.ElementAt(2);

            assertLeg(thirdLeg, "0101", SampleLocations.STOCKHOLM, SampleLocations.HELSINKI);
        }
        protected void setUp()
        {
            cargoRepository         = MockRepository.GenerateMock <CargoRepository>();
            voyageRepository        = MockRepository.GenerateMock <VoyageRepository>();
            handlingEventRepository = MockRepository.GenerateMock <HandlingEventRepository>();
            locationRepository      = MockRepository.GenerateMock <LocationRepository>();
            systemEvents            = MockRepository.GenerateMock <SystemEvents>();

            HandlingEventFactory handlingEventFactory = new HandlingEventFactory(cargoRepository,
                                                                                 voyageRepository,
                                                                                 locationRepository);

            service = new HandlingEventServiceImpl(handlingEventRepository, systemEvents, handlingEventFactory);
        }
Exemplo n.º 15
0
        public void LoadHibernateData()
        {
            var tt = new TransactionTemplate(transactionManager);

            tt.Execute(ts => {
                var session = SessionFactory.GetCurrentSession();

                foreach (var location in SampleLocations.getAll())
                {
                    session.Save(location);
                }

                session.Save(SampleVoyages.HONGKONG_TO_NEW_YORK);
                session.Save(SampleVoyages.NEW_YORK_TO_DALLAS);
                session.Save(SampleVoyages.DALLAS_TO_HELSINKI);
                session.Save(SampleVoyages.HELSINKI_TO_HONGKONG);
                session.Save(SampleVoyages.DALLAS_TO_HELSINKI_ALT);

                var routeSpecification = new RouteSpecification(
                    SampleLocations.HONGKONG,
                    SampleLocations.HELSINKI,
                    DateTime.Parse("2009-03-15"));
                var trackingId = new TrackingId("ABC123");
                var abc123     = new Cargo(trackingId, routeSpecification);

                var itinerary = new Itinerary(new[] {
                    Leg.DeriveLeg(SampleVoyages.HONGKONG_TO_NEW_YORK, SampleLocations.HONGKONG, SampleLocations.NEWYORK),
                    Leg.DeriveLeg(SampleVoyages.NEW_YORK_TO_DALLAS, SampleLocations.NEWYORK, SampleLocations.DALLAS),
                    Leg.DeriveLeg(SampleVoyages.DALLAS_TO_HELSINKI, SampleLocations.DALLAS, SampleLocations.HELSINKI),
                });

                abc123.AssignToRoute(itinerary);

                session.Save(abc123);

                var event01 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-01"),
                    trackingId,
                    null,
                    SampleLocations.HONGKONG.UnLocode,
                    HandlingActivityType.RECEIVE,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event01);

                var event02 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-02"),
                    trackingId,
                    SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber,
                    SampleLocations.HONGKONG.UnLocode,
                    HandlingActivityType.LOAD,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event02);

                var event03 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-05"),
                    trackingId,
                    SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber,
                    SampleLocations.NEWYORK.UnLocode,
                    HandlingActivityType.UNLOAD,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event03);

                var handlingEvent = HandlingEventRepository.mostRecentHandling(abc123);
                abc123.Handled(handlingEvent.Activity);
                session.Update(abc123);

                // Cargo JKL567

                var routeSpecification1 = new RouteSpecification(
                    SampleLocations.HANGZOU,
                    SampleLocations.STOCKHOLM,
                    DateTime.Parse("2009-03-18"));
                var trackingId1 = new TrackingId("JKL567");
                var jkl567      = new Cargo(trackingId1, routeSpecification1);

                var itinerary1 = new Itinerary(new[] {
                    Leg.DeriveLeg(SampleVoyages.HONGKONG_TO_NEW_YORK, SampleLocations.HANGZOU, SampleLocations.NEWYORK),
                    Leg.DeriveLeg(SampleVoyages.NEW_YORK_TO_DALLAS, SampleLocations.NEWYORK, SampleLocations.DALLAS),
                    Leg.DeriveLeg(SampleVoyages.DALLAS_TO_HELSINKI, SampleLocations.DALLAS, SampleLocations.STOCKHOLM),
                });
                jkl567.AssignToRoute(itinerary1);

                session.Save(jkl567);

                var event1 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-01"),
                    trackingId1,
                    null,
                    SampleLocations.HANGZOU.UnLocode,
                    HandlingActivityType.RECEIVE,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event1);

                var event2 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-03"),
                    trackingId1,
                    SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber,
                    SampleLocations.HANGZOU.UnLocode,
                    HandlingActivityType.LOAD,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event2);

                var event3 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-05"),
                    trackingId1,
                    SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber,
                    SampleLocations.NEWYORK.UnLocode,
                    HandlingActivityType.UNLOAD,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event3);

                var event4 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-06"),
                    trackingId1,
                    SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber,
                    SampleLocations.NEWYORK.UnLocode,
                    HandlingActivityType.LOAD,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event4);

                var handlingEvent1 = HandlingEventRepository.mostRecentHandling(jkl567);
                jkl567.Handled(handlingEvent1.Activity);
                session.Update(jkl567);

                return(null);
            });
        }
Exemplo n.º 16
0
 public TrackingController(CargoRepository cargoRepository, HandlingEventRepository handlingEventRepository)
 {
     _cargoRepository = cargoRepository;
     _handlingEventRepository = handlingEventRepository;
 }
Exemplo n.º 17
0
 public TrackingController(CargoRepository cargoRepository, HandlingEventRepository handlingEventRepository)
 {
     _cargoRepository         = cargoRepository;
     _handlingEventRepository = handlingEventRepository;
 }