     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")
+    @_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', ->
  beforeEach (done) ->
    @journal = sinon.mock(new Journal(kTestFilename))
    @replication = sinon.mock({start: (->), send: (->)})
    @engine = sinon.mock(new TradeEngine())
    @pce = new ProcessingChainEntrance(@engine.object, @journal.object, @replication.object)
    done()

  afterEach (done) ->
    @journal.verify()
    @replication.verify()
    @engine.verify()
    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()


    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")

    onComplete = (result) ->
      result.should.equal "success"
