 
       # The mock objects.
       mock =
+        protocol:
+          scan:
+            _id: 'sp1'
+            scan_type: 'T1'
+            orientation: 'axial'
+          registration:
+            _id: 'rp1'
+            technique: 'ANTS'
+          modeling:
+            _id: 'mp1'
+            technique: 'Tofts'
         subject:
-          _id: 'a'
+          _id: 's1'
           project: 'QIN_Test'
           collection: 'Breast'
           number: 1
           birth_date: moment('August 21, 1986').valueOf()
-          scan_sets:
-            t1:
-              registration:
-                reg_01:
-                  modeling:
-                    pk_01:
-                      results: [
-                        delta_k_trans:
-                          average: 2.3
-                      ]
-                reg_02:
-                  modeling:
-                    pk_02:
-                      results: [
-                        delta_k_trans:
-                          average: 2.1
-                      ]
-              modeling:
-                pk_03:
-                  results: [
+          sessions: [
+            {
+              number: 1
+              acquisition_date: moment('July 1, 2013').valueOf()
+              detail: 'sd1'
+              modeling: [
+                {
+                  resource: 'pk_01'
+                  protocol: 'mp1'
+                  source:
+                    registration: 'rp1'
+                  result:
                     delta_k_trans:
-                      average: 2.6
-                  ]
-          sessions: [
-            number: 1
-            acquisition_date: moment('July 1, 2013').valueOf()
-            detail: 'b'
+                      average: 2.3
+                }
+              ]
+            }
           ]
           encounters: [
             _cls: 'Biopsy'

          # Confirm that a subject was fetched.
          it 'should fetch the subject', ->
            expect(subject, "Subject was not fetched").to.exist

          # Validate the birth date.
          it 'should anonymize the subject birth date', ->
            expect(subject.birthDate, "Subject is missing a birth date").to.exist
            expect(subject.birthDate.valueOf(), "Subject birth date is incorrect")
              .to.equal(moment('July 7, 1986').valueOf())
        
          # Validate the encounters.
          it 'should set the subject encounters', ->
            expect(subject.encounters, "Subject is missing encounters").to.exist
            expect(subject.encounters.length, "Subject encounters length is" +
                                              " incorrect").to.equal(1)
            enc = subject.encounters[0]
            expect(enc._cls, "Encounter type is incorrect")
              .to.equal(mock.subject.encounters[0]._cls)
        
          # Validate the treatments.
          it 'should extend the subject treatments', ->
            expect(subject.treatments, "Subject is missing treatments").to.exist
            expect(subject.treatments.length, "Subject encounters length is" +
                                              " incorrect").to.equal(1)
            trt = subject.treatments[0]
            expect(trt.treatmentType, "Treatment type is missing").to.exist
            expect(trt.treatmentType, "Treatment type is incorrect")
              .to.equal(mock.subject.treatments[0].treatment_type)
            expect(trt.begin_date.valueOf(), "Treatment begin date is incorrect")
              .to.equal(mock.subject.treatments[0].begin_date)
        
          # Validate the modeling.  
          it 'should set the subject modeling', ->
            expect(subject.modeling, "Subject is missing modeling").to.exist
          
            # There are two registration modeling objects.
            regMdl = subject.modeling.registration
            expect(regMdl, "The subject modeling registration is missing")
              .to.exist
            expect(regMdl.length, "The subject modeling registration count" +
                                  " is incorrect").to.equal(2)
          
            # There is one scan modeling objects.
            scanMdl = subject.modeling.scan
            expect(scanMdl, "The subject modeling scan is missing").to.exist
            expect(scanMdl.length, "The subject modeling registration count" +
                                   " is incorrect").to.equal(1)
          
            # The scan modeling is for the T1 scan.
            mdl = subject.modeling.scan[0]
            expect(mdl.key, "Modeling is missing a key").to.exist
            expect(mdl.source, "Modeling is missing a source").to.exist
            expect(mdl.source.scanType, "The scan modeling source is missing" +
                                        " the scan type").to.exist
            expect(mdl.source.scanType, "Modeling source scan type is incorrect")
              .to.equal('t1')
            mockMdl = mock.subject.scan_sets.t1.modeling.pk_03
            expect(mdl.results, "Modeling is missing results").to.exist
            expect(mdl.results.length, "Modeling results count is incorrect")
              .to.equal(1)
            mdlResult = mdl.results[0]
            expect(mdlResult.deltaKTrans, "Modeling results is missing" +
                                          " deltaKTrans").to.exist
            expect(mdlResult.deltaKTrans.average, "Modeling deltaKTrans is" +
                                                  " incorrect")
              .to.equal(mockMdl.results[0].delta_k_trans.average)
          
            # The modeling result object refers to its respective session.
            expect(mdlResult.session, "Modeling results is missing session")
              .to.exist
            expect(mdlResult.session, "Modeling results session is incorrect")
              .to.equal(subject.sessions[0])
        
          # Validate the sessions (without detail).
          it 'should reflect the subject sessions', ->
            expect(subject.sessions, "Subject is missing sessions").to.exist
            expect(subject.sessions.length, "Subject sessions length is" +
                                            " incorrect").to.equal(1)
            expect(subject.isMultiSession, "Subject multi-session flag is" +
                                           " incorrect").to.be.false

          # describe 'Session', ->
          #   mockSession = null

            $httpBackend.whenGET(url).respond(JSON.stringify(_items: [mock.subject]))

            # The mock subject http call.
            url = encodeURI('/api/subject/s1')
            $httpBackend.whenGET(url).respond(JSON.stringify(mock.subject))

            # The mock session-detail http call.
            url = encodeURI('/api/session-detail/sd1')
            $httpBackend.whenGET(url).respond(JSON.stringify(mock.session_detail))

            # The mock scan protocol http call.
            url = encodeURI('/api/scan-protocol/sp1')
            $httpBackend.whenGET(url).respond(JSON.stringify(mock.scan_protocol))

            # The mock registration protocol http call.
            url = encodeURI('/api/registration-protocol/rp1')
            $httpBackend.whenGET(url).respond(JSON.stringify(mock.registration_protocol))

            # The mock modeling protocol http call.
            url = encodeURI('/api/modeling-protocol/mp1')
            $httpBackend.whenGET(url).respond(JSON.stringify(mock.modeling_protocol))
        ]

      afterEach ->
