 
     operation = {kind: "TEST"}
     messageJson = JSON.stringify(operation)
-    @journal.expects('record').once().withArgs(messageJson).returns(deferred.promise)
-    @replication.expects('send').once().withArgs(messageJson).returns(deferred.promise)
-    @engine.expects('execute_operation').once().withArgs(operation).returns("success")
+    @_journal.expects('record').once().withArgs(messageJson).returns(deferred.promise)
+    @_replication.expects('send').once().withArgs(messageJson).returns(deferred.promise)
+    @_engine.expects('execute_operation').once().withArgs(operation).returns("success")
 
     onComplete = (result) ->
       result.should.equal "success"

    deferred = Q.defer()
    deferred.resolve(undefined)

    @journal.expects('record').once().returns(deferred.promise)
    @replication.expects('send').once().returns(deferred.promise)
    @engine.expects('execute_operation').once().throws("failure")

    onError = (error) ->
      error.name.should.equal "failure"

kTestFilename = 'test.log'

describe 'ProcessingChainEntrance', ->
  setup_mocking()

  beforeEach (done) ->
    @journal = new Journal(kTestFilename)
    @replication = {start: (->), send: (->)}
    @engine = new TradeEngine()

    @mockify 'journal'
    @mockify 'replication'
    @mockify 'engine'

    @pce = new ProcessingChainEntrance(@engine, @journal, @replication)
    done()

  it 'should intialize the transaction log and replication when starting', (done) ->
    @_journal.expects('start').once().returns(then: ->)
    @_replication.expects('start').once().returns(then: ->)

    @pce.start()
    done()
