<commit_before>package application

import (
	"time"

	"github.com/marcusolsson/goddd/domain/cargo"
	"github.com/marcusolsson/goddd/domain/location"
	"github.com/marcusolsson/goddd/domain/voyage"
	"github.com/marcusolsson/goddd/infrastructure"
	. "gopkg.in/check.v1"
)

type stubEventHandler struct {
	handledEvents []interface{}
}

func (h *stubEventHandler) CargoWasHandled(event cargo.HandlingEvent) {
	h.handledEvents = append(h.handledEvents, event)
}

func (h *stubEventHandler) CargoWasMisdirected(c cargo.Cargo) {
	h.handledEvents = append(h.handledEvents, c)
}

func (h *stubEventHandler) CargoHasArrived(c cargo.Cargo) {
	h.handledEvents = append(h.handledEvents, c)
}

func (s *S) TestRegisterHandlingEvent(c *C) {

	var (
		eventHandler            = &stubEventHandler{make([]interface{}, 0)}
		cargoRepository         = infrastructure.NewInMemCargoRepository()
		handlingEventRepository = infrastructure.NewInMemHandlingEventRepository()
		handlingEventFactory    = cargo.HandlingEventFactory{
			CargoRepository: cargoRepository,
		}
	)

	var service HandlingEventService = &handlingEventService{
		handlingEventRepository: handlingEventRepository,
		handlingEventFactory:    handlingEventFactory,
		eventHandler:            eventHandler,
	}

	var (
		completionTime = time.Date(2015, time.November, 10, 23, 0, 0, 0, time.UTC)
		trackingId     = cargo.TrackingId("ABC123")
		voyageNumber   = voyage.VoyageNumber("CM001")
		unLocode       = location.Stockholm.UNLocode
		eventType      = cargo.Load
	)

	service.RegisterHandlingEvent(completionTime, trackingId, voyageNumber, unLocode, eventType)

	c.Check(len(eventHandler.handledEvents), Equals, 1)
}<commit_msg>Fix failing test.<commit_after>package application

import (
	"time"

	"github.com/marcusolsson/goddd/domain/cargo"
	"github.com/marcusolsson/goddd/domain/location"
	"github.com/marcusolsson/goddd/domain/voyage"
	"github.com/marcusolsson/goddd/infrastructure"
	. "gopkg.in/check.v1"
)

type stubEventHandler struct {
	handledEvents []interface{}
}

func (h *stubEventHandler) CargoWasHandled(event cargo.HandlingEvent) {
	h.handledEvents = append(h.handledEvents, event)
}

func (h *stubEventHandler) CargoWasMisdirected(c cargo.Cargo) {
	h.handledEvents = append(h.handledEvents, c)
}

func (h *stubEventHandler) CargoHasArrived(c cargo.Cargo) {
	h.handledEvents = append(h.handledEvents, c)
}

func (s *S) TestRegisterHandlingEvent(c *C) {

	var (
		eventHandler            = &stubEventHandler{make([]interface{}, 0)}
		cargoRepository         = infrastructure.NewInMemCargoRepository()
		handlingEventRepository = infrastructure.NewInMemHandlingEventRepository()
		handlingEventFactory    = cargo.HandlingEventFactory{
			CargoRepository: cargoRepository,
		}
	)

	var service HandlingEventService = &handlingEventService{
		handlingEventRepository: handlingEventRepository,
		handlingEventFactory:    handlingEventFactory,
		eventHandler:            eventHandler,
	}

	var (
		completionTime = time.Date(2015, time.November, 10, 23, 0, 0, 0, time.UTC)
		trackingId     = cargo.TrackingId("ABC123")
		voyageNumber   = voyage.VoyageNumber("CM001")
		unLocode       = location.Stockholm.UNLocode
		eventType      = cargo.Load
	)

	cargoRepository.Store(*cargo.NewCargo(trackingId, cargo.RouteSpecification{}))

	err := service.RegisterHandlingEvent(completionTime, trackingId, voyageNumber, unLocode, eventType)

	c.Check(err, IsNil)
	c.Check(len(eventHandler.handledEvents), Equals, 1)
}
{'fraction_non_alphanumeric': 0.10909090909090909, 'fraction_numerical': 0.011544011544011544, 'mean_word_length': 5.006932409012132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2617236', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1157, 'n_words': 189}