896. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/3/2017 11:16:04 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

896.1 Files compared

# Location File Last Modified
1 ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\subsystems\vista vista-client-spec.js Mon Jul 10 17:46:22 2017 UTC
2 ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\subsystems\vista vista-client-spec.js Tue Oct 3 13:22:36 2017 UTC

896.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 3312
Changed 2 16
Inserted 0 0
Removed 0 0

896.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

896.4 Active regular expressions

No regular expressions were active.

896.5 Comparison detail

  1   'use stric t';
  2  
  3   //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -
  4   // This te sts the vi sta-subscr ibe.js mod ule.
  5   //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -
  6   require('. ./../../.. /env-setup ');
  7   var _ = re quire('und erscore');
  8   var VistaC lient = re quire(glob al.VX_SUBS YSTEMS + ' vista/vist a-client') ;
  9   var log =  require(gl obal.VX_DU MMIES + 'd ummy-logge r');
  10   var DummyR pcClient =  require(g lobal.VX_D UMMIES + ' /dummy-Rpc Client').R pcClient;
  11  
  12   var hmpSer ver = 'The HmpServer' ;
  13  
  14   var config  = {
  15       'vista Sites': {
  16           '9 E7A': {
  17                'name':  'panorama' ,
  18                  'host': ' IP          ',
  19                  'port':  PORT ,
  20                  'accessCod e': ' REDACT ',
  21                  'verifyCod e': ' REDACTED ',
  22                'localIP ': '127.0. 0.1',
  23                'localAd dress': 'l ocalhost',
  24                'connect Timeout':  3000,
  25                'sendTim eout': 100 00
  26           },
  27           'C 877': {
  28                'name':  'kodak',
  29                  'host': ' IP          ',
  30                  'port':  PORT ,
  31                  'accessCod e': ' REDACT ',
  32                  'verifyCod e': ' REDACTED ',
  33                'localIP ': '127.0. 0.1',
  34                'localAd dress': 'l ocalhost',
  35                'connect Timeout':  3000,
  36                'sendTim eout': 100 00
  37           }
  38       },
  39       'hmp.s erver.id':  hmpServer ,
  40       'hmp.v ersion': ' 0.7-S65',
  41       'hmp.b atch.size' : '1000',
  42       'hmp.e xtract.sch ema': '3.0 01'
  43   };
  44  
  45  
  46   //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
  47   // Create  an instanc e of the V ista Clien t and incl ude a "fak e" replace ement on t he rpcClie nt so that
  48   // the uni t tests ca n test dif ferent res ponses fro m VistA an d their be haviors.
  49   //
  50   // config:  The confi g file to  be used.
  51   // returnR pcClient:  True if th e _getRpcC lient is t o return t he rpcClie nt - false  if it is  not suppos ed to.
  52   // returns : The vist aClient th at was cre ated.
  53   //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
  54   function c reateVista Client(con fig, retur nRpcClient ) {
  55       var vi staClient  = new Vist aClient(lo g, log, co nfig, Dumm yRpcClient );
  56  
  57       // Sin ce VistaCl ient uses  a shared m odule leve l variable  for RPC c lient - if  we use
  58       // tha t client,  we will en d up with  race condi tions betw een tests.   So we ne ed
  59       // our  own.
  60       //---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------
  61       var rp cClient =  new DummyR pcClient(l og, config );
  62       spyOn( rpcClient,  'execute' ).andCallT hrough();
  63       spyOn( vistaClien t, '_getRp cClient'). andCallFak e(function  () {
  64           if  (returnRp cClient) {
  65                return r pcClient;
  66           }  else {
  67                return n ull;
  68           }
  69       });
  70       return  vistaClie nt;
  71   }
  72  
  73  
  74   describe(' vista-clie nt.js', fu nction ()  {
  75       descri be('_extra ctTotalIte msFromRawR esponse',  function ( ) {
  76           it ('Verify a  null rawR esponse re turns null ', functio n () {
  77                var vist aClient =  new VistaC lient(log,  log, conf ig, DummyR pcClient);
  78                var tota lItems = v istaClient ._extractT otalItemsF romRawResp onse(null) ;
  79                expect(t otalItems) .toBeNull( );
  80           }) ;
  81           it ('Verify a n undefine d rawRespo nse return s null', f unction ()  {
  82                var vist aClient =  new VistaC lient(log,  log, conf ig, DummyR pcClient);
  83                var tota lItems = v istaClient ._extractT otalItemsF romRawResp onse(undef ined);
  84                expect(t otalItems) .toBeNull( );
  85           }) ;
  86           it ('Verify a n object r awResponse  returns n ull', func tion () {
  87                var vist aClient =  new VistaC lient(log,  log, conf ig, DummyR pcClient);
  88                var tota lItems = v istaClient ._extractT otalItemsF romRawResp onse({});
  89                expect(t otalItems) .toBeNull( );
  90           }) ;
  91           it ('Verify a n empty st ring rawRe sponse ret urns null' , function  () {
  92                var vist aClient =  new VistaC lient(log,  log, conf ig, DummyR pcClient);
  93                var tota lItems = v istaClient ._extractT otalItemsF romRawResp onse('');
  94                expect(t otalItems) .toBeNull( );
  95           }) ;
  96           it ('Verify e xactly no  totalItems  item in t he "good"  JSON retur ns null',  function ( ) {
  97                var rawR esponse =  '{' +
  98                    '"ap iVersion":  1.03,' +
  99                    '"pa rams": {'  +
  100                    '"do main": "Vi stA domain  name",' +
  101                    '"sy stemId": " VistA Site  Hash"' +
  102                    '},'  +
  103                    '"da ta": {' +
  104                    '"up dated": "2 0161222091 413",' +
  105                    '"la stUpdate":  "3161217- 31888",' +
  106                    '"al locationTo ken": "316 1217-1",'  +
  107                    '"wa itingPids" : [],' +
  108                    '"pr ocessingPi ds": [],'  +
  109                    '"re mainingObj ects": 250 0,' +
  110                    '"it ems": []'  +
  111                    '}'  +
  112                    '}';
  113                var vist aClient =  new VistaC lient(log,  log, conf ig, DummyR pcClient);
  114                var tota lItems = v istaClient ._extractT otalItemsF romRawResp onse(rawRe sponse);
  115                expect(t otalItems) .toBeNull( );
  116           }) ;
  117           it ('Verify e xactly one  totalItem s item in  the "good"  JSON and  it is nume ric', func tion () {
  118                var rawR esponse =  '{' +
  119                    '"ap iVersion":  1.03,' +
  120                    '"pa rams": {'  +
  121                    '"do main": "Vi stA domain  name",' +
  122                    '"sy stemId": " VistA Site  Hash"' +
  123                    '},'  +
  124                    '"da ta": {' +
  125                    '"up dated": "2 0161222091 413",' +
  126                    '"to talItems":  500,' +
  127                    '"la stUpdate":  "3161217- 31888",' +
  128                    '"al locationTo ken": "316 1217-1",'  +
  129                    '"wa itingPids" : [],' +
  130                    '"pr ocessingPi ds": [],'  +
  131                    '"re mainingObj ects": 250 0,' +
  132                    '"it ems": []'  +
  133                    '}'  +
  134                    '}';
  135                var vist aClient =  new VistaC lient(log,  log, conf ig, DummyR pcClient);
  136                var tota lItems = v istaClient ._extractT otalItemsF romRawResp onse(rawRe sponse);
  137                expect(t otalItems) .toBe(500) ;
  138           }) ;
  139           it ('Verify e xactly one  totalItem s item in  the "bad"  JSON and i t is numer ic', funct ion () {
  140                var rawR esponse =  '{' +
  141                    '"ap iVersion":  1.03,' +
  142                    '"pa rams": {'  +
  143                    '"do main": "Vi stA domain  name",' +
  144                    '"sy stemId": " VistA Site  Hash"' +
  145                    '},'  +
  146                    'som e bad stuf f to make  the JSON i ncorrectly  formatted ' +
  147                    '"da ta": {' +
  148                    '"up dated": "2 0161222091 413",' +
  149                    '"to talItems":  500,' +
  150                    '"la stUpdate":  "3161217- 31888",' +
  151                    '"al locationTo ken": "316 1217-1",'  +
  152                    '"wa itingPids" : [],' +
  153                    '"pr ocessingPi ds": [],'  +
  154                    '"re mainingObj ects": 250 0,' +
  155                    '"it ems": []'  +
  156                    '}'  +
  157                    '}';
  158                var vist aClient =  new VistaC lient(log,  log, conf ig, DummyR pcClient);
  159                var tota lItems = v istaClient ._extractT otalItemsF romRawResp onse(rawRe sponse);
  160                expect(t otalItems) .toBe(500) ;
  161           }) ;
  162           it ('Verify t otalItems  (numeric a s a string )  item in  the "good " JSON and  it is num eric', fun ction () {
  163                var rawR esponse =  '{' +
  164                    '"ap iVersion":  1.03,' +
  165                    '"pa rams": {'  +
  166                    '"do main": "Vi stA domain  name",' +
  167                    '"sy stemId": " VistA Site  Hash"' +
  168                    '},'  +
  169                    '"da ta": {' +
  170                    '"up dated": "2 0161222091 413",' +
  171                    '"to talItems":  "500",' +
  172                    '"la stUpdate":  "3161217- 31888",' +
  173                    '"al locationTo ken": "316 1217-1",'  +
  174                    '"wa itingPids" : [],' +
  175                    '"pr ocessingPi ds": [],'  +
  176                    '"re mainingObj ects": 250 0,' +
  177                    '"it ems": []'  +
  178                    '}'  +
  179                    '}';
  180                var vist aClient =  new VistaC lient(log,  log, conf ig, DummyR pcClient);
  181                var tota lItems = v istaClient ._extractT otalItemsF romRawResp onse(rawRe sponse);
  182                expect(t otalItems) .toBe(500) ;
  183           }) ;
  184           it ('Verify t otalItems  (text as a  string)   item in th e "good" J SON and re turns null ', functio n () {
  185                var rawR esponse =  '{' +
  186                    '"ap iVersion":  1.03,' +
  187                    '"pa rams": {'  +
  188                    '"do main": "Vi stA domain  name",' +
  189                    '"sy stemId": " VistA Site  Hash"' +
  190                    '},'  +
  191                    '"da ta": {' +
  192                    '"up dated": "2 0161222091 413",' +
  193                    '"to talItems":  "junk",'  +
  194                    '"la stUpdate":  "3161217- 31888",' +
  195                    '"al locationTo ken": "316 1217-1",'  +
  196                    '"wa itingPids" : [],' +
  197                    '"pr ocessingPi ds": [],'  +
  198                    '"re mainingObj ects": 250 0,' +
  199                    '"it ems": []'  +
  200                    '}'  +
  201                    '}';
  202                var vist aClient =  new VistaC lient(log,  log, conf ig, DummyR pcClient);
  203                var tota lItems = v istaClient ._extractT otalItemsF romRawResp onse(rawRe sponse);
  204                expect(t otalItems) .toBeNull( );
  205           }) ;
  206           it ('Verify m ultiple to talItems i tems in th e "bad" JS ON and it  returns th e first',  function ( ) {
  207                var rawR esponse =  '{' +
  208                    '"ap iVersion":  1.03,' +
  209                    '"pa rams": {'  +
  210                    '"do main": "Vi stA domain  name",' +
  211                    '"sy stemId": " VistA Site  Hash"' +
  212                    '},'  +
  213                    'som e bad stuf f to make  the JSON i ncorrectly  formatted ' +
  214                    '"da ta": {' +
  215                    '"up dated": "2 0161222091 413",' +
  216                    '"to talItems":  500,' +
  217                    '"la stUpdate":  "3161217- 31888",' +
  218                    '"al locationTo ken": "316 1217-1",'  +
  219                    '"wa itingPids" : [],' +
  220                    '"pr ocessingPi ds": [],'  +
  221                    '"re mainingObj ects": 250 0,' +
  222                    '"it ems": [{"t otalItems" : 300}, {" totalItems ": 200}]'  +
  223                    '}'  +
  224                    '}';
  225                var vist aClient =  new VistaC lient(log,  log, conf ig, DummyR pcClient);
  226                var tota lItems = v istaClient ._extractT otalItemsF romRawResp onse(rawRe sponse);
  227                expect(t otalItems) .toBe(500) ;
  228           }) ;
  229       });
  230       descri be('fetchN extBatchMu ltipleMode ', functio n () {
  231           it ('Verify s uccessful  fetch of f irst batch  message ( no allocat ion token) .', functi on () {
  232                var rawR esponse =  '{' +
  233                    '"ap iVersion":  1.03,' +
  234                    '"pa rams": {'  +
  235                    '"do main": "Vi stA domain  name",' +
  236                    '"sy stemId": " VistA Site  Hash"' +
  237                    '},'  +
  238                    '"da ta": {' +
  239                    '"up dated": "2 0161222091 413",' +
  240                    '"to talItems":  500,' +
  241                    '"la stUpdate":  "3161217- 31888",' +
  242                    '"al locationTo ken": "316 1217-1",'  +
  243                    '"wa itingPids" : [],' +
  244                    '"pr ocessingPi ds": [],'  +
  245                    '"re mainingObj ects": 250 0,' +
  246                    '"it ems": []'  +
  247                    '}'  +
  248                    '}';
  249                var vist aClient =  createVist aClient(co nfig, true );
  250                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  251                expect(r pcClient). not.toBeNu ll();
  252                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  253  
  254                var fini shed = fal se;
  255                var fetc hError;
  256                var fetc hWrappedRe sponse;
  257                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 1000,  function  (error, wr appedRespo nse) {
  258                    fetc hError = e rror;
  259                    fetc hWrappedRe sponse = w rappedResp onse;
  260                    fini shed = tru e;
  261                });
  262  
  263                waitsFor (function  () {
  264                    retu rn finishe d;
  265                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  266  
  267                runs(fun ction () {
  268                    expe ct(fetchEr ror).toBeN ull();
  269                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  270                         data: {
  271                             update d: '201612 22091413',
  272                             totalI tems: 500,
  273                             lastUp date: '316 1217-31888 ',
  274                             alloca tionToken:  '3161217- 1',
  275                             waitin gPids: [],
  276                             proces singPids:  [],
  277                             remain ingObjects : 2500,
  278                             items:  []
  279                         },
  280                         hmpBatchSi ze: 1000,
  281                         rawRespons e: null,
  282                         errorData:  null
  283                    }));
  284                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  285                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  286                         jasmine.ob jectContai ning({
  287                             '"serv er"': hmpS erver,
  288                             '"comm and"': 'ge tPtUpdates ',
  289                             '"getS tatus"': t rue,
  290                             '"allo cationSize "': '1000' ,
  291                             '"hmpV ersion"':  config['hm p.version' ],
  292                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  293                         }), jasmin e.any(Func tion));
  294                    expe ct(rpcClie nt.execute ).not.toHa veBeenCall edWith('HM PDJFS API' ,
  295                         jasmine.ob jectContai ning({
  296                             '"allo cationToke n"': jasmi ne.any(Str ing)
  297                         }), jasmin e.any(Func tion));
  298                    expe ct(rpcClie nt.execute ).not.toHa veBeenCall edWith('HM PDJFS API' ,
  299                         jasmine.ob jectContai ning({
  300                             '"allo cationStat us"': jasm ine.any(St ring)
  301                         }), jasmin e.any(Func tion));
  302                });
  303           }) ;
  304           it ('Verify s uccessful  fetch of f ollow-on b atch messa ge (has al location t oken).', f unction ()  {
  305                var rawR esponse =  '{' +
  306                    '"ap iVersion":  1.03,' +
  307                    '"pa rams": {'  +
  308                    '"do main": "Vi stA domain  name",' +
  309                    '"sy stemId": " VistA Site  Hash"' +
  310                    '},'  +
  311                    '"da ta": {' +
  312                    '"up dated": "2 0161222091 413",' +
  313                    '"to talItems":  500,' +
  314                    '"la stUpdate":  "3161217- 31888",' +
  315                    '"al locationTo ken": "316 1217-2",'  +
  316                    '"wa itingPids" : [],' +
  317                    '"pr ocessingPi ds": [],'  +
  318                    '"re mainingObj ects": 250 0,' +
  319                    '"it ems": []'  +
  320                    '}'  +
  321                    '}';
  322                var vist aClient =  createVist aClient(co nfig, true );
  323                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  324                expect(r pcClient). not.toBeNu ll();
  325                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  326  
  327                var fini shed = fal se;
  328                var fetc hError;
  329                var fetc hWrappedRe sponse;
  330                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' 3161217-1' , 'complet e', 1000,  function ( error, wra ppedRespon se) {
  331                    fetc hError = e rror;
  332                    fetc hWrappedRe sponse = w rappedResp onse;
  333                    fini shed = tru e;
  334                });
  335  
  336                waitsFor (function  () {
  337                    retu rn finishe d;
  338                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  339  
  340                runs(fun ction () {
  341                    expe ct(fetchEr ror).toBeN ull();
  342                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  343                         data: {
  344                             update d: '201612 22091413',
  345                             totalI tems: 500,
  346                             lastUp date: '316 1217-31888 ',
  347                             alloca tionToken:  '3161217- 2',
  348                             waitin gPids: [],
  349                             proces singPids:  [],
  350                             remain ingObjects : 2500,
  351                             items:  []
  352                         },
  353                         hmpBatchSi ze: 1000,
  354                         rawRespons e: null,
  355                         errorData:  null
  356                    }));
  357                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  358                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  359                         jasmine.ob jectContai ning({
  360                             '"serv er"': hmpS erver,
  361                             '"comm and"': 'ge tPtUpdates ',
  362                             '"getS tatus"': t rue,
  363                             '"allo cationSize "': '1000' ,
  364                             '"hmpV ersion"':  config['hm p.version' ],
  365                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ],
  366                             '"allo cationToke n"': '3161 217-1',
  367                             '"allo cationStat us"': 'com plete'
  368                         }), jasmin e.any(Func tion));
  369                });
  370           }) ;
  371           it ('Verify w hen fetch  of batch m essage giv es an RPC  error.', f unction ()  {
  372                var vist aClient =  createVist aClient(co nfig, true );
  373                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  374                expect(r pcClient). not.toBeNu ll();
  375                rpcClien t.setError AndRespons e('ErrorVa lue', 'Err orResponse ');
  376  
  377                var fini shed = fal se;
  378                var fetc hError;
  379                var fetc hWrappedRe sponse;
  380                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 1000,  function  (error, wr appedRespo nse) {
  381                    fetc hError = e rror;
  382                    fetc hWrappedRe sponse = w rappedResp onse;
  383                    fini shed = tru e;
  384                });
  385  
  386                waitsFor (function  () {
  387                    retu rn finishe d;
  388                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  389  
  390                runs(fun ction () {
  391                    expe ct(fetchEr ror).toBeT ruthy();
  392                    expe ct(fetchEr ror).toCon tain('Erro rValue');
  393                    expe ct(fetchEr ror).toCon tain('Erro r received  from RPC  call');
  394                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  395                         data: null ,
  396                         hmpBatchSi ze: 1000,
  397                         rawRespons e: 'ErrorR esponse',
  398                         errorData:  { message : vistaCli ent.ERROR_ LIST.RPC_E RROR }
  399                    }));
  400                });
  401           }) ;
  402           it ('Verify w hen fetch  of batch m essage giv es no erro r and also  no respon se.', func tion () {
  403                var vist aClient =  createVist aClient(co nfig, true );
  404                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  405                expect(r pcClient). not.toBeNu ll();
  406                rpcClien t.setError AndRespons e(null, nu ll);
  407  
  408                var fini shed = fal se;
  409                var fetc hError;
  410                var fetc hWrappedRe sponse;
  411                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 1000,  function  (error, wr appedRespo nse) {
  412                    fetc hError = e rror;
  413                    fetc hWrappedRe sponse = w rappedResp onse;
  414                    fini shed = tru e;
  415                });
  416  
  417                waitsFor (function  () {
  418                    retu rn finishe d;
  419                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  420  
  421                runs(fun ction () {
  422                    expe ct(fetchEr ror).toBeT ruthy();
  423                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  424                         data: null ,
  425                         hmpBatchSi ze: 1000,
  426                         rawRespons e: null,
  427                         errorData:  { message : vistaCli ent.ERROR_ LIST.RPC_E RROR }
  428                    }));
  429                });
  430           }) ;
  431           it ('Verify b ad JSON ha ndling is  correct.',  function  () {
  432                var rawR esponse =  '{' +
  433                    '"ap iVersion":  1.03,' +
  434                    '"pa rams": {'  +
  435                    '"do main": "Vi stA domain  name",' +
  436                    '"sy stemId": " VistA Site  Hash"' +
  437                    'mak e some bad  JSON stru cture with  this mess age.' +
  438                    '},'  +
  439                    '"da ta": {' +
  440                    '"up dated": "2 0161222091 413",' +
  441                    '"to talItems":  2,' +
  442                    '"la stUpdate":  "3161217- 31888",' +
  443                    '"al locationTo ken": "316 12171",' +
  444                    '"wa itingPids" : [],' +
  445                    '"pr ocessingPi ds": [],'  +
  446                    '"re mainingObj ects": 250 0,' +
  447                    '"it ems": []'  +
  448                    '}'  +
  449                    '}';
  450                var vist aClient =  createVist aClient(co nfig, true );
  451                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  452                expect(r pcClient). not.toBeNu ll();
  453                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  454  
  455                var fini shed = fal se;
  456                var fetc hError;
  457                var fetc hWrappedRe sponse;
  458                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 2, fu nction (er ror, wrapp edResponse ) {
  459                    fetc hError = e rror;
  460                    fetc hWrappedRe sponse = w rappedResp onse;
  461                    fini shed = tru e;
  462                });
  463  
  464                waitsFor (function  () {
  465                    retu rn finishe d;
  466                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  467  
  468                runs(fun ction () {
  469                    expe ct(fetchEr ror).toBeT ruthy();
  470                    expe ct(fetchEr ror).toCon tain('Fail ed to pars e');
  471                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  472                         data: null ,
  473                         hmpBatchSi ze: 1,
  474                         rawRespons e: rawResp onse,
  475                         errorData:  { message : vistaCli ent.ERROR_ LIST.INVAL ID_JSON_ER ROR }
  476  
  477                    }));
  478                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(2);
  479                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  480                         jasmine.ob jectContai ning({
  481                             '"serv er"': hmpS erver,
  482                             '"comm and"': 'ge tPtUpdates ',
  483                             '"getS tatus"': t rue,
  484                             '"allo cationSize "': '2',
  485                             '"hmpV ersion"':  config['hm p.version' ],
  486                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  487                         }), jasmin e.any(Func tion));
  488                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  489                         jasmine.ob jectContai ning({
  490                             '"serv er"': hmpS erver,
  491                             '"comm and"': 'ge tPtUpdates ',
  492                             '"getS tatus"': t rue,
  493                             '"allo cationSize "': '1',
  494                             '"allo cationToke n"': '3161 2171',
  495                             '"allo cationStat us"': 'red uce',
  496                             '"hmpV ersion"':  config['hm p.version' ],
  497                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  498                         }), jasmin e.any(Func tion));
  499                });
  500           }) ;
  501           it ('Verify b ad JSON ha ndling - w hen totalI tems retur ned in raw Response i s 1.', fun ction () {
  502                var rawR esponse =  '{' +
  503                    '"ap iVersion":  1.03,' +
  504                    '"pa rams": {'  +
  505                    '"do main": "Vi stA domain  name",' +
  506                    '"sy stemId": " VistA Site  Hash"' +
  507                    'mak e some bad  JSON stru cture with  this mess age.' +
  508                    '},'  +
  509                    '"da ta": {' +
  510                    '"up dated": "2 0161222091 413",' +
  511                    '"to talItems":  1,' +
  512                    '"la stUpdate":  "3161217- 31888",' +
  513                    '"al locationTo ken": "316 12171",' +
  514                    '"wa itingPids" : [],' +
  515                    '"pr ocessingPi ds": [],'  +
  516                    '"re mainingObj ects": 250 0,' +
  517                    '"it ems": []'  +
  518                    '}'  +
  519                    '}';
  520                var vist aClient =  createVist aClient(co nfig, true );
  521                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  522                expect(r pcClient). not.toBeNu ll();
  523                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  524  
  525                var fini shed = fal se;
  526                var fetc hError;
  527                var fetc hWrappedRe sponse;
  528                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 2, fu nction (er ror, wrapp edResponse ) {
  529                    fetc hError = e rror;
  530                    fetc hWrappedRe sponse = w rappedResp onse;
  531                    fini shed = tru e;
  532                });
  533  
  534                waitsFor (function  () {
  535                    retu rn finishe d;
  536                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  537  
  538                runs(fun ction () {
  539                    expe ct(fetchEr ror).toBeT ruthy();
  540                    expe ct(fetchEr ror).toCon tain('Fail ed to pars e');
  541                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  542                         data: null ,
  543                         hmpBatchSi ze: 1,
  544                         rawRespons e: rawResp onse,
  545                         errorData:  { message : vistaCli ent.ERROR_ LIST.INVAL ID_JSON_ER ROR }
  546  
  547                    }));
  548                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  549                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  550                         jasmine.ob jectContai ning({
  551                             '"serv er"': hmpS erver,
  552                             '"comm and"': 'ge tPtUpdates ',
  553                             '"getS tatus"': t rue,
  554                             '"allo cationSize "': '2',
  555                             '"hmpV ersion"':  config['hm p.version' ],
  556                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  557                         }), jasmin e.any(Func tion));
  558                });
  559           }) ;
  560           it ('Verify b ad JSON ha ndling whe n response  does not  have an al locationTo ken.', fun ction () {
  561                var rawR esponse =  '{' +
  562                    '"ap iVersion":  1.03,' +
  563                    '"pa rams": {'  +
  564                    '"do main": "Vi stA domain  name",' +
  565                    '"sy stemId": " VistA Site  Hash"' +
  566                    'mak e some bad  JSON stru cture with  this mess age.' +
  567                    '},'  +
  568                    '"da ta": {' +
  569                    '"up dated": "2 0161222091 413",' +
  570                    '"to talItems":  2,' +
  571                    '"la stUpdate":  "3161217- 31888",' +
  572                    '"wa itingPids" : [],' +
  573                    '"pr ocessingPi ds": [],'  +
  574                    '"re mainingObj ects": 250 0,' +
  575                    '"it ems": []'  +
  576                    '}'  +
  577                    '}';
  578                var vist aClient =  createVist aClient(co nfig, true );
  579                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  580                expect(r pcClient). not.toBeNu ll();
  581                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  582  
  583                var fini shed = fal se;
  584                var fetc hError;
  585                var fetc hWrappedRe sponse;
  586                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 2, fu nction (er ror, wrapp edResponse ) {
  587                    fetc hError = e rror;
  588                    fetc hWrappedRe sponse = w rappedResp onse;
  589                    fini shed = tru e;
  590                });
  591  
  592                waitsFor (function  () {
  593                    retu rn finishe d;
  594                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  595  
  596                runs(fun ction () {
  597                    expe ct(fetchEr ror).toBeT ruthy();
  598                    expe ct(fetchEr ror).toCon tain('Fail ed to pars e');
  599                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  600                         data: null ,
  601                         hmpBatchSi ze: 2,
  602                         rawRespons e: rawResp onse,
  603                         errorData:  { message : vistaCli ent.ERROR_ LIST.INVAL ID_JSON_ER ROR }
  604  
  605                    }));
  606                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  607                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  608                         jasmine.ob jectContai ning({
  609                             '"serv er"': hmpS erver,
  610                             '"comm and"': 'ge tPtUpdates ',
  611                             '"getS tatus"': t rue,
  612                             '"allo cationSize "': '2',
  613                             '"hmpV ersion"':  config['hm p.version' ],
  614                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  615                         }), jasmin e.any(Func tion));
  616                });
  617           }) ;
  618           it ('Verify r apid reduc tion algor ithm when  bad JSON h andling oc curs.', fu nction ()  {
  619                var rawR esponse =  '{' +
  620                    '"ap iVersion":  1.03,' +
  621                    '"pa rams": {'  +
  622                    '"do main": "Vi stA domain  name",' +
  623                    '"sy stemId": " VistA Site  Hash"' +
  624                    'mak e some bad  JSON stru cture with  this mess age.' +
  625                    '},'  +
  626                    '"da ta": {' +
  627                    '"up dated": "2 0161222091 413",' +
  628                    '"to talItems":  2,' +
  629                    '"la stUpdate":  "3161217- 31888",' +
  630                    '"al locationTo ken": "316 12171",' +
  631                    '"wa itingPids" : [],' +
  632                    '"pr ocessingPi ds": [],'  +
  633                    '"re mainingObj ects": 250 0,' +
  634                    '"it ems": []'  +
  635                    '}'  +
  636                    '}';
  637                var vist aClient =  createVist aClient(co nfig, true );
  638                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  639                expect(r pcClient). not.toBeNu ll();
  640                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  641  
  642                var fini shed = fal se;
  643                var fetc hError;
  644                var fetc hWrappedRe sponse;
  645                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 10, f unction (e rror, wrap pedRespons e) {
  646                    fetc hError = e rror;
  647                    fetc hWrappedRe sponse = w rappedResp onse;
  648                    fini shed = tru e;
  649                });
  650  
  651                waitsFor (function  () {
  652                    retu rn finishe d;
  653                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  654  
  655                runs(fun ction () {
  656                    expe ct(fetchEr ror).toBeT ruthy();
  657                    expe ct(fetchEr ror).toCon tain('Fail ed to pars e');
  658                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  659                         data: null ,
  660                         hmpBatchSi ze: 1,
  661                         rawRespons e: rawResp onse,
  662                         errorData:  { message : vistaCli ent.ERROR_ LIST.INVAL ID_JSON_ER ROR }
  663                    }));
  664                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(2);
  665                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  666                         jasmine.ob jectContai ning({
  667                             '"serv er"': hmpS erver,
  668                             '"comm and"': 'ge tPtUpdates ',
  669                             '"getS tatus"': t rue,
  670                             '"allo cationSize "': '10',
  671                             '"hmpV ersion"':  config['hm p.version' ],
  672                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  673                         }), jasmin e.any(Func tion));
  674                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  675                         jasmine.ob jectContai ning({
  676                             '"serv er"': hmpS erver,
  677                             '"comm and"': 'ge tPtUpdates ',
  678                             '"getS tatus"': t rue,
  679                             '"allo cationSize "': '1',
  680                             '"allo cationToke n"': '3161 2171',
  681                             '"allo cationStat us"': 'red uce',
  682                             '"hmpV ersion"':  config['hm p.version' ],
  683                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  684                         }), jasmin e.any(Func tion));
  685                });
  686           }) ;
  687           it ('Verify " staging no t complete " warning  from VistA .', functi on () {
  688                var rawR esponse =  '{' +
  689                    '"ap iVersion":  1.03,' +
  690                    '"pa rams": {'  +
  691                    '"do main": "Vi stA domain  name",' +
  692                    '"sy stemId": " VistA Site  Hash"' +
  693                    '},'  +
  694                    '"wa rning": "S taging is  not comple te yet!"'  +
  695                    '}';
  696                var vist aClient =  createVist aClient(co nfig, true );
  697                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  698                expect(r pcClient). not.toBeNu ll();
  699                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  700  
  701                var fini shed = fal se;
  702                var fetc hError;
  703                var fetc hWrappedRe sponse;
  704                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 1000,  function  (error, wr appedRespo nse) {
  705                    fetc hError = e rror;
  706                    fetc hWrappedRe sponse = w rappedResp onse;
  707                    fini shed = tru e;
  708                });
  709  
  710                waitsFor (function  () {
  711                    retu rn finishe d;
  712                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  713  
  714                runs(fun ction () {
  715                    expe ct(fetchEr ror).toBeN ull();
  716                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  717                         data: unde fined,
  718                         hmpBatchSi ze: 1000,
  719                         rawRespons e: null,
  720                         errorData:  null
  721                    }));
  722                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  723                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  724                         jasmine.ob jectContai ning({
  725                             '"serv er"': hmpS erver,
  726                             '"comm and"': 'ge tPtUpdates ',
  727                             '"getS tatus"': t rue,
  728                             '"allo cationSize "': '1000' ,
  729                             '"hmpV ersion"':  config['hm p.version' ],
  730                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  731                         }), jasmin e.any(Func tion));
  732                });
  733           }) ;
  734           it ('Verify w hen valid  response h as no "dat a" node',  function ( ) {
  735                var rawR esponse =  '{' +
  736                    '"ap iVersion":  1.03,' +
  737                    '"pa rams": {'  +
  738                    '"do main": "Vi stA domain  name",' +
  739                    '"sy stemId": " VistA Site  Hash"' +
  740                    '}'  +
  741                    '}';
  742                var vist aClient =  createVist aClient(co nfig, true );
  743                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  744                expect(r pcClient). not.toBeNu ll();
  745                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  746  
  747                var fini shed = fal se;
  748                var fetc hError;
  749                var fetc hWrappedRe sponse;
  750                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 1000,  function  (error, wr appedRespo nse) {
  751                    fetc hError = e rror;
  752                    fetc hWrappedRe sponse = w rappedResp onse;
  753                    fini shed = tru e;
  754                });
  755  
  756                waitsFor (function  () {
  757                    retu rn finishe d;
  758                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  759  
  760                runs(fun ction () {
  761                    expe ct(fetchEr ror).toBeT ruthy();
  762                    expe ct(fetchEr ror).toCon tain('json Response d id not con tain any d ata attrib ute');
  763                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  764                         data: null ,
  765                         hmpBatchSi ze: 1000,
  766                         rawRespons e: null,
  767                         errorData:  null
  768                    }));
  769                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  770                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  771                         jasmine.ob jectContai ning({
  772                             '"serv er"': hmpS erver,
  773                             '"comm and"': 'ge tPtUpdates ',
  774                             '"getS tatus"': t rue,
  775                             '"allo cationSize "': '1000' ,
  776                             '"hmpV ersion"':  config['hm p.version' ],
  777                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  778                         }), jasmin e.any(Func tion));
  779                });
  780           }) ;
  781           it ('Verify w hen valid  response h as root le vel error  node', fun ction () {
  782                var rawR esponse =  '{' +
  783                    '"ap iVersion":  1.03,' +
  784                    '"pa rams": {'  +
  785                    '"do main": "Vi stA domain  name",' +
  786                    '"sy stemId": " VistA Site  Hash"' +
  787                    '},'  +
  788                    '"er ror": {' +
  789                    '"me ssage": "S ome error  occurred." ' +
  790                    '}'  +
  791                    '}';
  792                var vist aClient =  createVist aClient(co nfig, true );
  793                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  794                expect(r pcClient). not.toBeNu ll();
  795                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  796  
  797                var fini shed = fal se;
  798                var fetc hError;
  799                var fetc hWrappedRe sponse;
  800                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 1000,  function  (error, wr appedRespo nse) {
  801                    fetc hError = e rror;
  802                    fetc hWrappedRe sponse = w rappedResp onse;
  803                    fini shed = tru e;
  804                });
  805  
  806                waitsFor (function  () {
  807                    retu rn finishe d;
  808                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  809  
  810                runs(fun ction () {
  811                    expe ct(fetchEr ror).toBeT ruthy();
  812                    expe ct(fetchEr ror).toCon tain('Vist a returned  an error  condition. ');
  813                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  814                         data: null ,
  815                         hmpBatchSi ze: 1000,
  816                         rawRespons e: null,
  817                         errorData:  { message : 'Some er ror occurr ed.'}
  818                    }));
  819                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  820                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  821                         jasmine.ob jectContai ning({
  822                             '"serv er"': hmpS erver,
  823                             '"comm and"': 'ge tPtUpdates ',
  824                             '"getS tatus"': t rue,
  825                             '"allo cationSize "': '1000' ,
  826                             '"hmpV ersion"':  config['hm p.version' ],
  827                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  828                         }), jasmin e.any(Func tion));
  829                });
  830           }) ;
  831           it ('Verify w hen valid  response h as batch l evel error  under the  data node ', functio n () {
  832                var rawR esponse =  '{' +
  833                    '"ap iVersion":  1.03,' +
  834                    '"pa rams": {'  +
  835                    '"do main": "Vi stA domain  name",' +
  836                    '"sy stemId": " VistA Site  Hash"' +
  837                    '},'  +
  838                    '"da ta": {' +
  839                    '"er ror": {' +
  840                    '"me ssage": "S ome error  occurred." ' +
  841                    '}'  +
  842                    '}'  +
  843                    '}';
  844                var vist aClient =  createVist aClient(co nfig, true );
  845                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  846                expect(r pcClient). not.toBeNu ll();
  847                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  848  
  849                var fini shed = fal se;
  850                var fetc hError;
  851                var fetc hWrappedRe sponse;
  852                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 1000,  function  (error, wr appedRespo nse) {
  853                    fetc hError = e rror;
  854                    fetc hWrappedRe sponse = w rappedResp onse;
  855                    fini shed = tru e;
  856                });
  857  
  858                waitsFor (function  () {
  859                    retu rn finishe d;
  860                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  861  
  862                runs(fun ction () {
  863                    expe ct(fetchEr ror).toBeT ruthy();
  864                    expe ct(fetchEr ror).toCon tain('Vist a returned  a batch l evel error  condition .');
  865                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  866                         data: null ,
  867                         hmpBatchSi ze: 1000,
  868                         rawRespons e: null,
  869                         errorData:  { message : 'Some er ror occurr ed.'}
  870                    }));
  871                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  872                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  873                         jasmine.ob jectContai ning({
  874                             '"serv er"': hmpS erver,
  875                             '"comm and"': 'ge tPtUpdates ',
  876                             '"getS tatus"': t rue,
  877                             '"allo cationSize "': '1000' ,
  878                             '"hmpV ersion"':  config['hm p.version' ],
  879                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  880                         }), jasmin e.any(Func tion));
  881                });
  882           }) ;
  883           it ('Verify w hen have i nvalid con figuration ', functio n () {
  884                var loca lConfig =  JSON.parse (JSON.stri ngify(conf ig));
  885                delete l ocalConfig .vistaSite s['9E7A'];
  886                delete l ocalConfig .vistaSite s['C877'];
  887                var vist aClient =  createVist aClient(lo calConfig,  false);
  888  
  889                var fini shed = fal se;
  890                var fetc hError;
  891                var fetc hWrappedRe sponse;
  892                vistaCli ent.fetchN extBatchMu ltipleMode ('9E7A', ' ', 'comple te', 1000,  function  (error, wr appedRespo nse) {
  893                    fetc hError = e rror;
  894                    fetc hWrappedRe sponse = w rappedResp onse;
  895                    fini shed = tru e;
  896                });
  897  
  898                waitsFor (function  () {
  899                    retu rn finishe d;
  900                }, 'Call  to fetchN extBatchMu ltipleMode  failed to  return in  time.', 1 000);
  901  
  902                runs(fun ction () {
  903                    expe ct(fetchEr ror).toBeT ruthy();
  904                    expe ct(fetchEr ror).toCon tain('Fail ed to call  RPC getPt Updates fo r vistaId' );
  905                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  906                         data: null ,
  907                         hmpBatchSi ze: 1000,
  908                         rawRespons e: null,
  909                         errorData:  { message : vistaCli ent.ERROR_ LIST.INVAL ID_CONFIGU RATION_ERR OR}
  910                    }));
  911                });
  912           }) ;
  913  
  914       });
  915  
  916       descri be('fetchN extBatch',  function  () {
  917           it ('Verify s uccessful  fetch of f irst batch  message ( no lastUpd ate value) .', functi on () {
  918                var rawR esponse =  '{' +
  919                    '"ap iVersion":  1.03,' +
  920                    '"pa rams": {'  +
  921                    '"do main": "Vi stA domain  name",' +
  922                    '"sy stemId": " VistA Site  Hash"' +
  923                    '},'  +
  924                    '"da ta": {' +
  925                    '"up dated": "2 0161222091 413",' +
  926                    '"to talItems":  500,' +
  927                    '"la stUpdate":  "3161217- 31888",' +
  928                    '"wa itingPids" : [],' +
  929                    '"pr ocessingPi ds": [],'  +
  930                    '"re mainingObj ects": 250 0,' +
  931                    '"it ems": []'  +
  932                    '}'  +
  933                    '}';
  934                var vist aClient =  createVist aClient(co nfig, true );
  935                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  936                expect(r pcClient). not.toBeNu ll();
  937                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  938  
  939                var fini shed = fal se;
  940                var fetc hError;
  941                var fetc hWrappedRe sponse;
  942                vistaCli ent.fetchN extBatch(' 9E7A', '',  1000, fun ction (err or, wrappe dResponse)  {
  943                    fetc hError = e rror;
  944                    fetc hWrappedRe sponse = w rappedResp onse;
  945                    fini shed = tru e;
  946                });
  947  
  948                waitsFor (function  () {
  949                    retu rn finishe d;
  950                }, 'Call  to fetchN extBatch f ailed to r eturn in t ime.', 100 0);
  951  
  952                runs(fun ction () {
  953                    expe ct(fetchEr ror).toBeN ull();
  954                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  955                         data: {
  956                             update d: '201612 22091413',
  957                             totalI tems: 500,
  958                             lastUp date: '316 1217-31888 ',
  959                             waitin gPids: [],
  960                             proces singPids:  [],
  961                             remain ingObjects : 2500,
  962                             items:  []
  963                         },
  964                         hmpBatchSi ze: 1000,
  965                         rawRespons e: null,
  966                         errorData:  null
  967                    }));
  968                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  969                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  970                         jasmine.ob jectContai ning({
  971                             '"serv er"': hmpS erver,
  972                             '"comm and"': 'ge tPtUpdates ',
  973                             '"last Update"':  '',
  974                             '"getS tatus"': t rue,
  975                             '"max" ': '1000',
  976                             '"hmpV ersion"':  config['hm p.version' ],
  977                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  978                         }), jasmin e.any(Func tion));
  979                });
  980           }) ;
  981           it ('Verify s uccessful  fetch of f ollow-on b atch messa ge (has al location t oken).', f unction ()  {
  982                var rawR esponse =  '{' +
  983                    '"ap iVersion":  1.03,' +
  984                    '"pa rams": {'  +
  985                    '"do main": "Vi stA domain  name",' +
  986                    '"sy stemId": " VistA Site  Hash"' +
  987                    '},'  +
  988                    '"da ta": {' +
  989                    '"up dated": "2 0161222091 413",' +
  990                    '"to talItems":  500,' +
  991                    '"la stUpdate":  "3161217- 31888",' +
  992                    '"wa itingPids" : [],' +
  993                    '"pr ocessingPi ds": [],'  +
  994                    '"re mainingObj ects": 250 0,' +
  995                    '"it ems": []'  +
  996                    '}'  +
  997                    '}';
  998                var vist aClient =  createVist aClient(co nfig, true );
  999                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1000                expect(r pcClient). not.toBeNu ll();
  1001                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  1002  
  1003                var fini shed = fal se;
  1004                var fetc hError;
  1005                var fetc hWrappedRe sponse;
  1006                vistaCli ent.fetchN extBatch(' 9E7A', '31 61217-3138 8', 1000,  function ( error, wra ppedRespon se) {
  1007                    fetc hError = e rror;
  1008                    fetc hWrappedRe sponse = w rappedResp onse;
  1009                    fini shed = tru e;
  1010                });
  1011  
  1012                waitsFor (function  () {
  1013                    retu rn finishe d;
  1014                }, 'Call  to fetchN extBatch f ailed to r eturn in t ime.', 100 0);
  1015  
  1016                runs(fun ction () {
  1017                    expe ct(fetchEr ror).toBeN ull();
  1018                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  1019                         data: {
  1020                             update d: '201612 22091413',
  1021                             totalI tems: 500,
  1022                             lastUp date: '316 1217-31888 ',
  1023                             waitin gPids: [],
  1024                             proces singPids:  [],
  1025                             remain ingObjects : 2500,
  1026                             items:  []
  1027                         },
  1028                         hmpBatchSi ze: 1000,
  1029                         rawRespons e: null,
  1030                         errorData:  null
  1031                    }));
  1032                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  1033                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1034                         jasmine.ob jectContai ning({
  1035                             '"serv er"': hmpS erver,
  1036                             '"comm and"': 'ge tPtUpdates ',
  1037                             '"last Update"':  '3161217-3 1388',
  1038                             '"getS tatus"': t rue,
  1039                             '"max" ': '1000',
  1040                             '"hmpV ersion"':  config['hm p.version' ],
  1041                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  1042                         }), jasmin e.any(Func tion));
  1043                });
  1044           }) ;
  1045           it ('Verify w hen fetch  of batch m essage giv es an RPC  error.', f unction ()  {
  1046                var vist aClient =  createVist aClient(co nfig, true );
  1047                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1048                expect(r pcClient). not.toBeNu ll();
  1049                rpcClien t.setError AndRespons e('ErrorVa lue', 'Err orResponse ');
  1050  
  1051                var fini shed = fal se;
  1052                var fetc hError;
  1053                var fetc hWrappedRe sponse;
  1054                vistaCli ent.fetchN extBatch(' 9E7A', '',  1000, fun ction (err or, wrappe dResponse)  {
  1055                    fetc hError = e rror;
  1056                    fetc hWrappedRe sponse = w rappedResp onse;
  1057                    fini shed = tru e;
  1058                });
  1059  
  1060                waitsFor (function  () {
  1061                    retu rn finishe d;
  1062                }, 'Call  to fetchN extBatch f ailed to r eturn in t ime.', 100 0);
  1063  
  1064                runs(fun ction () {
  1065                    expe ct(fetchEr ror).toBeT ruthy();
  1066                    expe ct(fetchEr ror).toCon tain('Erro rValue');
  1067                    expe ct(fetchEr ror).toCon tain('Erro r received  from RPC  call');
  1068                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  1069                         data: null ,
  1070                         hmpBatchSi ze: 1000,
  1071                         rawRespons e: 'ErrorR esponse',
  1072                         errorData:  { message : vistaCli ent.ERROR_ LIST.RPC_E RROR }
  1073                    }));
  1074                });
  1075           }) ;
  1076           it ('Verify w hen fetch  of batch m essage giv es no erro r and also  no respon se.', func tion () {
  1077                var vist aClient =  createVist aClient(co nfig, true );
  1078                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1079                expect(r pcClient). not.toBeNu ll();
  1080                rpcClien t.setError AndRespons e(null, nu ll);
  1081  
  1082                var fini shed = fal se;
  1083                var fetc hError;
  1084                var fetc hWrappedRe sponse;
  1085                vistaCli ent.fetchN extBatch(' 9E7A', '',  1000, fun ction (err or, wrappe dResponse)  {
  1086                    fetc hError = e rror;
  1087                    fetc hWrappedRe sponse = w rappedResp onse;
  1088                    fini shed = tru e;
  1089                });
  1090  
  1091                waitsFor (function  () {
  1092                    retu rn finishe d;
  1093                }, 'Call  to fetchN extBatch f ailed to r eturn in t ime.', 100 0);
  1094  
  1095                runs(fun ction () {
  1096                    expe ct(fetchEr ror).toBeT ruthy();
  1097                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  1098                         data: null ,
  1099                         hmpBatchSi ze: 1000,
  1100                         rawRespons e: null,
  1101                         errorData:  { message : vistaCli ent.ERROR_ LIST.RPC_E RROR }
  1102                    }));
  1103                });
  1104           }) ;
  1105           it ('Verify b ad JSON ha ndling is  correct.',  function  () {
  1106                var rawR esponse =  '{' +
  1107                    '"ap iVersion":  1.03,' +
  1108                    '"pa rams": {'  +
  1109                    '"do main": "Vi stA domain  name",' +
  1110                    '"sy stemId": " VistA Site  Hash"' +
  1111                    'mak e some bad  JSON stru cture with  this mess age.' +
  1112                    '},'  +
  1113                    '"da ta": {' +
  1114                    '"up dated": "2 0161222091 413",' +
  1115                    '"to talItems":  1,' +
  1116                    '"la stUpdate":  "3161217- 31888",' +
  1117                    '"al locationTo ken": "316 1217-1",'  +
  1118                    '"wa itingPids" : [],' +
  1119                    '"pr ocessingPi ds": [],'  +
  1120                    '"re mainingObj ects": 250 0,' +
  1121                    '"it ems": []'  +
  1122                    '}'  +
  1123                    '}';
  1124                var vist aClient =  createVist aClient(co nfig, true );
  1125                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1126                expect(r pcClient). not.toBeNu ll();
  1127                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  1128  
  1129                var fini shed = fal se;
  1130                var fetc hError;
  1131                var fetc hWrappedRe sponse;
  1132                vistaCli ent.fetchN extBatch(' 9E7A', '',  2, functi on (error,  wrappedRe sponse) {
  1133                    fetc hError = e rror;
  1134                    fetc hWrappedRe sponse = w rappedResp onse;
  1135                    fini shed = tru e;
  1136                });
  1137  
  1138                waitsFor (function  () {
  1139                    retu rn finishe d;
  1140                }, 'Call  to fetchN extBatch f ailed to r eturn in t ime.', 100 0);
  1141  
  1142                runs(fun ction () {
  1143                    expe ct(fetchEr ror).toBeT ruthy();
  1144                    expe ct(fetchEr ror).toCon tain('Fail ed to pars e');
  1145                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  1146                         data: null ,
  1147                         hmpBatchSi ze: '1',
  1148                         rawRespons e: rawResp onse,
  1149                         errorData:  { message : vistaCli ent.ERROR_ LIST.INVAL ID_JSON_ER ROR }
  1150  
  1151                    }));
  1152                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(2);
  1153                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1154                         jasmine.ob jectContai ning({
  1155                             '"serv er"': hmpS erver,
  1156                             '"comm and"': 'ge tPtUpdates ',
  1157                             '"last Update"':  '',
  1158                             '"getS tatus"': t rue,
  1159                             '"max" ': '2',
  1160                             '"hmpV ersion"':  config['hm p.version' ],
  1161                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  1162                         }), jasmin e.any(Func tion));
  1163                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1164                         jasmine.ob jectContai ning({
  1165                             '"serv er"': hmpS erver,
  1166                             '"comm and"': 'ge tPtUpdates ',
  1167                             '"last Update"':  '',
  1168                             '"getS tatus"': t rue,
  1169                             '"max" ': '1',
  1170                             '"hmpV ersion"':  config['hm p.version' ],
  1171                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  1172                         }), jasmin e.any(Func tion));
  1173                });
  1174           }) ;
  1175           it ('Verify " staging no t complete " warning  from VistA .', functi on () {
  1176                var rawR esponse =  '{' +
  1177                    '"ap iVersion":  1.03,' +
  1178                    '"pa rams": {'  +
  1179                    '"do main": "Vi stA domain  name",' +
  1180                    '"sy stemId": " VistA Site  Hash"' +
  1181                    '},'  +
  1182                    '"wa rning": "S taging is  not comple te yet!"'  +
  1183                    '}';
  1184                var vist aClient =  createVist aClient(co nfig, true );
  1185                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1186                expect(r pcClient). not.toBeNu ll();
  1187                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  1188  
  1189                var fini shed = fal se;
  1190                var fetc hError;
  1191                var fetc hWrappedRe sponse;
  1192                vistaCli ent.fetchN extBatch(' 9E7A', '',  1000, fun ction (err or, wrappe dResponse)  {
  1193                    fetc hError = e rror;
  1194                    fetc hWrappedRe sponse = w rappedResp onse;
  1195                    fini shed = tru e;
  1196                });
  1197  
  1198                waitsFor (function  () {
  1199                    retu rn finishe d;
  1200                }, 'Call  to fetchN extBatch f ailed to r eturn in t ime.', 100 0);
  1201  
  1202                runs(fun ction () {
  1203                    expe ct(fetchEr ror).toBeN ull();
  1204                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  1205                         data: unde fined,
  1206                         hmpBatchSi ze: 1000,
  1207                         rawRespons e: null,
  1208                         errorData:  null
  1209                    }));
  1210                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  1211                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1212                         jasmine.ob jectContai ning({
  1213                             '"serv er"': hmpS erver,
  1214                             '"comm and"': 'ge tPtUpdates ',
  1215                             '"last Update"':  '',
  1216                             '"getS tatus"': t rue,
  1217                             '"max" ': '1000',
  1218                             '"hmpV ersion"':  config['hm p.version' ],
  1219                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  1220                         }), jasmin e.any(Func tion));
  1221                });
  1222           }) ;
  1223           it ('Verify w hen valid  response h as no "dat a" node',  function ( ) {
  1224                var rawR esponse =  '{' +
  1225                    '"ap iVersion":  1.03,' +
  1226                    '"pa rams": {'  +
  1227                    '"do main": "Vi stA domain  name",' +
  1228                    '"sy stemId": " VistA Site  Hash"' +
  1229                    '}'  +
  1230                    '}';
  1231                var vist aClient =  createVist aClient(co nfig, true );
  1232                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1233                expect(r pcClient). not.toBeNu ll();
  1234                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  1235  
  1236                var fini shed = fal se;
  1237                var fetc hError;
  1238                var fetc hWrappedRe sponse;
  1239                vistaCli ent.fetchN extBatch(' 9E7A', '',  1000, fun ction (err or, wrappe dResponse)  {
  1240                    fetc hError = e rror;
  1241                    fetc hWrappedRe sponse = w rappedResp onse;
  1242                    fini shed = tru e;
  1243                });
  1244  
  1245                waitsFor (function  () {
  1246                    retu rn finishe d;
  1247                }, 'Call  to fetchN extBatch f ailed to r eturn in t ime.', 100 0);
  1248  
  1249                runs(fun ction () {
  1250                    expe ct(fetchEr ror).toBeT ruthy();
  1251                    expe ct(fetchEr ror).toCon tain('json Response d id not con tain any d ata attrib ute');
  1252                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  1253                         data: null ,
  1254                         hmpBatchSi ze: 1000,
  1255                         rawRespons e: null,
  1256                         errorData:  null
  1257                    }));
  1258                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  1259                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1260                         jasmine.ob jectContai ning({
  1261                             '"serv er"': hmpS erver,
  1262                             '"comm and"': 'ge tPtUpdates ',
  1263                             '"last Update"':  '',
  1264                             '"getS tatus"': t rue,
  1265                             '"max" ': '1000',
  1266                             '"hmpV ersion"':  config['hm p.version' ],
  1267                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  1268                         }), jasmin e.any(Func tion));
  1269                });
  1270           }) ;
  1271           it ('Verify w hen valid  response h as root le vel error  node', fun ction () {
  1272                var rawR esponse =  '{' +
  1273                    '"ap iVersion":  1.03,' +
  1274                    '"pa rams": {'  +
  1275                    '"do main": "Vi stA domain  name",' +
  1276                    '"sy stemId": " VistA Site  Hash"' +
  1277                    '},'  +
  1278                    '"er ror": {' +
  1279                    '"me ssage": "S ome error  occurred." ' +
  1280                    '}'  +
  1281                    '}';
  1282                var vist aClient =  createVist aClient(co nfig, true );
  1283                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1284                expect(r pcClient). not.toBeNu ll();
  1285                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  1286  
  1287                var fini shed = fal se;
  1288                var fetc hError;
  1289                var fetc hWrappedRe sponse;
  1290                vistaCli ent.fetchN extBatch(' 9E7A', '',  1000, fun ction (err or, wrappe dResponse)  {
  1291                    fetc hError = e rror;
  1292                    fetc hWrappedRe sponse = w rappedResp onse;
  1293                    fini shed = tru e;
  1294                });
  1295  
  1296                waitsFor (function  () {
  1297                    retu rn finishe d;
  1298                }, 'Call  to fetchN extBatch f ailed to r eturn in t ime.', 100 0);
  1299  
  1300                runs(fun ction () {
  1301                    expe ct(fetchEr ror).toBeT ruthy();
  1302                    expe ct(fetchEr ror).toCon tain('Vist a returned  an error  condition. ');
  1303                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  1304                         data: null ,
  1305                         hmpBatchSi ze: 1000,
  1306                         rawRespons e: null,
  1307                         errorData:  { message : 'Some er ror occurr ed.'}
  1308                    }));
  1309                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  1310                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1311                         jasmine.ob jectContai ning({
  1312                             '"serv er"': hmpS erver,
  1313                             '"comm and"': 'ge tPtUpdates ',
  1314                             '"last Update"':  '',
  1315                             '"getS tatus"': t rue,
  1316                             '"max" ': '1000',
  1317                             '"hmpV ersion"':  config['hm p.version' ],
  1318                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  1319                         }), jasmin e.any(Func tion));
  1320                });
  1321           }) ;
  1322           it ('Verify w hen valid  response h as batch l evel error  under the  data node ', functio n () {
  1323                var rawR esponse =  '{' +
  1324                    '"ap iVersion":  1.03,' +
  1325                    '"pa rams": {'  +
  1326                    '"do main": "Vi stA domain  name",' +
  1327                    '"sy stemId": " VistA Site  Hash"' +
  1328                    '},'  +
  1329                    '"da ta": {' +
  1330                    '"er ror": {' +
  1331                    '"me ssage": "S ome error  occurred." ' +
  1332                    '}'  +
  1333                    '}'  +
  1334                    '}';
  1335                var vist aClient =  createVist aClient(co nfig, true );
  1336                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1337                expect(r pcClient). not.toBeNu ll();
  1338                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  1339  
  1340                var fini shed = fal se;
  1341                var fetc hError;
  1342                var fetc hWrappedRe sponse;
  1343                vistaCli ent.fetchN extBatch(' 9E7A', '',  1000, fun ction (err or, wrappe dResponse)  {
  1344                    fetc hError = e rror;
  1345                    fetc hWrappedRe sponse = w rappedResp onse;
  1346                    fini shed = tru e;
  1347                });
  1348  
  1349                waitsFor (function  () {
  1350                    retu rn finishe d;
  1351                }, 'Call  to fetchN extBatch f ailed to r eturn in t ime.', 100 0);
  1352  
  1353                runs(fun ction () {
  1354                    expe ct(fetchEr ror).toBeT ruthy();
  1355                    expe ct(fetchEr ror).toCon tain('Vist a returned  a batch l evel error  condition .');
  1356                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  1357                         data: null ,
  1358                         hmpBatchSi ze: 1000,
  1359                         rawRespons e: null,
  1360                         errorData:  { message : 'Some er ror occurr ed.'}
  1361                    }));
  1362                    expe ct(rpcClie nt.execute .calls.len gth).toEqu al(1);
  1363                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1364                         jasmine.ob jectContai ning({
  1365                             '"serv er"': hmpS erver,
  1366                             '"comm and"': 'ge tPtUpdates ',
  1367                             '"last Update"':  '',
  1368                             '"getS tatus"': t rue,
  1369                             '"max" ': '1000',
  1370                             '"hmpV ersion"':  config['hm p.version' ],
  1371                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ]
  1372                         }), jasmin e.any(Func tion));
  1373                });
  1374           }) ;
  1375           it ('Verify w hen have i nvalid con figuration ', functio n () {
  1376                var loca lConfig =  JSON.parse (JSON.stri ngify(conf ig));
  1377                delete l ocalConfig .vistaSite s['9E7A'];
  1378                delete l ocalConfig .vistaSite s['C877'];
  1379                var vist aClient =  createVist aClient(lo calConfig,  false);
  1380  
  1381                var fini shed = fal se;
  1382                var fetc hError;
  1383                var fetc hWrappedRe sponse;
  1384                vistaCli ent.fetchN extBatch(' 9E7A', '',  1000, fun ction (err or, wrappe dResponse)  {
  1385                    fetc hError = e rror;
  1386                    fetc hWrappedRe sponse = w rappedResp onse;
  1387                    fini shed = tru e;
  1388                });
  1389  
  1390                waitsFor (function  () {
  1391                    retu rn finishe d;
  1392                }, 'Call  to fetchN extBatch f ailed to r eturn in t ime.', 100 0);
  1393  
  1394                runs(fun ction () {
  1395                    expe ct(fetchEr ror).toBeT ruthy();
  1396                    expe ct(fetchEr ror).toCon tain('Fail ed to call  RPC getPt Updates fo r vistaId' );
  1397                    expe ct(fetchWr appedRespo nse).toEqu al(jasmine .objectCon taining({
  1398                         data: null ,
  1399                         hmpBatchSi ze: 1000,
  1400                         rawRespons e: null,
  1401                         errorData:  { message : vistaCli ent.ERROR_ LIST.INVAL ID_CONFIGU RATION_ERR OR}
  1402                    }));
  1403                });
  1404           }) ;
  1405  
  1406       });
  1407       descri be('multip lePollerMo deApi', fu nction ()  {
  1408           it ('Verify a n invalid  vistaId',  function ( ) {
  1409                var vist aClient =  createVist aClient(co nfig, true );
  1410  
  1411                var vist aId = null ;
  1412  
  1413                var fini shed = fal se;
  1414                var vist aError;
  1415                var vist aResponse;
  1416                runs(fun ction() {
  1417                    vist aClient.mu ltiplePoll erModeApi( vistaId, n ull, null,  null, nul l, null, f unction (e rror, resp onse) {
  1418                         vistaError  = error;
  1419                         vistaRespo nse = resp onse;
  1420                         finished =  true;
  1421                    });
  1422                });
  1423  
  1424                waitsFor (function  () {
  1425                    retu rn finishe d;
  1426                }, 'Call  to multip lePollerMo deApi fail ed to retu rn in time .', 1000);
  1427  
  1428                runs(fun ction () {
  1429                    expe ct(vistaEr ror).toBeT ruthy();
  1430                    expe ct(vistaEr ror).toCon tain('Call ed with mi ssing vist aId parame ter');
  1431                    expe ct(vistaRe sponse).to BeFalsy();
  1432                });
  1433           }) ;
  1434           it ('Verify o nly valid  vistaId an d no other  parameter s.', funct ion () {
  1435                var rawR esponse =  '{' +
  1436                    '"ap iVersion":  1.03,' +
  1437                    '"pa rams": {'  +
  1438                    '"do main": "PA NORAMA.VIS TACORE.US" ,' +
  1439                    '"sy stemId": " 9E7A"' +
  1440                    '},'  +
  1441                    '"da ta": {' +
  1442                    '"er ror": {' +
  1443                    '"me ssage": "S ome messag e here."'  +
  1444                    '}'  +
  1445                    '}'  +
  1446                    '}';
  1447                var vist aClient =  createVist aClient(co nfig, true );
  1448                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1449                expect(r pcClient). not.toBeNu ll();
  1450                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  1451  
  1452                var vist aId = '9E7 A';
  1453  
  1454                var fini shed = fal se;
  1455                var vist aError;
  1456                var vist aResponse;
  1457                runs(fun ction() {
  1458                    vist aClient.mu ltiplePoll erModeApi( vistaId, n ull, null,  null, nul l, null, f unction (e rror, resp onse) {
  1459                         vistaError  = error;
  1460                         vistaRespo nse = resp onse;
  1461                         finished =  true;
  1462                    });
  1463                });
  1464  
  1465                waitsFor (function  () {
  1466                    retu rn finishe d;
  1467                }, 'Call  to multip lePollerMo deApi fail ed to retu rn in time .', 1000);
  1468  
  1469                runs(fun ction () {
  1470                    expe ct(vistaEr ror).toBeF alsy();
  1471                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1472                         jasmine.ob jectContai ning({
  1473                             '"comm and"': 'ge tPtUpdates ',
  1474                             '"serv er"': hmpS erver,
  1475                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ],
  1476                             '"hmpV ersion"':  config['hm p.version' ]
  1477                         }), jasmin e.any(Func tion));
  1478                    expe ct(vistaRe sponse).to Be(rawResp onse);
  1479                });
  1480           }) ;
  1481           it ('Verify w ith valid  parameters  for all p arams.', f unction ()  {
  1482                var rawR esponse =  '{' +
  1483                    '"ap iVersion":  1.03,' +
  1484                    '"pa rams": {'  +
  1485                    '"do main": "PA NORAMA.VIS TACORE.US" ,' +
  1486                    '"sy stemId": " 9E7A"' +
  1487                    '},'  +
  1488                    '"da ta": {' +
  1489                    '"er ror": {' +
  1490                    '"me ssage": "S ome messag e here."'  +
  1491                    '}'  +
  1492                    '}'  +
  1493                    '}';
  1494                var vist aClient =  createVist aClient(co nfig, true );
  1495                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1496                expect(r pcClient). not.toBeNu ll();
  1497                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  1498  
  1499                var vist aId = '9E7 A';
  1500                var allo cationSize  = '100';
  1501                var allo cationToke n = '12345 56111';
  1502                var allo cationStat us = 'comp lete';
  1503                var max  = '1000';
  1504                var maxS ize = '500 ';
  1505  
  1506                var fini shed = fal se;
  1507                var vist aError;
  1508                var vist aResponse;
  1509                runs(fun ction() {
  1510                    vist aClient.mu ltiplePoll erModeApi( vistaId, a llocationS ize, alloc ationToken , allocati onStatus,  max, maxSi ze, functi on (error,  response)  {
  1511                         vistaError  = error;
  1512                         vistaRespo nse = resp onse;
  1513                         finished =  true;
  1514                    });
  1515                });
  1516  
  1517                waitsFor (function  () {
  1518                    retu rn finishe d;
  1519                }, 'Call  to multip lePollerMo deApi fail ed to retu rn in time .', 1000);
  1520  
  1521                runs(fun ction () {
  1522                    expe ct(vistaEr ror).toBeF alsy();
  1523                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1524                         jasmine.ob jectContai ning({
  1525                             '"comm and"': 'ge tPtUpdates ',
  1526                             '"serv er"': hmpS erver,
  1527                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ],
  1528                             '"hmpV ersion"':  config['hm p.version' ],
  1529                             '"allo cationSize "': alloca tionSize,
  1530                             '"allo cationToke n"': alloc ationToken ,
  1531                             '"allo cationStat us"': allo cationStat us,
  1532                             '"max" ': max,
  1533                             '"maxS ize"': max Size
  1534                         }), jasmin e.any(Func tion));
  1535                    expe ct(vistaRe sponse).to Be(rawResp onse);
  1536                });
  1537           }) ;
  1538           it ('Verify w ith valid  vistaId an d allocati onSize but  no other  parameters .', functi on () {
  1539                var rawR esponse =  '{' +
  1540                    '"ap iVersion":  1.03,' +
  1541                    '"pa rams": {'  +
  1542                    '"do main": "PA NORAMA.VIS TACORE.US" ,' +
  1543                    '"sy stemId": " 9E7A"' +
  1544                    '},'  +
  1545                    '"da ta": {' +
  1546                    '"er ror": {' +
  1547                    '"me ssage": "S ome messag e here."'  +
  1548                    '}'  +
  1549                    '}'  +
  1550                    '}';
  1551                var vist aClient =  createVist aClient(co nfig, true );
  1552                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1553                expect(r pcClient). not.toBeNu ll();
  1554                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  1555  
  1556                var vist aId = '9E7 A';
  1557                var allo cationSize  = '100';
  1558  
  1559                var fini shed = fal se;
  1560                var vist aError;
  1561                var vist aResponse;
  1562                runs(fun ction() {
  1563                    vist aClient.mu ltiplePoll erModeApi( vistaId, a llocationS ize, null,  null, nul l, null, f unction (e rror, resp onse) {
  1564                         vistaError  = error;
  1565                         vistaRespo nse = resp onse;
  1566                         finished =  true;
  1567                    });
  1568                });
  1569  
  1570                waitsFor (function  () {
  1571                    retu rn finishe d;
  1572                }, 'Call  to multip lePollerMo deApi fail ed to retu rn in time .', 1000);
  1573  
  1574                runs(fun ction () {
  1575                    expe ct(vistaEr ror).toBeF alsy();
  1576                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1577                         jasmine.ob jectContai ning({
  1578                             '"comm and"': 'ge tPtUpdates ',
  1579                             '"serv er"': hmpS erver,
  1580                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ],
  1581                             '"hmpV ersion"':  config['hm p.version' ],
  1582                             '"allo cationSize "': alloca tionSize
  1583                         }), jasmin e.any(Func tion));
  1584                    expe ct(vistaRe sponse).to Be(rawResp onse);
  1585                });
  1586           }) ;
  1587       });
  1588       descri be('retrie veApiVersi on', funct ion () {
  1589           it ('Verify a n invalid  vistaId',  function ( ) {
  1590                var vist aClient =  createVist aClient(co nfig, true );
  1591  
  1592                var vist aId = null ;
  1593  
  1594                var fini shed = fal se;
  1595                var vist aError;
  1596                var vist aResponse;
  1597                runs(fun ction () {
  1598                    vist aClient.re trieveApiV ersion(vis taId, func tion (erro r, respons e) {
  1599                         vistaError  = error;
  1600                         vistaRespo nse = resp onse;
  1601                         finished =  true;
  1602                    });
  1603                });
  1604  
  1605                waitsFor (function  () {
  1606                    retu rn finishe d;
  1607                }, 'Call  to retrie veApiVersi on failed  to return  in time.',  1000);
  1608  
  1609                runs(fun ction () {
  1610                    expe ct(vistaEr ror).toBeT ruthy();
  1611                    expe ct(vistaEr ror).toCon tain('Call ed with mi ssing vist aId parame ter');
  1612                    expe ct(vistaRe sponse).to BeFalsy();
  1613                });
  1614           }) ;
  1615           it ('Verify w ith valid  vistaId.',  function  () {
  1616                var rawR esponse =  '{' +
  1617                    '"ap iVersion":  1.03,' +
  1618                    '"pa rams": {'  +
  1619                    '"do main": "PA NORAMA.VIS TACORE.US" ,' +
  1620                    '"sy stemId": " 9E7A"' +
  1621                    '},'  +
  1622                    '"da ta": {' +
  1623                    '"er ror": {' +
  1624                    '"me ssage": "S ome messag e here."'  +
  1625                    '}'  +
  1626                    '}'  +
  1627                    '}';
  1628                var vist aClient =  createVist aClient(co nfig, true );
  1629                var rpcC lient = vi staClient. _getRpcCli ent('9E7A' );
  1630                expect(r pcClient). not.toBeNu ll();
  1631                rpcClien t.setError AndRespons e(null, ra wResponse) ;
  1632  
  1633                var vist aId = '9E7 A';
  1634  
  1635                var fini shed = fal se;
  1636                var vist aError;
  1637                var vist aResponse;
  1638                runs(fun ction () {
  1639                    vist aClient.re trieveApiV ersion(vis taId, func tion (erro r, respons e) {
  1640                         vistaError  = error;
  1641                         vistaRespo nse = resp onse;
  1642                         finished =  true;
  1643                    });
  1644                });
  1645  
  1646                waitsFor (function  () {
  1647                    retu rn finishe d;
  1648                }, 'Call  to retrie veApiVersi on failed  to return  in time.',  1000);
  1649  
  1650                runs(fun ction () {
  1651                    expe ct(vistaEr ror).toBeF alsy();
  1652                    expe ct(rpcClie nt.execute ).toHaveBe enCalledWi th('HMPDJF S API',
  1653                         jasmine.ob jectContai ning({
  1654                             '"comm and"': 'ch eckHealth' ,
  1655                             '"serv er"': hmpS erver,
  1656                             '"extr actSchema" ': config[ 'hmp.extra ct.schema' ],
  1657                             '"hmpV ersion"':  config['hm p.version' ]
  1658                         }), jasmin e.any(Func tion));
  1659                    expe ct(vistaRe sponse).to Be(rawResp onse);
  1660                });
  1661           }) ;
  1662       });
  1663   });
  1664