public void setUp()
        {
            reportSubmission = MockRepository.GenerateMock<ReportSubmission>();
            CargoRepository cargoRepository = new CargoRepositoryInMem();
            HandlingEventRepository handlingEventRepository = new HandlingEventRepositoryInMem();
            HandlingEventFactory handlingEventFactory = new HandlingEventFactory(cargoRepository,
                new VoyageRepositoryInMem(),
                new LocationRepositoryInMem());

            TrackingId trackingId = new TrackingId("ABC");
            RouteSpecification routeSpecification = new RouteSpecification(L.HONGKONG, L.ROTTERDAM, DateTime.Parse("2009-10-10"));
            Cargo cargo = new Cargo(trackingId, routeSpecification);
            cargoRepository.store(cargo);

            HandlingEvent handlingEvent = handlingEventFactory.createHandlingEvent(
                DateTime.Parse("2009-10-02"),
                trackingId,
                null,
                L.HONGKONG.UnLocode,
                HandlingActivityType.RECEIVE,
                new OperatorCode("ABCDE")
                );
            handlingEventRepository.store(handlingEvent);

            cargo.Handled(handlingEvent.Activity);

            reportPusher = new ReportPusher(reportSubmission, cargoRepository, handlingEventRepository);
            eventSequenceNumber = handlingEvent.SequenceNumber;
        }
Beispiel #2
0
        public void setUp()
        {
            reportSubmission = MockRepository.GenerateMock <ReportSubmission>();
            CargoRepository         cargoRepository         = new CargoRepositoryInMem();
            HandlingEventRepository handlingEventRepository = new HandlingEventRepositoryInMem();
            HandlingEventFactory    handlingEventFactory    = new HandlingEventFactory(cargoRepository,
                                                                                       new VoyageRepositoryInMem(),
                                                                                       new LocationRepositoryInMem());

            TrackingId         trackingId         = new TrackingId("ABC");
            RouteSpecification routeSpecification = new RouteSpecification(L.HONGKONG, L.ROTTERDAM, DateTime.Parse("2009-10-10"));
            Cargo cargo = new Cargo(trackingId, routeSpecification);

            cargoRepository.store(cargo);

            HandlingEvent handlingEvent = handlingEventFactory.createHandlingEvent(
                DateTime.Parse("2009-10-02"),
                trackingId,
                null,
                L.HONGKONG.UnLocode,
                HandlingActivityType.RECEIVE,
                new OperatorCode("ABCDE")
                );

            handlingEventRepository.store(handlingEvent);

            cargo.Handled(handlingEvent.Activity);

            reportPusher        = new ReportPusher(reportSubmission, cargoRepository, handlingEventRepository);
            eventSequenceNumber = handlingEvent.SequenceNumber;
        }
Beispiel #3
0
 public HandlingEvent find(EventSequenceNumber eventSequenceNumber)
 {
     return(sessionFactory.GetCurrentSession().
            CreateQuery("from HandlingEvent where SequenceNumber = :sn").
            SetParameter("sn", eventSequenceNumber).
            UniqueResult <HandlingEvent>());
 }
 public HandlingEvent find(EventSequenceNumber eventSequenceNumber)
 {
     return sessionFactory.GetCurrentSession().
       CreateQuery("from HandlingEvent where SequenceNumber = :sn").
       SetParameter("sn", eventSequenceNumber).
       UniqueResult<HandlingEvent>();
 }
Beispiel #5
0
        public void reportHandlingEvent(EventSequenceNumber sequenceNumber)
        {
            HandlingEvent handlingEvent    = handlingEventRepository.find(sequenceNumber);
            Handling      handling         = assembleFrom(handlingEvent);
            string        trackingIdString = handlingEvent.Cargo.TrackingId.Value;

            reportSubmission.submitHandling(trackingIdString, handling);
        }
Beispiel #6
0
        public void reportHandlingEvent(EventSequenceNumber sequenceNumber)
        {
            HandlingEvent handlingEvent = handlingEventRepository.find(sequenceNumber);
            Handling handling = assembleFrom(handlingEvent);
            string trackingIdString = handlingEvent.Cargo.TrackingId.Value;

            reportSubmission.submitHandling(trackingIdString, handling);
        }
 /// <summary>
 /// Initializes a new instance of <see cref="EventProcessorState"/>
 /// </summary>
 /// <param name="eventProcessor"><see cref="IEventProcessor"/> the state is for</param>
 /// <param name="status"><see cref="EventProcessorStatus">Status</see> of the <see cref="IEventProcessor"/></param>
 /// <param name="lastProcessed">When processed last</param>
 /// <param name="lastProcessedSequenceNumber">Last <see cref="EventSequenceNumber"/></param>
 /// <param name="lastProcessedSequenceNumberForEventType">Last <see cref="EventSequenceNumber"/> for the <see cref="IEvent">event type</see></param>
 /// <param name="lastProcessingStatus"><see cref="EventProcessingStatus"/> of the processing</param>
 public EventProcessorState(
     IEventProcessor eventProcessor,
     EventProcessorStatus status,
     DateTimeOffset lastProcessed,
     EventSequenceNumber lastProcessedSequenceNumber,
     EventSequenceNumber lastProcessedSequenceNumberForEventType,
     EventProcessingStatus lastProcessingStatus)
 {
     Status         = status;
     EventProcessor = eventProcessor;
     LastProcessed  = lastProcessed;
     LastProcessedSequenceNumber             = lastProcessedSequenceNumber;
     LastProcessedSequenceNumberForEventType = lastProcessedSequenceNumberForEventType;
     LastProcessingStatus = lastProcessingStatus;
 }
        public HandlingEvent find(EventSequenceNumber eventSequenceNumber)
        {
            foreach(IEnumerable<HandlingEvent> handlingEvents in eventMap.Values)
            {
                foreach(HandlingEvent handlingEvent in handlingEvents)
                {
                    if(handlingEvent.SequenceNumber.sameValueAs(eventSequenceNumber))
                    {
                        return handlingEvent;
                    }
                }
            }

            return null;
        }
        public HandlingEvent find(EventSequenceNumber eventSequenceNumber)
        {
            foreach (IEnumerable <HandlingEvent> handlingEvents in eventMap.Values)
            {
                foreach (HandlingEvent handlingEvent in handlingEvents)
                {
                    if (handlingEvent.SequenceNumber.sameValueAs(eventSequenceNumber))
                    {
                        return(handlingEvent);
                    }
                }
            }

            return(null);
        }
Beispiel #10
0
        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);
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
 public void handlingEventNotFound()
 {
     cargoUpdater.updateCargo(EventSequenceNumber.ValueOf(999L));
     systemEvents.AssertWasNotCalled(se => se.notifyOfCargoUpdate(Arg <Cargo> .Is.TypeOf));
     systemEvents.AssertWasNotCalled(se => se.notifyOfHandlingEvent(Arg <HandlingEvent> .Is.TypeOf));
 }