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 }
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 registerHandlingEvent(DateTime completionTime, TrackingId trackingId, VoyageNumber voyageNumber, UnLocode unLocode, HandlingActivityType type, OperatorCode operatorCode) { // Using a factory to create a HandlingEvent (aggregate). This is where // it is determined wether the incoming data, the attempt, actually is capable // of representing a real handling handlingEvent. var handlingEvent = handlingEventFactory.createHandlingEvent( completionTime, trackingId, voyageNumber, unLocode, type, operatorCode ); // Store the new handling handlingEvent, which updates the persistent // state of the handling handlingEvent aggregate (but not the cargo aggregate - // that happens asynchronously!) handlingEventRepository.store(handlingEvent); // Publish a system event systemEvents.notifyOfHandlingEvent(handlingEvent); LOG.Info("Registered handling event: " + handlingEvent); }