public TrackingId bookNewCargo(UnLocode originUnLocode, UnLocode destinationUnLocode, DateTime arrivalDeadline) { var trackingId = _trackingIdFactory.nextTrackingId(); var origin = _locationRepository.find(originUnLocode); var destination = _locationRepository.find(destinationUnLocode); var routeSpecification = new RouteSpecification(origin, destination, arrivalDeadline); var cargo = new Cargo(trackingId, routeSpecification); _cargoRepository.store(cargo); _logger.Info("Booked new cargo with tracking id " + cargo.TrackingId.Value); return(cargo.TrackingId); }
public void updateCargo() { TrackingId trackingId = trackingIdFactory.nextTrackingId(); RouteSpecification routeSpecification = new RouteSpecification(L.HONGKONG, L.GOTHENBURG, DateTime.Parse("2009-10-15")); Cargo cargo = new Cargo(trackingId, routeSpecification); cargoRepository.store(cargo); HandlingEvent handlingEvent = handlingEventFactory.createHandlingEvent(DateTime.Parse("2009-10-01 14:30"), cargo.TrackingId, V.HONGKONG_TO_NEW_YORK.VoyageNumber, L.HONGKONG.UnLocode, HandlingActivityType.LOAD, new OperatorCode("ABCDE")); handlingEventRepository.store(handlingEvent); Assert.That(handlingEvent.Activity, Is.Not.EqualTo(cargo.MostRecentHandlingActivity)); cargoUpdater.updateCargo(handlingEvent.SequenceNumber); Assert.That(handlingEvent.Activity, Is.EqualTo(cargo.MostRecentHandlingActivity)); Assert.True(handlingEvent.Activity != cargo.MostRecentHandlingActivity); systemEvents.AssertWasCalled(se => se.notifyOfCargoUpdate(cargo)); }
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()); }
public void updateCargo(EventSequenceNumber sequenceNumber) { var handlingEvent = handlingEventRepository.find(sequenceNumber); if (handlingEvent == null) { logger.Error("Could not find any handling event with sequence number " + sequenceNumber); return; } var activity = handlingEvent.Activity.Copy(); var cargo = handlingEvent.Cargo; cargo.Handled(activity); cargoRepository.store(cargo); systemEvents.notifyOfCargoUpdate(cargo); logger.Info("Updated cargo " + cargo); }