Produced by Araxis Merge on 10/3/2017 11:16:03 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\handlers\vista-record-poller | vista-record-poller-spec.js | Mon Jul 10 17:46:22 2017 UTC |
| 2 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\handlers\vista-record-poller | vista-record-poller-spec.js | Tue Oct 3 13:21:23 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 4790 |
| Changed | 1 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| 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 |
No regular expressions were active.
| 1 | 'use stric t'; | |
| 2 | ||
| 3 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------ | |
| 4 | // This fi le contain s unit tes ts for vis ta-record- poller.js. | |
| 5 | // | |
| 6 | // Author: Mike Rish er, Les We stberg | |
| 7 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------ | |
| 8 | ||
| 9 | require('. ./../../.. /env-setup '); | |
| 10 | ||
| 11 | var _ = re quire('und erscore'); | |
| 12 | var moment = require ('moment') ; | |
| 13 | ||
| 14 | var Poller = require (global.VX _HANDLERS + 'vista-r ecord-poll er/vista-r ecord-poll er'); | |
| 15 | var Publis herRouterD ummy = req uire(globa l.VX_DUMMI ES + 'publ isherRoute rDummy'); | |
| 16 | var Publis herDummy = require(g lobal.VX_D UMMIES + ' publisherD ummy'); | |
| 17 | var dummyL ogger = re quire(glob al.VX_DUMM IES + 'dum my-logger' ); | |
| 18 | var publis herRouterD ummy = new Publisher RouterDumm y(dummyLog ger, confi g, Publish erDummy); | |
| 19 | // var log = require (global.VX _UTILS + ' log'); | |
| 20 | // dummyLo gger = log ._createLo gger({ | |
| 21 | // nam e: 'test', | |
| 22 | // lev el: 'debug ', | |
| 23 | // chi ld: log._c reateLogge r | |
| 24 | // }); | |
| 25 | var JobSta tusUpdater = require (global.VX _SUBSYSTEM S + 'jds/J obStatusUp dater'); | |
| 26 | var JdsCli entDummy = require(g lobal.VX_D UMMIES + ' jds-client -dummy'); | |
| 27 | var VistaC lientDummy = require (global.VX _DUMMIES + 'vista-cl ient-dummy '); | |
| 28 | ||
| 29 | var errorP ublisher = { | |
| 30 | publis hPollerErr or: functi on() {} | |
| 31 | }; | |
| 32 | var config = { | |
| 33 | poller IgnoreDupl icateError Time: 1800 , | |
| 34 | jds: { | |
| 35 | pr otocol: 'h ttp', | |
| 36 | host: ' IP ', | |
| 37 | port: PORT | |
| 38 | }, | |
| 39 | 'hmp.b atch.size' : 1000, | |
| 40 | hdr: { | |
| 41 | hd rSites: { | |
| 42 | '84F0': { | |
| 43 | stat ionNumber: 578 | |
| 44 | } | |
| 45 | }, | |
| 46 | pu bsubConfig : { | |
| 47 | maxBatch Size: 500 | |
| 48 | } | |
| 49 | } | |
| 50 | }; | |
| 51 | ||
| 52 | var jdsCli entDummy = new JdsCl ientDummy( dummyLogge r, config) ; | |
| 53 | var lastUp dateTimeVa lue = '315 0106-1624' ; | |
| 54 | var vistaI dValue = ' C877'; | |
| 55 | var patien tIdentifie rValue1 = { | |
| 56 | type: 'pid', | |
| 57 | value: vistaIdVa lue + ';1' | |
| 58 | }; | |
| 59 | var uidVal ue = 'urn: va:vprupda te:' + vis taIdValue; | |
| 60 | ||
| 61 | var enviro nment = { | |
| 62 | jobSta tusUpdater : {}, | |
| 63 | metric s: dummyLo gger, | |
| 64 | publis herRouter: publisher RouterDumm y, | |
| 65 | jds: j dsClientDu mmy, | |
| 66 | errorP ublisher: {publishPo llerError: function( ){}} | |
| 67 | }; | |
| 68 | environmen t.jobStatu sUpdater = new JobSt atusUpdate r(dummyLog ger, confi g, environ ment.jds); | |
| 69 | ||
| 70 | var syncSt artJobsVal ue = [{ | |
| 71 | collec tion: 'syn cStart', | |
| 72 | pid: v istaIdValu e + ';1', | |
| 73 | rootJo bId: '3', | |
| 74 | jobId: '9', | |
| 75 | metaSt amp: { | |
| 76 | st ampTime: ' 2015011411 5126', | |
| 77 | so urceMetaSt amp: { | |
| 78 | '9E7A': { | |
| 79 | pid: vistaIdVa lue + ';1' , | |
| 80 | loca lId: '1', | |
| 81 | stam pTime: '20 1501141151 26', | |
| 82 | doma inMetaStam p: { | |
| 83 | 'allergy': { | |
| 84 | domain : 'allergy ', | |
| 85 | stampT ime: '2015 0114115126 ', | |
| 86 | eventM etaStamp: { | |
| 87 | 'u rn:va:alle rgy:C877:1 :751': { | |
| 88 | stampTim e: '201501 14115126' | |
| 89 | }, | |
| 90 | 'u rn:va:alle rgy:C877:1 :752': { | |
| 91 | stampTim e: '201501 14115126' | |
| 92 | } | |
| 93 | } | |
| 94 | } | |
| 95 | } | |
| 96 | } | |
| 97 | } | |
| 98 | } | |
| 99 | }, { | |
| 100 | collec tion: 'syn cStart', | |
| 101 | pid: v istaIdValu e + ';2', | |
| 102 | rootJo bId: '2', | |
| 103 | jobId: '6', | |
| 104 | metaSt amp: { | |
| 105 | st ampTime: ' 2015011411 5126', | |
| 106 | so urceMetaSt amp: { | |
| 107 | '9E7A': { | |
| 108 | pid: vistaIdVa lue + ';2' , | |
| 109 | loca lId: '1', | |
| 110 | stam pTime: '20 1501141151 26', | |
| 111 | doma inMetaStam p: { | |
| 112 | 'allergy': { | |
| 113 | domain : 'allergy ', | |
| 114 | stampT ime: '2015 0114115126 ', | |
| 115 | eventM etaStamp: { | |
| 116 | 'u rn:va:alle rgy:C877:2 :300': { | |
| 117 | stampTim e: '201501 14115126' | |
| 118 | }, | |
| 119 | 'u rn:va:alle rgy:C877:2 :301': { | |
| 120 | stampTim e: '201501 14115126' | |
| 121 | } | |
| 122 | } | |
| 123 | } | |
| 124 | } | |
| 125 | } | |
| 126 | } | |
| 127 | } | |
| 128 | }]; | |
| 129 | ||
| 130 | var unsoli citedUpdat eSyncStart = { | |
| 131 | collec tion: 'syn cStart', | |
| 132 | pid: v istaIdValu e + ';1', | |
| 133 | metaSt amp: { | |
| 134 | st ampTime: ' 2015011411 5126', | |
| 135 | so urceMetaSt amp: { | |
| 136 | 'C877': { | |
| 137 | pid: vistaIdVa lue + ';1' , | |
| 138 | loca lId: '1', | |
| 139 | stam pTime: '20 1501141151 26', | |
| 140 | doma inMetaStam p: { | |
| 141 | 'allergy': { | |
| 142 | domain : 'allergy ', | |
| 143 | stampT ime: '2015 0114115126 ', | |
| 144 | eventM etaStamp: { | |
| 145 | 'u rn:va:alle rgy:C877:1 :751': { | |
| 146 | stampTim e: '201501 14115126' | |
| 147 | } | |
| 148 | } | |
| 149 | } | |
| 150 | } | |
| 151 | } | |
| 152 | } | |
| 153 | } | |
| 154 | }; | |
| 155 | ||
| 156 | var OPDsyn cStartJobs Value = [{ | |
| 157 | 'colle ction': 'O PDsyncStar t', | |
| 158 | 'syste mId': '9E7 A', | |
| 159 | 'rootJ obId': '1' , | |
| 160 | 'jobId ': '3', | |
| 161 | 'metaS tamp': { | |
| 162 | 's tampTime': 201410310 94920, | |
| 163 | 's ourceMetaS tamp': { | |
| 164 | '9E7A': { | |
| 165 | 'sta mpTime': 2 0141031094 920, | |
| 166 | 'dom ainMetaSta mp': { | |
| 167 | 'doc-def': { | |
| 168 | 'domai n': 'doc-d ef', | |
| 169 | 'stamp Time': 201 4103109492 0, | |
| 170 | 'itemM etaStamp': { | |
| 171 | 'u rn:va:doc- def:9E7A:1 001': { | |
| 172 | 'stampTi me': 20141 031094920, | |
| 173 | }, | |
| 174 | 'u rn:va:doc- def:9E7A:1 002': { | |
| 175 | 'stampTi me': 20141 031094920, | |
| 176 | } | |
| 177 | } | |
| 178 | }, | |
| 179 | 'pt-select ': { | |
| 180 | 'domai n': 'pt-se lect', | |
| 181 | 'stamp Time': 201 4103109492 0, | |
| 182 | 'itemM etaStamp': { | |
| 183 | 'u rn:va:pt-s elect:9E7A :1001': { | |
| 184 | 'stampTi me': 20141 031094920, | |
| 185 | }, | |
| 186 | 'u rn:va:pt-s elect:9E7a :1002': { | |
| 187 | 'stampTi me': 20141 031094920, | |
| 188 | } | |
| 189 | } | |
| 190 | } | |
| 191 | } | |
| 192 | } | |
| 193 | } | |
| 194 | } | |
| 195 | }]; | |
| 196 | ||
| 197 | var vistaD ataJobAlle rgyObjectW ithoutPid = { | |
| 198 | uid: ' urn:va:all ergy:9E7A: 1:27837' | |
| 199 | }; | |
| 200 | ||
| 201 | var vistaD ataJobAlle rgyObjectW ithPid = { | |
| 202 | pid: v istaIdValu e + ';1', | |
| 203 | uid: ' urn:va:all ergy:9E7A: 1:27837' | |
| 204 | }; | |
| 205 | ||
| 206 | var vistaD ataJobsVal ue = [{ | |
| 207 | collec tion: 'all ergy', | |
| 208 | pid: v istaIdValu e + ';1', | |
| 209 | object : vistaDat aJobAllerg yObjectWit houtPid | |
| 210 | }, { | |
| 211 | collec tion: 'pt- select', | |
| 212 | pid: v istaIdValu e + ';2', | |
| 213 | object : { | |
| 214 | pi d: vistaId Value + '; 2' | |
| 215 | } | |
| 216 | }, { | |
| 217 | collec tion: 'doc -ref', | |
| 218 | object : { | |
| 219 | da ta: 'some operationa l data' | |
| 220 | } | |
| 221 | }]; | |
| 222 | ||
| 223 | var dataVa lue = { | |
| 224 | lastUp date: last UpdateTime Value, | |
| 225 | items: [] | |
| 226 | }; | |
| 227 | dataValue. items = sy ncStartJob sValue.con cat(vistaD ataJobsVal ue).concat (unsolicit edUpdateSy ncStart); | |
| 228 | ||
| 229 | var rootJo bIdValue = '1'; | |
| 230 | var jobIdV alue = '2' ; | |
| 231 | var jpidVa lue = '9a6 c3294-fe16 -4a91-b10b -19f78656f b8c'; | |
| 232 | ||
| 233 | // Configu rations re lated to V istaHdr | |
| 234 | var hdrIdV alue = '84 F0'; | |
| 235 | var hdrUid Value = 'u rn:va:vpru pdate:' + hdrIdValue ; | |
| 236 | var hdrPat ientIdenti fierValue1 = { | |
| 237 | type: 'pid', | |
| 238 | value: hdrIdValu e + ';1' | |
| 239 | }; | |
| 240 | ||
| 241 | var hdrSyn cStartJobs Value = [{ | |
| 242 | collec tion: 'syn cStart', | |
| 243 | pid: h drIdValue + ';1', | |
| 244 | metaSt amp: { | |
| 245 | st ampTime: ' 2015011411 5126', | |
| 246 | so urceMetaSt amp: { | |
| 247 | '84F0': { | |
| 248 | pid: hdrIdValu e + ';1', | |
| 249 | loca lId: '1', | |
| 250 | stam pTime: '20 1501141151 26', | |
| 251 | doma inMetaStam p: { | |
| 252 | 'allergy': { | |
| 253 | domain : 'allergy ', | |
| 254 | stampT ime: '2015 0114115126 ', | |
| 255 | eventM etaStamp: { | |
| 256 | 'u rn:va:alle rgy:84F0:1 :751': { | |
| 257 | stampTim e: '201501 14115126' | |
| 258 | }, | |
| 259 | 'u rn:va:alle rgy:84F0:1 :752': { | |
| 260 | stampTim e: '201501 14115126' | |
| 261 | } | |
| 262 | } | |
| 263 | } | |
| 264 | } | |
| 265 | } | |
| 266 | } | |
| 267 | } | |
| 268 | }, { | |
| 269 | collec tion: 'syn cStart', | |
| 270 | pid: h drIdValue + ';2', | |
| 271 | metaSt amp: { | |
| 272 | st ampTime: ' 2015011411 5126', | |
| 273 | so urceMetaSt amp: { | |
| 274 | '84F0': { | |
| 275 | pid: hdrIdValu e + ';2', | |
| 276 | loca lId: '1', | |
| 277 | stam pTime: '20 1501141151 26', | |
| 278 | doma inMetaStam p: { | |
| 279 | 'allergy': { | |
| 280 | domain : 'allergy ', | |
| 281 | stampT ime: '2015 0114115126 ', | |
| 282 | eventM etaStamp: { | |
| 283 | 'u rn:va:alle rgy:84F0:2 :300': { | |
| 284 | stampTim e: '201501 14115126' | |
| 285 | }, | |
| 286 | 'u rn:va:alle rgy:84F0:2 :301': { | |
| 287 | stampTim e: '201501 14115126' | |
| 288 | } | |
| 289 | } | |
| 290 | } | |
| 291 | } | |
| 292 | } | |
| 293 | } | |
| 294 | } | |
| 295 | }]; | |
| 296 | ||
| 297 | var hdrDat aValue = { | |
| 298 | lastUp date: last UpdateTime Value, | |
| 299 | items: [] | |
| 300 | }; | |
| 301 | ||
| 302 | var vistaH drDataJobV alue = [{ | |
| 303 | collec tion: 'con sult', | |
| 304 | pid: ' 84F0;1', | |
| 305 | localI d: '1', | |
| 306 | seq: 1 , | |
| 307 | total: 1, | |
| 308 | object : { | |
| 309 | la stUpdateTi me: 201404 09083720, | |
| 310 | ca tegory: 'P ', | |
| 311 | ui d: 'urn:va :consult:8 4F0:1:82' | |
| 312 | } | |
| 313 | }, { | |
| 314 | collec tion: 'cpt ', | |
| 315 | pid: ' 84F0;1', | |
| 316 | localI d: '1', | |
| 317 | seq: 1 , | |
| 318 | total: 1, | |
| 319 | object : { | |
| 320 | la stUpdateTi me: 201404 09083720, | |
| 321 | ty pe: 'U', | |
| 322 | ui d: 'urn:va :cpt:84F0: 1:881' | |
| 323 | } | |
| 324 | }]; | |
| 325 | ||
| 326 | hdrDataVal ue.items = hdrSyncSt artJobsVal ue.concat( vistaHdrDa taJobValue ); | |
| 327 | ||
| 328 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----- | |
| 329 | // Create an instanc e of the p oller. | |
| 330 | // | |
| 331 | // log: Th e logger t o be sent to the pol ler. | |
| 332 | // vistaId Value: The vistaId t hat the po ller is ru nning unde r. | |
| 333 | // config: The confi guration s ettings | |
| 334 | // envrion ment: The environmen t settings | |
| 335 | // start: True if th e poller s hould come up in sta rt mode - meaning st art | |
| 336 | // polling th e site. | |
| 337 | // multipl ePollerMod e: True if the polle r should b e running in multipl e poller m ode | |
| 338 | // returns : the inst ance of th e poller t hat was cr eated. | |
| 339 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----- | |
| 340 | function c reatePolle r(log, vis taIdValue, config, e nvironment , start, m ultiplePol lerMode) { | |
| 341 | var po ller = new Poller(lo g, vistaId Value, con fig, envir onment, st art, multi plePollerM ode); | |
| 342 | return poller; | |
| 343 | } | |
| 344 | ||
| 345 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------- | |
| 346 | // This me thod sets up the spi es that wi ll needed on the env ironment l evel class es. | |
| 347 | // | |
| 348 | // jdsClie nt: A hand le to the JDS client . | |
| 349 | // environ ment: A ha ndle to th e environm ent. | |
| 350 | // poller: A handle to the pol ler. | |
| 351 | // publish erRouter: A handle t o the job publisher. | |
| 352 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------- | |
| 353 | function s etupSpies( jdsClient, environme nt, poller , publishe rRouter) { | |
| 354 | // Und erlying JD S calls to monitor a nd make su re that th ey are mad e. | |
| 355 | //---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- - | |
| 356 | spyOn( jdsClient, 'getOpera tionalData Mutable'). andCallThr ough(); | |
| 357 | spyOn( jdsClient, 'getPatie ntIdentifi erByPid'). andCallThr ough(); | |
| 358 | ||
| 359 | spyOn( environmen t.jobStatu sUpdater, 'createJob Status').a ndCallThro ugh(); | |
| 360 | spyOn( environmen t.errorPub lisher, 'p ublishPoll erError'). andCallThr ough(); | |
| 361 | ||
| 362 | spyOn( poller, '_ storeLastU pdateTime' ).andCallT hrough(); | |
| 363 | spyOn( poller, '_ sendToVist aRecordPro cessor').a ndCallThro ugh(); | |
| 364 | spyOn( poller, '_ createJobs ForUnsolic itedUpdate s').andCal lThrough() ; | |
| 365 | spyOn( poller, '_ createUnso licitedUpd ateJobStat us').andCa llThrough( ); | |
| 366 | spyOn( poller, '_ updateAllo cationInfo ').andCall Through(); | |
| 367 | ||
| 368 | spyOn( publisherR outer, 'pu blish').an dCallThrou gh(); | |
| 369 | } | |
| 370 | ||
| 371 | describe(' vista-reco rd-poller' , function () { | |
| 372 | descri be('_getLa stUpdateTi meFromJds' , function () { | |
| 373 | it ('Happy Pa th', funct ion() { | |
| 374 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 375 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 376 | ||
| 377 | var expe ctedJdsRes ponse = { | |
| 378 | stat usCode: 20 0 | |
| 379 | }; | |
| 380 | var expe ctedJdsRes ult = { | |
| 381 | _id: vistaIdVa lue, | |
| 382 | last Update: la stUpdateTi meValue, | |
| 383 | uid: uidValue | |
| 384 | }; | |
| 385 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, expectedJ dsResult); | |
| 386 | ||
| 387 | var fini shed = fal se; | |
| 388 | var actu alError; | |
| 389 | var actu alResponse ; | |
| 390 | runs(fun ction() { | |
| 391 | poll er._getLas tUpdateTim eFromJds(f unction(er ror, respo nse) { | |
| 392 | actualErro r = error; | |
| 393 | actualResp onse = res ponse; | |
| 394 | finished = true; | |
| 395 | }); | |
| 396 | }); | |
| 397 | ||
| 398 | waitsFor (function( ) { | |
| 399 | retu rn finishe d; | |
| 400 | }, 'Call to _getLa stUpdateTi meFromJds failed to return in time.', 50 0); | |
| 401 | ||
| 402 | runs(fun ction() { | |
| 403 | expe ct(actualE rror).toBe Null(); | |
| 404 | expe ct(actualR esponse).t oEqual(las tUpdateTim eValue); | |
| 405 | expe ct(jdsClie ntDummy.ge tOperation alDataMuta ble.calls. length).to Equal(1); | |
| 406 | expe ct(jdsClie ntDummy.ge tOperation alDataMuta ble).toHav eBeenCalle dWith(vist aIdValue, jasmine.an y(Function )); | |
| 407 | }); | |
| 408 | }) ; | |
| 409 | it ('Happy Pa th for Vis taHdr', fu nction() { | |
| 410 | var hdrP oller = cr eatePoller (dummyLogg er, hdrIdV alue, conf ig, enviro nment, fal se, false) ; | |
| 411 | setupSpi es(jdsClie ntDummy, e nvironment , hdrPolle r, publish erRouterDu mmy); | |
| 412 | ||
| 413 | var expe ctedJdsRes ponse = { | |
| 414 | stat usCode: 20 0 | |
| 415 | }; | |
| 416 | var expe ctedJdsRes ult = { | |
| 417 | _id: hdrIdValu e, | |
| 418 | last Update: la stUpdateTi meValue, | |
| 419 | uid: hdrUidVal ue | |
| 420 | }; | |
| 421 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, expectedJ dsResult); | |
| 422 | ||
| 423 | var fini shed = fal se; | |
| 424 | var actu alError; | |
| 425 | var actu alResponse ; | |
| 426 | runs(fun ction() { | |
| 427 | hdrP oller._get LastUpdate TimeFromJd s(function (error, re sponse) { | |
| 428 | actualErro r = error; | |
| 429 | actualResp onse = res ponse; | |
| 430 | finished = true; | |
| 431 | }); | |
| 432 | }); | |
| 433 | ||
| 434 | waitsFor (function( ) { | |
| 435 | retu rn finishe d; | |
| 436 | }, 'Call to _getLa stUpdateTi meFromJds failed to return in time.', 50 0); | |
| 437 | ||
| 438 | runs(fun ction() { | |
| 439 | expe ct(actualE rror).toBe Null(); | |
| 440 | expe ct(actualR esponse).t oEqual(las tUpdateTim eValue); | |
| 441 | expe ct(jdsClie ntDummy.ge tOperation alDataMuta ble.calls. length).to Equal(1); | |
| 442 | expe ct(jdsClie ntDummy.ge tOperation alDataMuta ble).toHav eBeenCalle dWith(hdrI dValue, ja smine.any( Function)) ; | |
| 443 | }); | |
| 444 | }) ; | |
| 445 | }); | |
| 446 | descri be('_store LastUpdate TimeToJds' , function () { | |
| 447 | it ('Happy Pa th', funct ion() { | |
| 448 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 449 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 450 | ||
| 451 | var expe ctedJdsRes ponse = { | |
| 452 | stat usCode: 20 0 | |
| 453 | }; | |
| 454 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, undefined ); | |
| 455 | spyOn(jd sClientDum my, 'store Operationa lDataMutab le').andCa llThrough( ); | |
| 456 | var fini shed = fal se; | |
| 457 | var actu alError; | |
| 458 | var actu alResponse ; | |
| 459 | runs(fun ction() { | |
| 460 | poll er._storeL astUpdateT imeToJds(l astUpdateT imeValue, function(e rror, resp onse) { | |
| 461 | actualErro r = error; | |
| 462 | actualResp onse = res ponse; | |
| 463 | finished = true; | |
| 464 | }); | |
| 465 | }); | |
| 466 | ||
| 467 | waitsFor (function( ) { | |
| 468 | retu rn finishe d; | |
| 469 | }, 'Call to _store LastUpdate TimeToJds failed to return in time.', 50 0); | |
| 470 | ||
| 471 | runs(fun ction() { | |
| 472 | expe ct(actualE rror).toBe Null(); | |
| 473 | expe ct(actualR esponse).t oEqual('su ccess'); | |
| 474 | expe ct(jdsClie ntDummy.st oreOperati onalDataMu table.call s.length). toEqual(1) ; | |
| 475 | expe ct(jdsClie ntDummy.st oreOperati onalDataMu table).toH aveBeenCal ledWith(ja smine.obje ctContaini ng({ | |
| 476 | _id: vista IdValue, | |
| 477 | lastUpdate : lastUpda teTimeValu e, | |
| 478 | uid: uidVa lue | |
| 479 | }), jasmine.an y(Function )); | |
| 480 | }); | |
| 481 | }) ; | |
| 482 | it ('Happy Pa th for Vis taHdr', fu nction() { | |
| 483 | var hdrP oller = cr eatePoller (dummyLogg er, hdrIdV alue, conf ig, enviro nment, fal se, false) ; | |
| 484 | setupSpi es(jdsClie ntDummy, e nvironment , hdrPolle r, publish erRouterDu mmy); | |
| 485 | ||
| 486 | var expe ctedJdsRes ponse = { | |
| 487 | stat usCode: 20 0 | |
| 488 | }; | |
| 489 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, undefined ); | |
| 490 | spyOn(jd sClientDum my, 'store Operationa lDataMutab le').andCa llThrough( ); | |
| 491 | var fini shed = fal se; | |
| 492 | var actu alError; | |
| 493 | var actu alResponse ; | |
| 494 | runs(fun ction() { | |
| 495 | hdrP oller._sto reLastUpda teTimeToJd s(lastUpda teTimeValu e, functio n(error, r esponse) { | |
| 496 | actualErro r = error; | |
| 497 | actualResp onse = res ponse; | |
| 498 | finished = true; | |
| 499 | }); | |
| 500 | }); | |
| 501 | ||
| 502 | waitsFor (function( ) { | |
| 503 | retu rn finishe d; | |
| 504 | }, 'Call to _store LastUpdate TimeToJds failed to return in time.', 50 0); | |
| 505 | ||
| 506 | runs(fun ction() { | |
| 507 | expe ct(actualE rror).toBe Null(); | |
| 508 | expe ct(actualR esponse).t oEqual('su ccess'); | |
| 509 | expe ct(jdsClie ntDummy.st oreOperati onalDataMu table.call s.length). toEqual(1) ; | |
| 510 | expe ct(jdsClie ntDummy.st oreOperati onalDataMu table).toH aveBeenCal ledWith(ja smine.obje ctContaini ng({ | |
| 511 | _id: hdrId Value, | |
| 512 | lastUpdate : lastUpda teTimeValu e, | |
| 513 | uid: hdrUi dValue | |
| 514 | }), jasmine.an y(Function )); | |
| 515 | }); | |
| 516 | }) ; | |
| 517 | }); | |
| 518 | descri be('_store LastUpdate Time', fun ction() { | |
| 519 | it ('Happy Pa th', funct ion() { | |
| 520 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 521 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 522 | ||
| 523 | var expe ctedJdsRes ponse = { | |
| 524 | stat usCode: 20 0 | |
| 525 | }; | |
| 526 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, undefined ); | |
| 527 | spyOn(jd sClientDum my, 'store Operationa lDataMutab le').andCa llThrough( ); | |
| 528 | var fini shed = fal se; | |
| 529 | var actu alError; | |
| 530 | var actu alResponse ; | |
| 531 | var loca lDataValue = JSON.pa rse(JSON.s tringify(d ataValue)) ; | |
| 532 | runs(fun ction() { | |
| 533 | ||
| 534 | poll er._storeL astUpdateT ime(localD ataValue, function(e rror, resp onse) { | |
| 535 | actualErro r = error; | |
| 536 | actualResp onse = res ponse; | |
| 537 | finished = true; | |
| 538 | }); | |
| 539 | }); | |
| 540 | ||
| 541 | waitsFor (function( ) { | |
| 542 | retu rn finishe d; | |
| 543 | }, 'Call to _store LastUpdate Time faile d to retur n in time. ', 500); | |
| 544 | ||
| 545 | runs(fun ction() { | |
| 546 | expe ct(actualE rror).toBe Null(); | |
| 547 | expe ct(actualR esponse).t oEqual('su ccess'); | |
| 548 | expe ct(jdsClie ntDummy.st oreOperati onalDataMu table.call s.length). toEqual(1) ; | |
| 549 | expe ct(jdsClie ntDummy.st oreOperati onalDataMu table).toH aveBeenCal ledWith(ja smine.obje ctContaini ng({ | |
| 550 | _id: vista IdValue, | |
| 551 | lastUpdate : lastUpda teTimeValu e, | |
| 552 | uid: uidVa lue | |
| 553 | }), jasmine.an y(Function )); | |
| 554 | }); | |
| 555 | }) ; | |
| 556 | it ('Happy Pa th for Vis taHdr', fu nction() { | |
| 557 | var hdrP oller = cr eatePoller (dummyLogg er, hdrIdV alue, conf ig, enviro nment, fal se, false) ; | |
| 558 | setupSpi es(jdsClie ntDummy, e nvironment , hdrPolle r, publish erRouterDu mmy); | |
| 559 | ||
| 560 | var expe ctedJdsRes ponse = { | |
| 561 | stat usCode: 20 0 | |
| 562 | }; | |
| 563 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, undefined ); | |
| 564 | spyOn(jd sClientDum my, 'store Operationa lDataMutab le').andCa llThrough( ); | |
| 565 | var fini shed = fal se; | |
| 566 | var actu alError; | |
| 567 | var actu alResponse ; | |
| 568 | var loca lHdrDataVa lue = JSON .parse(JSO N.stringif y(hdrDataV alue)); | |
| 569 | runs(fun ction() { | |
| 570 | hdrP oller._sto reLastUpda teTime(loc alHdrDataV alue, func tion(error , response ) { | |
| 571 | actualErro r = error; | |
| 572 | actualResp onse = res ponse; | |
| 573 | finished = true; | |
| 574 | }); | |
| 575 | }); | |
| 576 | ||
| 577 | waitsFor (function( ) { | |
| 578 | retu rn finishe d; | |
| 579 | }, 'Call to _store LastUpdate Time faile d to retur n in time. ', 500); | |
| 580 | ||
| 581 | runs(fun ction() { | |
| 582 | expe ct(actualE rror).toBe Null(); | |
| 583 | expe ct(actualR esponse).t oEqual('su ccess'); | |
| 584 | expe ct(jdsClie ntDummy.st oreOperati onalDataMu table.call s.length). toEqual(1) ; | |
| 585 | expe ct(jdsClie ntDummy.st oreOperati onalDataMu table).toH aveBeenCal ledWith(ja smine.obje ctContaini ng({ | |
| 586 | _id: hdrId Value, | |
| 587 | lastUpdate : lastUpda teTimeValu e, | |
| 588 | uid: hdrUi dValue | |
| 589 | }), jasmine.an y(Function )); | |
| 590 | }); | |
| 591 | }) ; | |
| 592 | it ('Missing lastUpdate Field', fu nction() { | |
| 593 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 594 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 595 | ||
| 596 | var expe ctedJdsRes ponse = { | |
| 597 | stat usCode: 20 0 | |
| 598 | }; | |
| 599 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, undefined ); | |
| 600 | spyOn(jd sClientDum my, 'store Operationa lDataMutab le').andCa llThrough( ); | |
| 601 | var fini shed = fal se; | |
| 602 | var actu alError; | |
| 603 | var actu alResponse ; | |
| 604 | runs(fun ction() { | |
| 605 | poll er._storeL astUpdateT ime({}, fu nction(err or, respon se) { | |
| 606 | actualErro r = error; | |
| 607 | actualResp onse = res ponse; | |
| 608 | finished = true; | |
| 609 | }); | |
| 610 | }); | |
| 611 | ||
| 612 | waitsFor (function( ) { | |
| 613 | retu rn finishe d; | |
| 614 | }, 'Call to _store LastUpdate Time faile d to retur n in time. ', 500); | |
| 615 | ||
| 616 | runs(fun ction() { | |
| 617 | expe ct(actualE rror).toBe Null(); | |
| 618 | expe ct(actualR esponse).t oEqual('su ccess'); | |
| 619 | expe ct(jdsClie ntDummy.st oreOperati onalDataMu table.call s.length). toEqual(0) ; | |
| 620 | }); | |
| 621 | }) ; | |
| 622 | }); | |
| 623 | descri be('_proce ssBatch', function() { | |
| 624 | it ('Happy Pa th - Singl e Poller M ode', func tion() { | |
| 625 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 626 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 627 | ||
| 628 | dummyLog ger.debug( 'In _proce ssBatch te st'); | |
| 629 | spyOn(en vironment. jds,'store Operationa lDataMutab le').andCa llFake(fun ction(data , callback ){callback (null, {st atusCode: 200});}); | |
| 630 | ||
| 631 | var fini shed = fal se; | |
| 632 | var actu alError; | |
| 633 | var actu alResponse ; | |
| 634 | var loca lDataValue = JSON.pa rse(JSON.s tringify(d ataValue)) ; | |
| 635 | runs(fun ction() { | |
| 636 | poll er._proces sBatch(loc alDataValu e, functio n(error, r esponse) { | |
| 637 | actualErro r = error; | |
| 638 | actualResp onse = res ponse; | |
| 639 | finished = true; | |
| 640 | }); | |
| 641 | }); | |
| 642 | ||
| 643 | waitsFor (function( ) { | |
| 644 | retu rn finishe d; | |
| 645 | }, 'Call to _proce ssSyncStar tJobs fail ed to retu rn in time .', 500); | |
| 646 | ||
| 647 | runs(fun ction() { | |
| 648 | expe ct(actualE rror).toBe Falsy(); | |
| 649 | expe ct(actualR esponse).t oBeTruthy( ); | |
| 650 | ||
| 651 | expe ct(poller. _createJob sForUnsoli citedUpdat es.calls.l ength).toE qual(1); | |
| 652 | expe ct(poller. _createUns olicitedUp dateJobSta tus.calls. length).to Equal(1); | |
| 653 | ||
| 654 | expe ct(poller. _storeLast UpdateTime .calls.len gth).toEqu al(1); | |
| 655 | expe ct(poller. _sendToVis taRecordPr ocessor.ca lls.length ).toEqual( 1); | |
| 656 | expe ct(poller. _storeLast UpdateTime ).toHaveBe enCalledWi th(localDa taValue, j asmine.any (Function) ); | |
| 657 | expe ct(poller. _updateAll ocationInf o).not.toH aveBeenCal led(); | |
| 658 | expe ct(poller. _sendToVis taRecordPr ocessor).t oHaveBeenC alledWith( localDataV alue, jasm ine.any(Fu nction)); | |
| 659 | ||
| 660 | dumm yLogger.de bug('End _ processBat ch test'); | |
| 661 | }); | |
| 662 | }) ; | |
| 663 | it ('Happy Pa th - Multi ple Poller Mode', fu nction() { | |
| 664 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, true); | |
| 665 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 666 | ||
| 667 | dummyLog ger.debug( 'In _proce ssBatch te st'); | |
| 668 | spyOn(en vironment. jds,'store Operationa lDataMutab le').andCa llFake(fun ction(data , callback ){callback (null, {st atusCode: 200});}); | |
| 669 | ||
| 670 | var fini shed = fal se; | |
| 671 | var actu alError; | |
| 672 | var actu alResponse ; | |
| 673 | var loca lDataValue = JSON.pa rse(JSON.s tringify(d ataValue)) ; | |
| 674 | runs(fun ction() { | |
| 675 | poll er._proces sBatch(loc alDataValu e, functio n(error, r esponse) { | |
| 676 | actualErro r = error; | |
| 677 | actualResp onse = res ponse; | |
| 678 | finished = true; | |
| 679 | }); | |
| 680 | }); | |
| 681 | ||
| 682 | waitsFor (function( ) { | |
| 683 | retu rn finishe d; | |
| 684 | }, 'Call to _proce ssSyncStar tJobs fail ed to retu rn in time .', 500); | |
| 685 | ||
| 686 | runs(fun ction() { | |
| 687 | expe ct(actualE rror).toBe Falsy(); | |
| 688 | expe ct(actualR esponse).t oBeTruthy( ); | |
| 689 | ||
| 690 | expe ct(poller. _createJob sForUnsoli citedUpdat es.calls.l ength).toE qual(1); | |
| 691 | expe ct(poller. _createUns olicitedUp dateJobSta tus.calls. length).to Equal(1); | |
| 692 | ||
| 693 | expe ct(poller. _storeLast UpdateTime ).not.toHa veBeenCall ed(); | |
| 694 | expe ct(poller. _sendToVis taRecordPr ocessor.ca lls.length ).toEqual( 1); | |
| 695 | expe ct(poller. _updateAll ocationInf o).toHaveB eenCalledW ith(localD ataValue, 'complete' , jasmine. any(Functi on)); | |
| 696 | expe ct(poller. _sendToVis taRecordPr ocessor).t oHaveBeenC alledWith( localDataV alue, jasm ine.any(Fu nction)); | |
| 697 | ||
| 698 | dumm yLogger.de bug('End _ processBat ch test'); | |
| 699 | }); | |
| 700 | }) ; | |
| 701 | it ('Error pa th: task e rrors out' , function () { | |
| 702 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 703 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 704 | ||
| 705 | spyOn(en vironment. jds,'store Operationa lDataMutab le').andCa llFake(fun ction(data , callback ){callback (null, {st atusCode: 500});}); | |
| 706 | ||
| 707 | var fini shed = fal se; | |
| 708 | var actu alError; | |
| 709 | var actu alResponse ; | |
| 710 | var loca lDataValue = JSON.pa rse(JSON.s tringify(d ataValue)) ; | |
| 711 | runs(fun ction() { | |
| 712 | poll er._proces sBatch(loc alDataValu e, functio n(error, r esponse) { | |
| 713 | actualErro r = error; | |
| 714 | actualResp onse = res ponse; | |
| 715 | finished = true; | |
| 716 | }); | |
| 717 | }); | |
| 718 | ||
| 719 | waitsFor (function( ) { | |
| 720 | retu rn finishe d; | |
| 721 | }, 'Call to _proce ssSyncStar tJobs fail ed to retu rn in time .', 500); | |
| 722 | ||
| 723 | runs(fun ction() { | |
| 724 | expe ct(actualE rror).toBe Truthy(); | |
| 725 | expe ct(actualR esponse).t oBeTruthy( ); | |
| 726 | ||
| 727 | expe ct(environ ment.error Publisher. publishPol lerError). toHaveBeen Called(); | |
| 728 | ||
| 729 | dumm yLogger.de bug('End _ processBat ch test'); | |
| 730 | }); | |
| 731 | }) ; | |
| 732 | }); | |
| 733 | descri be('_extra ctLastUpda teFromRawR esponse', function() { | |
| 734 | it ('Happy Pa th - with white spac e', functi on() { | |
| 735 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 736 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 737 | ||
| 738 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"lastU pdate\" : \"3150721- 11303\"}}' ; | |
| 739 | var last UpdateTime = poller. _extractLa stUpdateFr omRawRespo nse(rawRes ponse); | |
| 740 | expect(l astUpdateT ime).toEqu al('315072 1-11303'); | |
| 741 | }) ; | |
| 742 | it ('Happy Pa th - with no white s pace', fun ction() { | |
| 743 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 744 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 745 | ||
| 746 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"lastU pdate\":\" 3150721-11 303\"}}'; | |
| 747 | var last UpdateTime = poller. _extractLa stUpdateFr omRawRespo nse(rawRes ponse); | |
| 748 | expect(l astUpdateT ime).toEqu al('315072 1-11303'); | |
| 749 | }) ; | |
| 750 | it ('Happy Pa th - handl e multiple - get fir st', funct ion() { | |
| 751 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 752 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 753 | ||
| 754 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"lastU pdate\":\" 3150721-11 303\",\"la stUpdate\" :\"3150721 -11505\"}} '; | |
| 755 | var last UpdateTime = poller. _extractLa stUpdateFr omRawRespo nse(rawRes ponse); | |
| 756 | expect(_ .isArray(l astUpdateT ime)).toBe (false); | |
| 757 | expect(l astUpdateT ime).toEqu al('315072 1-11303'); | |
| 758 | }) ; | |
| 759 | }); | |
| 760 | descri be('_proce ssResponse ', functio n() { | |
| 761 | it ('Happy Pa th - Singl e Poller M ode, JSON error with batch siz e of one', function () { | |
| 762 | var poll erFakeInst ance = { | |
| 763 | vist aId: '9E7A ', | |
| 764 | envi ronment: e nvironment , | |
| 765 | conf ig: config , | |
| 766 | metr ics: dummy Logger, | |
| 767 | log: dummyLogg er, | |
| 768 | paus ed: false, | |
| 769 | read yToShutdow n: false, | |
| 770 | allo cationToke n: '', | |
| 771 | allo cationStat us: 'compl ete', | |
| 772 | mult ipleMode: false, | |
| 773 | erro rPublisher : errorPub lisher, | |
| 774 | poll DelayMilli s: 1000, | |
| 775 | last UpdateTime : '0', | |
| 776 | vprU pdateOpDat a: null, | |
| 777 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 778 | isVi staHdr: fa lse, | |
| 779 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 780 | succ ess: false , | |
| 781 | _han dleInvalid JSONWithSi ngleMessag e: functio n (error, wrappedRes ponse) { | |
| 782 | expect(err or).toBeDe fined(); | |
| 783 | expect(wra ppedRespon se).toBeDe fined(); | |
| 784 | return; | |
| 785 | } | |
| 786 | }; | |
| 787 | spyOn(po llerFakeIn stance, '_ handleInva lidJSONWit hSingleMes sage').and CallThroug h(); | |
| 788 | Poller.p rototype._ processRes ponse.call (pollerFak eInstance, 'parse er ror', { | |
| 789 | hmpB atchSize: 1, | |
| 790 | data : null, | |
| 791 | rawR esponse: ' some text here...', | |
| 792 | erro rData: { m essage: 'I nvalid JSO N with hmp BatchSize = 1'} | |
| 793 | }); | |
| 794 | expect(p ollerFakeI nstance._h andleInval idJSONWith SingleMess age.calls. length).to Equal(1); | |
| 795 | }) ; | |
| 796 | it ('Happy Pa th - Singl e Poller M ode, Error on batch with > 1 b atch size' , function () { | |
| 797 | var poll erFakeInst ance = { | |
| 798 | vist aId: '9E7A ', | |
| 799 | envi ronment: e nvironment , | |
| 800 | conf ig: config , | |
| 801 | metr ics: dummy Logger, | |
| 802 | log: dummyLogg er, | |
| 803 | paus ed: false, | |
| 804 | read yToShutdow n: false, | |
| 805 | allo cationToke n: '', | |
| 806 | allo cationStat us: 'compl ete', | |
| 807 | mult ipleMode: false, | |
| 808 | erro rPublisher : errorPub lisher, | |
| 809 | poll DelayMilli s: 1000, | |
| 810 | last UpdateTime : '0', | |
| 811 | vprU pdateOpDat a: null, | |
| 812 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 813 | isVi staHdr: fa lse, | |
| 814 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 815 | succ ess: false , | |
| 816 | _han dleBatchEr rorGeneral : function (error) { | |
| 817 | expect(err or).toBeDe fined(); | |
| 818 | return; | |
| 819 | } | |
| 820 | }; | |
| 821 | spyOn(po llerFakeIn stance, '_ handleBatc hErrorGene ral').andC allThrough (); | |
| 822 | ||
| 823 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"lastU pdate\" : \"3150721- 11303\",\" items\":[{ },{}]}}'; | |
| 824 | Poller.p rototype._ processRes ponse.call (pollerFak eInstance, 'Some err or', { | |
| 825 | hmpB atchSize: 1000, | |
| 826 | data : JSON.par se(rawResp onse).data , | |
| 827 | rawR esponse: n ull | |
| 828 | }); | |
| 829 | expect(p ollerFakeI nstance._h andleBatch ErrorGener al.calls.l ength).toE qual(1); | |
| 830 | }) ; | |
| 831 | it ('Happy Pa th - Singl e Poller M ode, with data', fun ction () { | |
| 832 | var poll erFakeInst ance = { | |
| 833 | vist aId: '9E7A ', | |
| 834 | envi ronment: e nvironment , | |
| 835 | conf ig: config , | |
| 836 | log: dummyLogg er, | |
| 837 | metr ics: dummy Logger, | |
| 838 | paus ed: false, | |
| 839 | read yToShutdow n: false, | |
| 840 | allo cationToke n: '', | |
| 841 | allo cationStat us: 'compl ete', | |
| 842 | mult ipleMode: false, | |
| 843 | erro rPublisher : errorPub lisher, | |
| 844 | poll DelayMilli s: 1000, | |
| 845 | last UpdateTime : '0', | |
| 846 | vprU pdateOpDat a: null, | |
| 847 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 848 | isVi staHdr: fa lse, | |
| 849 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 850 | succ ess: false , | |
| 851 | _han dleBatchSu ccess: fun ction (wra ppedRespon se) { | |
| 852 | expect(wra ppedRespon se).toBeDe fined(); | |
| 853 | return; | |
| 854 | } | |
| 855 | }; | |
| 856 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"lastU pdate\" : \"3150721- 11303\",\" items\":[{ },{}]}}'; | |
| 857 | spyOn(po llerFakeIn stance, '_ handleBatc hSuccess') .andCallTh rough(); | |
| 858 | Poller.p rototype._ processRes ponse.call (pollerFak eInstance, null, { | |
| 859 | hmpB atchSize: 200, | |
| 860 | data : JSON.par se(rawResp onse).data | |
| 861 | }); | |
| 862 | expect(p ollerFakeI nstance._h andleBatch Success.ca lls.length ).toEqual( 1); | |
| 863 | }) ; | |
| 864 | }); | |
| 865 | ||
| 866 | descri be('_handl eInvalidJS ONWithSing leMessage' , function () { | |
| 867 | it ('JSON par sing error - single poller mod e', functi on() { | |
| 868 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 869 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 870 | ||
| 871 | var poll erFakeInst ance = { | |
| 872 | vist aId: '9E7A ', | |
| 873 | envi ronment: e nvironment , | |
| 874 | conf ig: config , | |
| 875 | log: dummyLogg er, | |
| 876 | metr ics: dummy Logger, | |
| 877 | paus ed: false, | |
| 878 | read yToShutdow n: false, | |
| 879 | allo cationToke n: '', | |
| 880 | allo cationStat us: 'compl ete', | |
| 881 | mult ipleMode: false, | |
| 882 | erro rPublisher : errorPub lisher, | |
| 883 | poll DelayMilli s: 1000, | |
| 884 | last UpdateTime : '0', | |
| 885 | vprU pdateOpDat a: null, | |
| 886 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 887 | isVi staHdr: fa lse, | |
| 888 | hmpB atchSize: '200', | |
| 889 | _sto reLastUpda teTime: fu nction(dat a, callbac k) { | |
| 890 | expect(dat a.lastUpda te).toEqua l('3150721 -11303'); | |
| 891 | complete++ ; | |
| 892 | callback(n ull, 'no d ata'); | |
| 893 | }, | |
| 894 | getB atchSize: function() { | |
| 895 | return con fig['hmp.b atch.size' ]; | |
| 896 | }, | |
| 897 | _ext ractLastUp dateFromRa wResponse: poller._e xtractLast UpdateFrom RawRespons e.bind(thi s) | |
| 898 | }; | |
| 899 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 900 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"lastU pdate\" : \"3150721- 11303\",\" items\":[{ \"name\":} ]}}'; | |
| 901 | var comp lete = 0; | |
| 902 | pollerFa keInstance .doNext = function() { | |
| 903 | comp lete++; | |
| 904 | }; | |
| 905 | runs(fun ction() { | |
| 906 | Poll er.prototy pe._handle InvalidJSO NWithSingl eMessage.c all(poller FakeInstan ce, 'parsi ng error', { | |
| 907 | hmpBatchSi ze: 1, | |
| 908 | rawRespons e: rawResp onse | |
| 909 | }); | |
| 910 | }); | |
| 911 | waitsFor (function( ) { | |
| 912 | retu rn complet e >= 2; | |
| 913 | }, 'Proc essing Vis ta Respons e'); | |
| 914 | runs(fun ction() { | |
| 915 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 916 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 917 | }); | |
| 918 | }) ; | |
| 919 | it ('JSON par sing error for Vista Hdr - sing le poller mode', fun ction() { | |
| 920 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 921 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 922 | ||
| 923 | var poll erFakeInst ance = { | |
| 924 | vist aId: '84F0 ', | |
| 925 | envi ronment: e nvironment , | |
| 926 | conf ig: config , | |
| 927 | log: dummyLogg er, | |
| 928 | metr ics: dummy Logger, | |
| 929 | paus ed: false, | |
| 930 | read yToShutdow n: false, | |
| 931 | allo cationToke n: '', | |
| 932 | allo cationStat us: 'compl ete', | |
| 933 | mult ipleMode: false, | |
| 934 | erro rPublisher : errorPub lisher, | |
| 935 | poll DelayMilli s: 1000, | |
| 936 | last UpdateTime : '0', | |
| 937 | vprU pdateOpDat a: null, | |
| 938 | isVi staHdr: tr ue, | |
| 939 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 940 | hmpB atchSize: config.hdr .pubsubCon fig.maxBat chSize, | |
| 941 | _sto reLastUpda teTime: fu nction(dat a, callbac k) { | |
| 942 | expect(dat a.lastUpda te).toEqua l('3150721 -11303'); | |
| 943 | complete++ ; | |
| 944 | callback(n ull, 'no d ata'); | |
| 945 | }, | |
| 946 | getB atchSize: function() { | |
| 947 | return con fig.hdr.pu bsubConfig .maxBatchS ize; | |
| 948 | }, | |
| 949 | _ext ractLastUp dateFromRa wResponse: poller._e xtractLast UpdateFrom RawRespons e.bind(thi s) | |
| 950 | }; | |
| 951 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 952 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"RA PHAEL.VIST ACORE.US\" ,\"systemI d\":\"84F0 \"},\"data \":{\"upda ted\":\"20 1507211205 12\",\"tot alItems\": 1000,\"las tUpdate\" : \"315072 1-11303\", "items\": [{\"name\" :}]}}'; | |
| 953 | var comp lete = 0; | |
| 954 | pollerFa keInstance .doNext = function() { | |
| 955 | comp lete++; | |
| 956 | }; | |
| 957 | runs(fun ction() { | |
| 958 | Poll er.prototy pe._handle InvalidJSO NWithSingl eMessage.c all(poller FakeInstan ce, 'parsi ng error', { | |
| 959 | hmpBatchSi ze: 1, | |
| 960 | rawRespons e: rawResp onse | |
| 961 | }); | |
| 962 | }); | |
| 963 | waitsFor (function( ) { | |
| 964 | retu rn complet e >= 2; | |
| 965 | }, 'Proc essing Vis ta Respons e'); | |
| 966 | runs(fun ction() { | |
| 967 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 968 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config .hdr.pubsu bConfig.ma xBatchSize ); | |
| 969 | }); | |
| 970 | }) ; | |
| 971 | it ('JSON par sing error AND error storing l astUpdateT ime - Sing le Poller Mode', fun ction() { | |
| 972 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 973 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 974 | ||
| 975 | var poll erFakeInst ance = { | |
| 976 | vist aId: '9E7A ', | |
| 977 | envi ronment: e nvironment , | |
| 978 | conf ig: config , | |
| 979 | log: dummyLogg er, | |
| 980 | metr ics: dummy Logger, | |
| 981 | paus ed: false, | |
| 982 | read yToShutdow n: false, | |
| 983 | allo cationToke n: '', | |
| 984 | allo cationStat us: 'compl ete', | |
| 985 | mult ipleMode: false, | |
| 986 | erro rPublisher : errorPub lisher, | |
| 987 | poll DelayMilli s: 1000, | |
| 988 | last UpdateTime : '0', | |
| 989 | vprU pdateOpDat a: null, | |
| 990 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 991 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 992 | isVi staHdr: fa lse, | |
| 993 | _sto reLastUpda teTime: fu nction(dat a, callbac k){ | |
| 994 | complete++ ; | |
| 995 | callback(' ERROR', nu ll); | |
| 996 | }, | |
| 997 | getB atchSize: function() { | |
| 998 | return con fig['hmp.b atch.size' ]; | |
| 999 | }, | |
| 1000 | _ext ractLastUp dateFromRa wResponse: poller._e xtractLast UpdateFrom RawRespons e.bind(thi s) | |
| 1001 | }; | |
| 1002 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1003 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"lastU pdate\" : \"3150721- 11303\",\" items\":[{ \"name\":} ]}}'; | |
| 1004 | var comp lete = 0; | |
| 1005 | pollerFa keInstance .doNext = function() { | |
| 1006 | comp lete++; | |
| 1007 | }; | |
| 1008 | runs(fun ction() { | |
| 1009 | Poll er.prototy pe._handle InvalidJSO NWithSingl eMessage.c all(poller FakeInstan ce, 'parsi ng error', { | |
| 1010 | hmpBatchSi ze: 1, | |
| 1011 | rawRespons e: rawResp onse | |
| 1012 | }); | |
| 1013 | }); | |
| 1014 | waitsFor (function( ) { | |
| 1015 | retu rn complet e >=2; | |
| 1016 | }, 'Proc essing Vis ta Respons e'); | |
| 1017 | runs(fun ction(){ | |
| 1018 | expe ct(errorPu blisher.pu blishPolle rError.cal ls.length) .toEqual(2 ); | |
| 1019 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1020 | }); | |
| 1021 | }) ; | |
| 1022 | it ('JSON par sing error - multipl e poller m ode', func tion() { | |
| 1023 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 1024 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 1025 | ||
| 1026 | var poll erFakeInst ance = { | |
| 1027 | vist aId: '9E7A ', | |
| 1028 | envi ronment: e nvironment , | |
| 1029 | conf ig: config , | |
| 1030 | log: dummyLogg er, | |
| 1031 | metr ics: dummy Logger, | |
| 1032 | paus ed: false, | |
| 1033 | read yToShutdow n: false, | |
| 1034 | allo cationToke n: '', | |
| 1035 | allo cationStat us: 'compl ete', | |
| 1036 | mult ipleMode: true, | |
| 1037 | erro rPublisher : errorPub lisher, | |
| 1038 | poll DelayMilli s: 1000, | |
| 1039 | last UpdateTime : '0', | |
| 1040 | vprU pdateOpDat a: null, | |
| 1041 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1042 | isVi staHdr: fa lse, | |
| 1043 | hmpB atchSize: '200', | |
| 1044 | getB atchSize: function() { | |
| 1045 | return con fig['hmp.b atch.size' ]; | |
| 1046 | } | |
| 1047 | }; | |
| 1048 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1049 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"alloc ationToken \" : \"123 456789\",\ "items\":[ {\"name\": }]}}'; | |
| 1050 | var comp lete = 0; | |
| 1051 | pollerFa keInstance .doNext = function() { | |
| 1052 | comp lete++; | |
| 1053 | }; | |
| 1054 | runs(fun ction() { | |
| 1055 | Poll er.prototy pe._handle InvalidJSO NWithSingl eMessage.c all(poller FakeInstan ce, 'parsi ng error', { | |
| 1056 | hmpBatchSi ze: 1, | |
| 1057 | rawRespons e: rawResp onse | |
| 1058 | }); | |
| 1059 | }); | |
| 1060 | waitsFor (function( ) { | |
| 1061 | retu rn complet e >= 1; | |
| 1062 | }, 'Proc essing Vis ta Respons e'); | |
| 1063 | runs(fun ction() { | |
| 1064 | expe ct(pollerF akeInstanc e.allocati onToken).t oBe('12345 6789'); | |
| 1065 | expe ct(pollerF akeInstanc e.allocati onStatus). toBe('reje cted'); | |
| 1066 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1067 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1068 | }); | |
| 1069 | }) ; | |
| 1070 | it ('JSON par sing error and failu re to extr act alloca tion token - multipl e poller m ode', func tion() { | |
| 1071 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 1072 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 1073 | ||
| 1074 | var poll erFakeInst ance = { | |
| 1075 | vist aId: '9E7A ', | |
| 1076 | envi ronment: e nvironment , | |
| 1077 | conf ig: config , | |
| 1078 | log: dummyLogg er, | |
| 1079 | metr ics: dummy Logger, | |
| 1080 | paus ed: false, | |
| 1081 | read yToShutdow n: false, | |
| 1082 | allo cationToke n: '', | |
| 1083 | allo cationStat us: 'compl ete', | |
| 1084 | mult ipleMode: true, | |
| 1085 | erro rPublisher : errorPub lisher, | |
| 1086 | poll DelayMilli s: 1000, | |
| 1087 | last UpdateTime : '0', | |
| 1088 | vprU pdateOpDat a: null, | |
| 1089 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1090 | isVi staHdr: fa lse, | |
| 1091 | hmpB atchSize: '200', | |
| 1092 | getB atchSize: function() { | |
| 1093 | return con fig['hmp.b atch.size' ]; | |
| 1094 | } | |
| 1095 | }; | |
| 1096 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1097 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"alloc ationToken Junk\" : \ "123456789 \",\"items \":[{\"nam e\":}]}}'; | |
| 1098 | var comp lete = 0; | |
| 1099 | pollerFa keInstance .doNext = function() { | |
| 1100 | comp lete++; | |
| 1101 | }; | |
| 1102 | runs(fun ction() { | |
| 1103 | Poll er.prototy pe._handle InvalidJSO NWithSingl eMessage.c all(poller FakeInstan ce, 'parsi ng error', { | |
| 1104 | hmpBatchSi ze: 1, | |
| 1105 | rawRespons e: rawResp onse | |
| 1106 | }); | |
| 1107 | }); | |
| 1108 | waitsFor (function( ) { | |
| 1109 | retu rn complet e >= 1; | |
| 1110 | }, 'Proc essing Vis ta Respons e'); | |
| 1111 | runs(fun ction() { | |
| 1112 | expe ct(pollerF akeInstanc e.allocati onToken).t oBe(''); | |
| 1113 | expe ct(pollerF akeInstanc e.allocati onStatus). toBe('comp lete'); | |
| 1114 | expe ct(errorPu blisher.pu blishPolle rError.cal ls.length) .toEqual(2 ); | |
| 1115 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1116 | }); | |
| 1117 | }) ; | |
| 1118 | }); | |
| 1119 | ||
| 1120 | descri be('_handl eBatchErro rGeneral', function( ) { | |
| 1121 | it ('Non JSON parsing e rror - Sin gle Poller Mode', fu nction() { | |
| 1122 | var poll erFakeInst ance = { | |
| 1123 | vist aId: '9E7A ', | |
| 1124 | envi ronment: e nvironment , | |
| 1125 | conf ig: config , | |
| 1126 | log: dummyLogg er, | |
| 1127 | metr ics: dummy Logger, | |
| 1128 | paus ed: false, | |
| 1129 | read yToShutdow n: false, | |
| 1130 | allo cationToke n: '123456 789', | |
| 1131 | allo cationStat us: 'rejec ted', | |
| 1132 | mult ipleMode: false, | |
| 1133 | erro rPublisher : errorPub lisher, | |
| 1134 | poll DelayMilli s: 1000, | |
| 1135 | last UpdateTime : '0', | |
| 1136 | vprU pdateOpDat a: null, | |
| 1137 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1138 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1139 | isVi staHdr: fa lse, | |
| 1140 | last BatchError s: {}, | |
| 1141 | getB atchSize: function() { | |
| 1142 | return con fig['hmp.b atch.size' ]; | |
| 1143 | } | |
| 1144 | }; | |
| 1145 | pollerFa keInstance ._updateLa stBatchErr orPublishT ime = Poll er.prototy pe._update LastBatchE rrorPublis hTime.bind (pollerFak eInstance) ; | |
| 1146 | pollerFa keInstance ._isErrorP ublishNeed ed = Polle r.prototyp e._isError PublishNee ded.bind(p ollerFakeI nstance); | |
| 1147 | ||
| 1148 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1149 | spyOn(en vironment. metrics, ' warn').and CallThroug h(); | |
| 1150 | var comp lete = fal se; | |
| 1151 | pollerFa keInstance .doNext = function() { | |
| 1152 | comp lete = tru e; | |
| 1153 | }; | |
| 1154 | runs(fun ction() { | |
| 1155 | Poll er.prototy pe._handle BatchError General.ca ll(pollerF akeInstanc e, 'Random error fro m Vista', { | |
| 1156 | hmpBatchSi ze: 1, | |
| 1157 | data: null , | |
| 1158 | rawRespons e: 'some t ext here.. .', | |
| 1159 | errorData: { message : 'RPC Err or'} | |
| 1160 | }); | |
| 1161 | }); | |
| 1162 | waitsFor (function( ) { | |
| 1163 | retu rn complet e; | |
| 1164 | }, 'Proc essing Vis ta Respons e'); | |
| 1165 | runs(fun ction() { | |
| 1166 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1167 | expe ct(environ ment.metri cs.warn).t oHaveBeenC alled(); | |
| 1168 | expe ct(pollerF akeInstanc e.success) .toBe(fals e); | |
| 1169 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1170 | }); | |
| 1171 | }) ; | |
| 1172 | it ('Non JSON parsing e rror for V istaHdr', function() { | |
| 1173 | var poll erFakeInst ance = { | |
| 1174 | vist aId: '84F0 ', | |
| 1175 | envi ronment: e nvironment , | |
| 1176 | conf ig: config , | |
| 1177 | log: dummyLogg er, | |
| 1178 | metr ics: dummy Logger, | |
| 1179 | paus ed: false, | |
| 1180 | read yToShutdow n: false, | |
| 1181 | allo cationToke n: '123456 789', | |
| 1182 | allo cationStat us: 'rejec ted', | |
| 1183 | mult ipleMode: false, | |
| 1184 | erro rPublisher : errorPub lisher, | |
| 1185 | poll DelayMilli s: 1000, | |
| 1186 | last UpdateTime : '0', | |
| 1187 | vprU pdateOpDat a: null, | |
| 1188 | isVi staHdr: tr ue, | |
| 1189 | last BatchError s: {}, | |
| 1190 | hmpB atchSize: config.hdr .pubsubCon fig.maxBat chSize, | |
| 1191 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1192 | getB atchSize: function() { | |
| 1193 | return con fig.hdr.pu bsubConfig .maxBatchS ize; | |
| 1194 | } | |
| 1195 | }; | |
| 1196 | pollerFa keInstance ._updateLa stBatchErr orPublishT ime = Poll er.prototy pe._update LastBatchE rrorPublis hTime.bind (pollerFak eInstance) ; | |
| 1197 | pollerFa keInstance ._isErrorP ublishNeed ed = Polle r.prototyp e._isError PublishNee ded.bind(p ollerFakeI nstance); | |
| 1198 | ||
| 1199 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1200 | spyOn(en vironment. metrics, ' warn').and CallThroug h(); | |
| 1201 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"RA PHAEL.VIST ACORE.US\" ,\"systemI d\":\"84F0 \"},\"data \":{\"upda ted\":\"20 1507211205 12\",\"tot alItems\": 1000,\"las tUpdate\" : \"315072 1-11303\"} }'; | |
| 1202 | var comp lete = fal se; | |
| 1203 | pollerFa keInstance .doNext = function() { | |
| 1204 | comp lete = tru e; | |
| 1205 | }; | |
| 1206 | runs(fun ction() { | |
| 1207 | Poll er.prototy pe._handle BatchError General.ca ll(pollerF akeInstanc e, 'Random error fro m Vista', { | |
| 1208 | hmpBatchSi ze: 500, | |
| 1209 | data: JSON .parse(raw Response). data, | |
| 1210 | errorData: { message : 'An erro r occurred ' } | |
| 1211 | }); | |
| 1212 | }); | |
| 1213 | waitsFor (function( ) { | |
| 1214 | retu rn complet e; | |
| 1215 | }, 'Proc essing Vis ta Respons e'); | |
| 1216 | runs(fun ction() { | |
| 1217 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1218 | expe ct(environ ment.metri cs.warn).t oHaveBeenC alled(); | |
| 1219 | expe ct(pollerF akeInstanc e.success) .toBe(fals e); | |
| 1220 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config .hdr.pubsu bConfig.ma xBatchSize ); | |
| 1221 | }); | |
| 1222 | }) ; | |
| 1223 | it ('Non JSON parsing e rror (with out alloca tionToken) - Multipl e Poller M ode', func tion() { | |
| 1224 | var poll erFakeInst ance = { | |
| 1225 | vist aId: '9E7A ', | |
| 1226 | envi ronment: e nvironment , | |
| 1227 | conf ig: config , | |
| 1228 | log: dummyLogg er, | |
| 1229 | metr ics: dummy Logger, | |
| 1230 | paus ed: false, | |
| 1231 | read yToShutdow n: false, | |
| 1232 | allo cationToke n: '123456 789', | |
| 1233 | allo cationStat us: 'rejec ted', | |
| 1234 | mult ipleMode: true, | |
| 1235 | erro rPublisher : errorPub lisher, | |
| 1236 | poll DelayMilli s: 1000, | |
| 1237 | last UpdateTime : '0', | |
| 1238 | vprU pdateOpDat a: null, | |
| 1239 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1240 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1241 | isVi staHdr: fa lse, | |
| 1242 | last BatchError s: {}, | |
| 1243 | getB atchSize: function() { | |
| 1244 | return con fig['hmp.b atch.size' ]; | |
| 1245 | } | |
| 1246 | }; | |
| 1247 | pollerFa keInstance ._updateLa stBatchErr orPublishT ime = Poll er.prototy pe._update LastBatchE rrorPublis hTime.bind (pollerFak eInstance) ; | |
| 1248 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1249 | pollerFa keInstance ._isErrorP ublishNeed ed = Polle r.prototyp e._isError PublishNee ded.bind(p ollerFakeI nstance); | |
| 1250 | ||
| 1251 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1252 | spyOn(en vironment. metrics, ' warn').and CallThroug h(); | |
| 1253 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"RA PHAEL.VIST ACORE.US\" ,\"systemI d\":\"84F0 \"},\"data \":{\"upda ted\":\"20 1507211205 12\",\"tot alItems\": 1000,\"las tUpdate\" : \"315072 1-11303\"} }'; | |
| 1254 | var comp lete = fal se; | |
| 1255 | pollerFa keInstance .doNext = function() { | |
| 1256 | comp lete = tru e; | |
| 1257 | }; | |
| 1258 | runs(fun ction() { | |
| 1259 | Poll er.prototy pe._handle BatchError General.ca ll(pollerF akeInstanc e, 'Random error fro m Vista', { | |
| 1260 | hmpBatchSi ze: 500, | |
| 1261 | data: JSON .parse(raw Response). data, | |
| 1262 | errorData: { message : 'An erro r occurred ' } | |
| 1263 | }); | |
| 1264 | }); | |
| 1265 | waitsFor (function( ) { | |
| 1266 | retu rn complet e; | |
| 1267 | }, 'Proc essing Vis ta Respons e'); | |
| 1268 | runs(fun ction() { | |
| 1269 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1270 | expe ct(environ ment.metri cs.warn).t oHaveBeenC alled(); | |
| 1271 | expe ct(pollerF akeInstanc e.success) .toBe(fals e); | |
| 1272 | expe ct(pollerF akeInstanc e.allocati onToken).t oBe(''); | |
| 1273 | expe ct(pollerF akeInstanc e.allocati onStatus). toBe('comp lete'); | |
| 1274 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1275 | }); | |
| 1276 | }) ; | |
| 1277 | it ('Non JSON parsing e rror (with allocatio nToken) - Multiple P oller Mode ', functio n() { | |
| 1278 | var poll erFakeInst ance = { | |
| 1279 | vist aId: '9E7A ', | |
| 1280 | envi ronment: e nvironment , | |
| 1281 | conf ig: config , | |
| 1282 | log: dummyLogg er, | |
| 1283 | metr ics: dummy Logger, | |
| 1284 | paus ed: false, | |
| 1285 | read yToShutdow n: false, | |
| 1286 | allo cationToke n: '123456 789', | |
| 1287 | allo cationStat us: 'rejec ted', | |
| 1288 | mult ipleMode: true, | |
| 1289 | erro rPublisher : errorPub lisher, | |
| 1290 | poll DelayMilli s: 1000, | |
| 1291 | last UpdateTime : '0', | |
| 1292 | vprU pdateOpDat a: null, | |
| 1293 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1294 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1295 | isVi staHdr: fa lse, | |
| 1296 | last BatchError s: {}, | |
| 1297 | getB atchSize: function() { | |
| 1298 | return con fig['hmp.b atch.size' ]; | |
| 1299 | } | |
| 1300 | }; | |
| 1301 | pollerFa keInstance ._updateLa stBatchErr orPublishT ime = Poll er.prototy pe._update LastBatchE rrorPublis hTime.bind (pollerFak eInstance) ; | |
| 1302 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1303 | pollerFa keInstance ._isErrorP ublishNeed ed = Polle r.prototyp e._isError PublishNee ded.bind(p ollerFakeI nstance); | |
| 1304 | ||
| 1305 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1306 | spyOn(en vironment. metrics, ' warn').and CallThroug h(); | |
| 1307 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"RA PHAEL.VIST ACORE.US\" ,\"systemI d\":\"84F0 \"},\"data \":{\"allo cationToke n\":\"1234 56789\",\" updated\": \"20150721 120512\",\ "totalItem s\":1000,\ "lastUpdat e\" : \"31 50721-1130 3\"}}'; | |
| 1308 | var comp lete = fal se; | |
| 1309 | pollerFa keInstance .doNext = function() { | |
| 1310 | comp lete = tru e; | |
| 1311 | }; | |
| 1312 | runs(fun ction() { | |
| 1313 | Poll er.prototy pe._handle BatchError General.ca ll(pollerF akeInstanc e, 'Random error fro m Vista', { | |
| 1314 | hmpBatchSi ze: 500, | |
| 1315 | data: JSON .parse(raw Response). data, | |
| 1316 | errorData: { message : 'An erro r occurred ' } | |
| 1317 | }); | |
| 1318 | }); | |
| 1319 | waitsFor (function( ) { | |
| 1320 | retu rn complet e; | |
| 1321 | }, 'Proc essing Vis ta Respons e'); | |
| 1322 | runs(fun ction() { | |
| 1323 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1324 | expe ct(environ ment.metri cs.warn).t oHaveBeenC alled(); | |
| 1325 | expe ct(pollerF akeInstanc e.success) .toBe(fals e); | |
| 1326 | expe ct(pollerF akeInstanc e.allocati onToken).t oBe('12345 6789'); | |
| 1327 | expe ct(pollerF akeInstanc e.allocati onStatus). toBe('time out'); | |
| 1328 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1329 | }); | |
| 1330 | }) ; | |
| 1331 | it ('Error wi th no wrap pedRespons e returned - Multipl e Poller M ode', func tion() { | |
| 1332 | var poll erFakeInst ance = { | |
| 1333 | vist aId: '9E7A ', | |
| 1334 | envi ronment: e nvironment , | |
| 1335 | conf ig: config , | |
| 1336 | log: dummyLogg er, | |
| 1337 | metr ics: dummy Logger, | |
| 1338 | paus ed: false, | |
| 1339 | read yToShutdow n: false, | |
| 1340 | allo cationToke n: '123456 789', | |
| 1341 | allo cationStat us: 'rejec ted', | |
| 1342 | mult ipleMode: true, | |
| 1343 | erro rPublisher : errorPub lisher, | |
| 1344 | poll DelayMilli s: 1000, | |
| 1345 | last UpdateTime : '0', | |
| 1346 | vprU pdateOpDat a: null, | |
| 1347 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1348 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1349 | isVi staHdr: fa lse, | |
| 1350 | last BatchError s: {}, | |
| 1351 | getB atchSize: function() { | |
| 1352 | return con fig['hmp.b atch.size' ]; | |
| 1353 | } | |
| 1354 | }; | |
| 1355 | pollerFa keInstance ._updateLa stBatchErr orPublishT ime = Poll er.prototy pe._update LastBatchE rrorPublis hTime.bind (pollerFak eInstance) ; | |
| 1356 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1357 | pollerFa keInstance ._isErrorP ublishNeed ed = Polle r.prototyp e._isError PublishNee ded.bind(p ollerFakeI nstance); | |
| 1358 | ||
| 1359 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1360 | spyOn(en vironment. metrics, ' warn').and CallThroug h(); | |
| 1361 | spyOn(po llerFakeIn stance, '_ updateLast BatchError PublishTim e').andCal lThrough() ; | |
| 1362 | spyOn(po llerFakeIn stance, '_ isErrorPub lishNeeded ').andCall Through(); | |
| 1363 | var comp lete = fal se; | |
| 1364 | pollerFa keInstance .doNext = function() { | |
| 1365 | comp lete = tru e; | |
| 1366 | }; | |
| 1367 | runs(fun ction() { | |
| 1368 | Poll er.prototy pe._handle BatchError General.ca ll(pollerF akeInstanc e, 'Random error fro m Vista', null); | |
| 1369 | }); | |
| 1370 | waitsFor (function( ) { | |
| 1371 | retu rn complet e; | |
| 1372 | }, 'Proc essing Vis ta Respons e'); | |
| 1373 | runs(fun ction() { | |
| 1374 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1375 | expe ct(pollerF akeInstanc e._updateL astBatchEr rorPublish Time).not. toHaveBeen Called(); | |
| 1376 | expe ct(environ ment.metri cs.warn).t oHaveBeenC alled(); | |
| 1377 | expe ct(pollerF akeInstanc e.success) .toBe(fals e); | |
| 1378 | expe ct(pollerF akeInstanc e.allocati onToken).t oBe(''); | |
| 1379 | expe ct(pollerF akeInstanc e.allocati onStatus). toBe('comp lete'); | |
| 1380 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1381 | }); | |
| 1382 | }) ; | |
| 1383 | it ('Error wi th no erro rData in w rappedResp onse retur ned - Mult iple Polle r Mode', f unction() { | |
| 1384 | var poll erFakeInst ance = { | |
| 1385 | vist aId: '9E7A ', | |
| 1386 | envi ronment: e nvironment , | |
| 1387 | conf ig: config , | |
| 1388 | log: dummyLogg er, | |
| 1389 | metr ics: dummy Logger, | |
| 1390 | paus ed: false, | |
| 1391 | read yToShutdow n: false, | |
| 1392 | allo cationToke n: '123456 789', | |
| 1393 | allo cationStat us: 'rejec ted', | |
| 1394 | mult ipleMode: true, | |
| 1395 | erro rPublisher : errorPub lisher, | |
| 1396 | poll DelayMilli s: 1000, | |
| 1397 | last UpdateTime : '0', | |
| 1398 | vprU pdateOpDat a: null, | |
| 1399 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1400 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1401 | isVi staHdr: fa lse, | |
| 1402 | last BatchError s: {}, | |
| 1403 | getB atchSize: function() { | |
| 1404 | return con fig['hmp.b atch.size' ]; | |
| 1405 | } | |
| 1406 | }; | |
| 1407 | pollerFa keInstance ._updateLa stBatchErr orPublishT ime = Poll er.prototy pe._update LastBatchE rrorPublis hTime.bind (pollerFak eInstance) ; | |
| 1408 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1409 | pollerFa keInstance ._isErrorP ublishNeed ed = Polle r.prototyp e._isError PublishNee ded.bind(p ollerFakeI nstance); | |
| 1410 | ||
| 1411 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1412 | spyOn(en vironment. metrics, ' warn').and CallThroug h(); | |
| 1413 | spyOn(po llerFakeIn stance, '_ updateLast BatchError PublishTim e').andCal lThrough() ; | |
| 1414 | spyOn(po llerFakeIn stance, '_ isErrorPub lishNeeded ').andCall Through(); | |
| 1415 | var comp lete = fal se; | |
| 1416 | pollerFa keInstance .doNext = function() { | |
| 1417 | comp lete = tru e; | |
| 1418 | }; | |
| 1419 | runs(fun ction() { | |
| 1420 | Poll er.prototy pe._handle BatchError General.ca ll(pollerF akeInstanc e, 'Random error fro m Vista', {}); | |
| 1421 | }); | |
| 1422 | waitsFor (function( ) { | |
| 1423 | retu rn complet e; | |
| 1424 | }, 'Proc essing Vis ta Respons e'); | |
| 1425 | runs(fun ction() { | |
| 1426 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1427 | expe ct(pollerF akeInstanc e._updateL astBatchEr rorPublish Time).not. toHaveBeen Called(); | |
| 1428 | expe ct(environ ment.metri cs.warn).t oHaveBeenC alled(); | |
| 1429 | expe ct(pollerF akeInstanc e.success) .toBe(fals e); | |
| 1430 | expe ct(pollerF akeInstanc e.allocati onToken).t oBe(''); | |
| 1431 | expe ct(pollerF akeInstanc e.allocati onStatus). toBe('comp lete'); | |
| 1432 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1433 | }); | |
| 1434 | }) ; | |
| 1435 | it ('Error wi th no mess age in wra ppedRespon se.errorDa ta returne d - Multip le Poller Mode', fun ction() { | |
| 1436 | var poll erFakeInst ance = { | |
| 1437 | vist aId: '9E7A ', | |
| 1438 | envi ronment: e nvironment , | |
| 1439 | conf ig: config , | |
| 1440 | log: dummyLogg er, | |
| 1441 | metr ics: dummy Logger, | |
| 1442 | paus ed: false, | |
| 1443 | read yToShutdow n: false, | |
| 1444 | allo cationToke n: '123456 789', | |
| 1445 | allo cationStat us: 'rejec ted', | |
| 1446 | mult ipleMode: true, | |
| 1447 | erro rPublisher : errorPub lisher, | |
| 1448 | poll DelayMilli s: 1000, | |
| 1449 | last UpdateTime : '0', | |
| 1450 | vprU pdateOpDat a: null, | |
| 1451 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1452 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1453 | isVi staHdr: fa lse, | |
| 1454 | last BatchError s: {}, | |
| 1455 | getB atchSize: function() { | |
| 1456 | return con fig['hmp.b atch.size' ]; | |
| 1457 | } | |
| 1458 | }; | |
| 1459 | pollerFa keInstance ._updateLa stBatchErr orPublishT ime = Poll er.prototy pe._update LastBatchE rrorPublis hTime.bind (pollerFak eInstance) ; | |
| 1460 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1461 | pollerFa keInstance ._isErrorP ublishNeed ed = Polle r.prototyp e._isError PublishNee ded.bind(p ollerFakeI nstance); | |
| 1462 | ||
| 1463 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1464 | spyOn(en vironment. metrics, ' warn').and CallThroug h(); | |
| 1465 | spyOn(po llerFakeIn stance, '_ updateLast BatchError PublishTim e').andCal lThrough() ; | |
| 1466 | spyOn(po llerFakeIn stance, '_ isErrorPub lishNeeded ').andCall Through(); | |
| 1467 | var comp lete = fal se; | |
| 1468 | pollerFa keInstance .doNext = function() { | |
| 1469 | comp lete = tru e; | |
| 1470 | }; | |
| 1471 | runs(fun ction() { | |
| 1472 | Poll er.prototy pe._handle BatchError General.ca ll(pollerF akeInstanc e, 'Random error fro m Vista', { errorDat a: {}}); | |
| 1473 | }); | |
| 1474 | waitsFor (function( ) { | |
| 1475 | retu rn complet e; | |
| 1476 | }, 'Proc essing Vis ta Respons e'); | |
| 1477 | runs(fun ction() { | |
| 1478 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1479 | expe ct(pollerF akeInstanc e._updateL astBatchEr rorPublish Time).not. toHaveBeen Called(); | |
| 1480 | expe ct(environ ment.metri cs.warn).t oHaveBeenC alled(); | |
| 1481 | expe ct(pollerF akeInstanc e.success) .toBe(fals e); | |
| 1482 | expe ct(pollerF akeInstanc e.allocati onToken).t oBe(''); | |
| 1483 | expe ct(pollerF akeInstanc e.allocati onStatus). toBe('comp lete'); | |
| 1484 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1485 | }); | |
| 1486 | }) ; | |
| 1487 | it ('Error wh en _isErro rPublishNe eded retur ns false - Multiple Poller Mod e', functi on() { | |
| 1488 | var poll erFakeInst ance = { | |
| 1489 | vist aId: '9E7A ', | |
| 1490 | envi ronment: e nvironment , | |
| 1491 | conf ig: config , | |
| 1492 | log: dummyLogg er, | |
| 1493 | metr ics: dummy Logger, | |
| 1494 | paus ed: false, | |
| 1495 | read yToShutdow n: false, | |
| 1496 | allo cationToke n: '123456 789', | |
| 1497 | allo cationStat us: 'rejec ted', | |
| 1498 | mult ipleMode: true, | |
| 1499 | erro rPublisher : errorPub lisher, | |
| 1500 | poll DelayMilli s: 1000, | |
| 1501 | last UpdateTime : '0', | |
| 1502 | vprU pdateOpDat a: null, | |
| 1503 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1504 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1505 | isVi staHdr: fa lse, | |
| 1506 | last BatchError s: {}, | |
| 1507 | getB atchSize: function() { | |
| 1508 | return con fig['hmp.b atch.size' ]; | |
| 1509 | } | |
| 1510 | }; | |
| 1511 | pollerFa keInstance ._updateLa stBatchErr orPublishT ime = Poll er.prototy pe._update LastBatchE rrorPublis hTime.bind (pollerFak eInstance) ; | |
| 1512 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1513 | pollerFa keInstance ._isErrorP ublishNeed ed = Polle r.prototyp e._isError PublishNee ded.bind(p ollerFakeI nstance); | |
| 1514 | ||
| 1515 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1516 | spyOn(en vironment. metrics, ' warn').and CallThroug h(); | |
| 1517 | spyOn(po llerFakeIn stance, '_ updateLast BatchError PublishTim e').andCal lThrough() ; | |
| 1518 | spyOn(po llerFakeIn stance, '_ isErrorPub lishNeeded ').andCall Through(); | |
| 1519 | var comp lete = fal se; | |
| 1520 | pollerFa keInstance .doNext = function() { | |
| 1521 | comp lete = tru e; | |
| 1522 | }; | |
| 1523 | pollerFa keInstance .lastBatch Errors['RP C Error'] = moment() .subtract( 1000, 'sec onds'); | |
| 1524 | runs(fun ction() { | |
| 1525 | Poll er.prototy pe._handle BatchError General.ca ll(pollerF akeInstanc e, 'Random error fro m Vista', { errorDat a: {messag e: 'RPC Er ror'}}); | |
| 1526 | }); | |
| 1527 | waitsFor (function( ) { | |
| 1528 | retu rn complet e; | |
| 1529 | }, 'Proc essing Vis ta Respons e'); | |
| 1530 | runs(fun ction() { | |
| 1531 | expe ct(errorPu blisher.pu blishPolle rError).no t.toHaveBe enCalled() ; | |
| 1532 | expe ct(pollerF akeInstanc e._updateL astBatchEr rorPublish Time).not. toHaveBeen Called(); | |
| 1533 | expe ct(environ ment.metri cs.warn).t oHaveBeenC alled(); | |
| 1534 | expe ct(pollerF akeInstanc e.success) .toBe(fals e); | |
| 1535 | expe ct(pollerF akeInstanc e.allocati onToken).t oBe(''); | |
| 1536 | expe ct(pollerF akeInstanc e.allocati onStatus). toBe('comp lete'); | |
| 1537 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1538 | }); | |
| 1539 | }) ; | |
| 1540 | it ('Error wh en _isErro rPublishNe eded retur ns true - Multiple P oller Mode ', functio n() { | |
| 1541 | var poll erFakeInst ance = { | |
| 1542 | vist aId: '9E7A ', | |
| 1543 | envi ronment: e nvironment , | |
| 1544 | conf ig: config , | |
| 1545 | log: dummyLogg er, | |
| 1546 | metr ics: dummy Logger, | |
| 1547 | paus ed: false, | |
| 1548 | read yToShutdow n: false, | |
| 1549 | allo cationToke n: '123456 789', | |
| 1550 | allo cationStat us: 'rejec ted', | |
| 1551 | mult ipleMode: true, | |
| 1552 | erro rPublisher : errorPub lisher, | |
| 1553 | poll DelayMilli s: 1000, | |
| 1554 | last UpdateTime : '0', | |
| 1555 | vprU pdateOpDat a: null, | |
| 1556 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1557 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1558 | isVi staHdr: fa lse, | |
| 1559 | last BatchError s: {}, | |
| 1560 | getB atchSize: function() { | |
| 1561 | return con fig['hmp.b atch.size' ]; | |
| 1562 | } | |
| 1563 | }; | |
| 1564 | pollerFa keInstance ._updateLa stBatchErr orPublishT ime = Poll er.prototy pe._update LastBatchE rrorPublis hTime.bind (pollerFak eInstance) ; | |
| 1565 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1566 | pollerFa keInstance ._isErrorP ublishNeed ed = Polle r.prototyp e._isError PublishNee ded.bind(p ollerFakeI nstance); | |
| 1567 | ||
| 1568 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1569 | spyOn(en vironment. metrics, ' warn').and CallThroug h(); | |
| 1570 | spyOn(po llerFakeIn stance, '_ updateLast BatchError PublishTim e').andCal lThrough() ; | |
| 1571 | spyOn(po llerFakeIn stance, '_ isErrorPub lishNeeded ').andCall Through(); | |
| 1572 | var comp lete = fal se; | |
| 1573 | pollerFa keInstance .doNext = function() { | |
| 1574 | comp lete = tru e; | |
| 1575 | }; | |
| 1576 | pollerFa keInstance .lastBatch Errors['RP C Error'] = moment() .subtract( 2000, 'sec onds'); | |
| 1577 | runs(fun ction() { | |
| 1578 | Poll er.prototy pe._handle BatchError General.ca ll(pollerF akeInstanc e, 'Random error fro m Vista', { errorDat a: {messag e: 'RPC Er ror'}}); | |
| 1579 | }); | |
| 1580 | waitsFor (function( ) { | |
| 1581 | retu rn complet e; | |
| 1582 | }, 'Proc essing Vis ta Respons e'); | |
| 1583 | runs(fun ction() { | |
| 1584 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1585 | expe ct(pollerF akeInstanc e._updateL astBatchEr rorPublish Time).toHa veBeenCall ed(); | |
| 1586 | expe ct(environ ment.metri cs.warn).t oHaveBeenC alled(); | |
| 1587 | expe ct(pollerF akeInstanc e.success) .toBe(fals e); | |
| 1588 | expe ct(pollerF akeInstanc e.allocati onToken).t oBe(''); | |
| 1589 | expe ct(pollerF akeInstanc e.allocati onStatus). toBe('comp lete'); | |
| 1590 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1591 | }); | |
| 1592 | }) ; | |
| 1593 | }); | |
| 1594 | ||
| 1595 | descri be('_handl eBatchSucc ess', func tion() { | |
| 1596 | it ('Happy Pa th with va lid data', function( ) { | |
| 1597 | var poll erFakeInst ance = { | |
| 1598 | vist aId: '9E7A ', | |
| 1599 | envi ronment: e nvironment , | |
| 1600 | conf ig: config , | |
| 1601 | metr ics: dummy Logger, | |
| 1602 | log: dummyLogg er, | |
| 1603 | paus ed: false, | |
| 1604 | read yToShutdow n: false, | |
| 1605 | allo cationToke n: '', | |
| 1606 | allo cationStat us: 'compl ete', | |
| 1607 | mult ipleMode: false, | |
| 1608 | erro rPublisher : errorPub lisher, | |
| 1609 | poll DelayMilli s: 1000, | |
| 1610 | last UpdateTime : '0', | |
| 1611 | vprU pdateOpDat a: null, | |
| 1612 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1613 | isVi staHdr: fa lse, | |
| 1614 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1615 | succ ess: false , | |
| 1616 | _pro cessBatch: function( wrappedRes ponse, cal lback) { | |
| 1617 | expect(wra ppedRespon se).toBeDe fined(); | |
| 1618 | callback(n ull, []); | |
| 1619 | } | |
| 1620 | }; | |
| 1621 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1622 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"lastU pdate\" : \"3150721- 11303\",\" items\":[{ },{}]}}'; | |
| 1623 | var comp lete = fal se; | |
| 1624 | pollerFa keInstance .doNext = function() { | |
| 1625 | comp lete = tru e; | |
| 1626 | }; | |
| 1627 | spyOn(po llerFakeIn stance, '_ processBat ch').andCa llThrough( ); | |
| 1628 | runs(fun ction() { | |
| 1629 | Poll er.prototy pe._handle BatchSucce ss.call(po llerFakeIn stance, { | |
| 1630 | hmpBatchSi ze: 200, | |
| 1631 | data: JSON .parse(raw Response). data | |
| 1632 | }); | |
| 1633 | }); | |
| 1634 | waitsFor (function( ) { | |
| 1635 | retu rn complet e; | |
| 1636 | }, 'Proc essing Vis ta Respons e'); | |
| 1637 | runs(fun ction() { | |
| 1638 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(200); | |
| 1639 | expe ct(pollerF akeInstanc e._process Batch.call s.length). toEqual(1) ; | |
| 1640 | expe ct(errorPu blisher.pu blishPolle rError).no t.toHaveBe enCalled() ; | |
| 1641 | }); | |
| 1642 | }) ; | |
| 1643 | it ('Happy Pa th Happy P ath with v alid data for VistaH dr', funct ion() { | |
| 1644 | var poll erFakeInst ance = { | |
| 1645 | vist aId: '84F0 ', | |
| 1646 | envi ronment: e nvironment , | |
| 1647 | conf ig: config , | |
| 1648 | log: dummyLogg er, | |
| 1649 | paus ed: false, | |
| 1650 | read yToShutdow n: false, | |
| 1651 | allo cationToke n: '', | |
| 1652 | allo cationStat us: 'compl ete', | |
| 1653 | mult ipleMode: false, | |
| 1654 | erro rPublisher : errorPub lisher, | |
| 1655 | poll DelayMilli s: 1000, | |
| 1656 | last UpdateTime : '0', | |
| 1657 | succ ess: false , | |
| 1658 | vprU pdateOpDat a: null, | |
| 1659 | isVi staHdr: tr ue, | |
| 1660 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1661 | hmpB atchSize: config.hdr .pubsubCon fig.maxBat chSize, | |
| 1662 | _pro cessBatch: function( wrappedRes ponse, cal lback) { | |
| 1663 | expect(wra ppedRespon se).toBeDe fined(); | |
| 1664 | callback(n ull, []); | |
| 1665 | } | |
| 1666 | }; | |
| 1667 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1668 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"RA PHAEL.VIST ACORE.US\" ,\"systemI d\":\"84F0 \"},\"data \":{\"upda ted\":\"20 1507211205 12\",\"tot alItems\": 1000,\"las tUpdate\" : \"315072 1-11303\", \"items\": [{},{}]}}' ; | |
| 1669 | var comp lete = fal se; | |
| 1670 | pollerFa keInstance .doNext = function() { | |
| 1671 | comp lete = tru e; | |
| 1672 | }; | |
| 1673 | spyOn(po llerFakeIn stance, '_ processBat ch').andCa llThrough( ); | |
| 1674 | runs(fun ction() { | |
| 1675 | Poll er.prototy pe._handle BatchSucce ss.call(po llerFakeIn stance, { | |
| 1676 | hmpBatchSi ze: 200, | |
| 1677 | data: JSON .parse(raw Response). data | |
| 1678 | }); | |
| 1679 | }); | |
| 1680 | waitsFor (function( ) { | |
| 1681 | retu rn complet e; | |
| 1682 | }, 'Proc essing Vis taHdr Resp onse'); | |
| 1683 | runs(fun ction() { | |
| 1684 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(200); | |
| 1685 | expe ct(pollerF akeInstanc e._process Batch.call s.length). toEqual(1) ; | |
| 1686 | expe ct(errorPu blisher.pu blishPolle rError).no t.toHaveBe enCalled() ; | |
| 1687 | }); | |
| 1688 | }) ; | |
| 1689 | it ('Happy Pa th with em pty batch message an d allocati onToken. ( Multiple P oller Mode )', functi on() { | |
| 1690 | var poll erFakeInst ance = { | |
| 1691 | vist aId: '9E7A ', | |
| 1692 | envi ronment: e nvironment , | |
| 1693 | conf ig: config , | |
| 1694 | metr ics: dummy Logger, | |
| 1695 | log: dummyLogg er, | |
| 1696 | paus ed: false, | |
| 1697 | read yToShutdow n: false, | |
| 1698 | allo cationToke n: '', | |
| 1699 | allo cationStat us: 'compl ete', | |
| 1700 | mult ipleMode: true, | |
| 1701 | erro rPublisher : errorPub lisher, | |
| 1702 | poll DelayMilli s: 1000, | |
| 1703 | last UpdateTime : '0', | |
| 1704 | vprU pdateOpDat a: null, | |
| 1705 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1706 | isVi staHdr: fa lse, | |
| 1707 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1708 | succ ess: false , | |
| 1709 | _pro cessBatch: function( wrappedRes ponse, cal lback) { | |
| 1710 | expect(wra ppedRespon se).toBeDe fined(); | |
| 1711 | callback(n ull, []); | |
| 1712 | } | |
| 1713 | }; | |
| 1714 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1715 | ||
| 1716 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1717 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"alloca tionToken\ ":\"123456 78\",\"upd ated\":\"2 0150721120 512\",\"to talItems\" :0,\"lastU pdate\" : \"3150721- 11303\",\" items\":[] }}'; | |
| 1718 | var comp lete = fal se; | |
| 1719 | pollerFa keInstance .doNext = function() { | |
| 1720 | comp lete = tru e; | |
| 1721 | }; | |
| 1722 | spyOn(po llerFakeIn stance, '_ processBat ch').andCa llThrough( ); | |
| 1723 | runs(fun ction() { | |
| 1724 | Poll er.prototy pe._handle BatchSucce ss.call(po llerFakeIn stance, { | |
| 1725 | hmpBatchSi ze: 200, | |
| 1726 | data: JSON .parse(raw Response). data | |
| 1727 | }); | |
| 1728 | }); | |
| 1729 | waitsFor (function( ) { | |
| 1730 | retu rn complet e; | |
| 1731 | }, 'Proc essing Vis ta Respons e'); | |
| 1732 | runs(fun ction() { | |
| 1733 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(200); | |
| 1734 | expe ct(pollerF akeInstanc e.allocati onToken).t oEqual('12 345678'); | |
| 1735 | expe ct(pollerF akeInstanc e.allocati onStatus). toEqual('c omplete'); | |
| 1736 | }); | |
| 1737 | }) ; | |
| 1738 | it ('Happy Pa th with em pty batch message an d no alloc ationToken . (Multipl e Poller M ode)', fun ction() { | |
| 1739 | var poll erFakeInst ance = { | |
| 1740 | vist aId: '9E7A ', | |
| 1741 | envi ronment: e nvironment , | |
| 1742 | conf ig: config , | |
| 1743 | metr ics: dummy Logger, | |
| 1744 | log: dummyLogg er, | |
| 1745 | paus ed: false, | |
| 1746 | read yToShutdow n: false, | |
| 1747 | allo cationToke n: '', | |
| 1748 | allo cationStat us: 'compl ete', | |
| 1749 | mult ipleMode: true, | |
| 1750 | erro rPublisher : errorPub lisher, | |
| 1751 | poll DelayMilli s: 1000, | |
| 1752 | last UpdateTime : '0', | |
| 1753 | vprU pdateOpDat a: null, | |
| 1754 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1755 | isVi staHdr: fa lse, | |
| 1756 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1757 | succ ess: false , | |
| 1758 | _pro cessBatch: function( wrappedRes ponse, cal lback) { | |
| 1759 | expect(wra ppedRespon se).toBeDe fined(); | |
| 1760 | callback(n ull, []); | |
| 1761 | } | |
| 1762 | }; | |
| 1763 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1764 | ||
| 1765 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1766 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":0, \"lastUpda te\" : \"3 150721-113 03\",\"ite ms\":[]}}' ; | |
| 1767 | var comp lete = fal se; | |
| 1768 | pollerFa keInstance .doNext = function() { | |
| 1769 | comp lete = tru e; | |
| 1770 | }; | |
| 1771 | spyOn(po llerFakeIn stance, '_ processBat ch').andCa llThrough( ); | |
| 1772 | runs(fun ction() { | |
| 1773 | Poll er.prototy pe._handle BatchSucce ss.call(po llerFakeIn stance, { | |
| 1774 | hmpBatchSi ze: 200, | |
| 1775 | data: JSON .parse(raw Response). data | |
| 1776 | }); | |
| 1777 | }); | |
| 1778 | waitsFor (function( ) { | |
| 1779 | retu rn complet e; | |
| 1780 | }, 'Proc essing Vis ta Respons e'); | |
| 1781 | runs(fun ction() { | |
| 1782 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(200); | |
| 1783 | expe ct(pollerF akeInstanc e.allocati onToken).t oEqual('') ; | |
| 1784 | expe ct(pollerF akeInstanc e.allocati onStatus). toEqual('c omplete'); | |
| 1785 | }); | |
| 1786 | }) ; | |
| 1787 | it ('Happy Pa th with no data node . (Multipl e Poller M ode)', fun ction() { | |
| 1788 | var poll erFakeInst ance = { | |
| 1789 | vist aId: '9E7A ', | |
| 1790 | envi ronment: e nvironment , | |
| 1791 | conf ig: config , | |
| 1792 | metr ics: dummy Logger, | |
| 1793 | log: dummyLogg er, | |
| 1794 | paus ed: false, | |
| 1795 | read yToShutdow n: false, | |
| 1796 | allo cationToke n: '', | |
| 1797 | allo cationStat us: 'compl ete', | |
| 1798 | mult ipleMode: true, | |
| 1799 | erro rPublisher : errorPub lisher, | |
| 1800 | poll DelayMilli s: 1000, | |
| 1801 | last UpdateTime : '0', | |
| 1802 | vprU pdateOpDat a: null, | |
| 1803 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1804 | isVi staHdr: fa lse, | |
| 1805 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1806 | succ ess: false , | |
| 1807 | _pro cessBatch: function( wrappedRes ponse, cal lback) { | |
| 1808 | expect(wra ppedRespon se).toBeDe fined(); | |
| 1809 | callback(n ull, []); | |
| 1810 | } | |
| 1811 | }; | |
| 1812 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1813 | ||
| 1814 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1815 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" }}'; | |
| 1816 | var comp lete = fal se; | |
| 1817 | pollerFa keInstance .doNext = function() { | |
| 1818 | comp lete = tru e; | |
| 1819 | }; | |
| 1820 | spyOn(po llerFakeIn stance, '_ processBat ch').andCa llThrough( ); | |
| 1821 | runs(fun ction() { | |
| 1822 | Poll er.prototy pe._handle BatchSucce ss.call(po llerFakeIn stance, { | |
| 1823 | hmpBatchSi ze: 200, | |
| 1824 | data: JSON .parse(raw Response). data | |
| 1825 | }); | |
| 1826 | }); | |
| 1827 | waitsFor (function( ) { | |
| 1828 | retu rn complet e; | |
| 1829 | }, 'Proc essing Vis ta Respons e'); | |
| 1830 | runs(fun ction() { | |
| 1831 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(200); | |
| 1832 | expe ct(pollerF akeInstanc e.allocati onToken).t oEqual('') ; | |
| 1833 | expe ct(pollerF akeInstanc e.allocati onStatus). toEqual('c omplete'); | |
| 1834 | }); | |
| 1835 | }) ; | |
| 1836 | it ('Error Pa th with va lid data', function( ) { | |
| 1837 | var poll erFakeInst ance = { | |
| 1838 | vist aId: '9E7A ', | |
| 1839 | envi ronment: e nvironment , | |
| 1840 | conf ig: config , | |
| 1841 | metr ics: dummy Logger, | |
| 1842 | log: dummyLogg er, | |
| 1843 | paus ed: false, | |
| 1844 | read yToShutdow n: false, | |
| 1845 | allo cationToke n: '', | |
| 1846 | allo cationStat us: 'compl ete', | |
| 1847 | mult ipleMode: false, | |
| 1848 | erro rPublisher : errorPub lisher, | |
| 1849 | poll DelayMilli s: 1000, | |
| 1850 | last UpdateTime : '0', | |
| 1851 | vprU pdateOpDat a: null, | |
| 1852 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1853 | isVi staHdr: fa lse, | |
| 1854 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1855 | succ ess: false , | |
| 1856 | _pro cessBatch: function( wrappedRes ponse, cal lback) { | |
| 1857 | expect(wra ppedRespon se).toBeDe fined(); | |
| 1858 | callback(' ERROR', [] ); | |
| 1859 | } | |
| 1860 | }; | |
| 1861 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1862 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"lastU pdate\" : \"3150721- 11303\",\" items\":[{ },{}]}}'; | |
| 1863 | var comp lete = fal se; | |
| 1864 | pollerFa keInstance .doNext = function() { | |
| 1865 | comp lete = tru e; | |
| 1866 | }; | |
| 1867 | spyOn(po llerFakeIn stance, '_ processBat ch').andCa llThrough( ); | |
| 1868 | runs(fun ction() { | |
| 1869 | Poll er.prototy pe._handle BatchSucce ss.call(po llerFakeIn stance, { | |
| 1870 | hmpBatchSi ze: 200, | |
| 1871 | data: JSON .parse(raw Response). data | |
| 1872 | }); | |
| 1873 | }); | |
| 1874 | waitsFor (function( ) { | |
| 1875 | retu rn complet e; | |
| 1876 | }, 'Proc essing Vis ta Respons e'); | |
| 1877 | runs(fun ction() { | |
| 1878 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(200); | |
| 1879 | expe ct(pollerF akeInstanc e._process Batch.call s.length). toEqual(1) ; | |
| 1880 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1881 | }); | |
| 1882 | }) ; | |
| 1883 | it ('Error Pa th with va lid data ( Multiple P oller Mode )', functi on() { | |
| 1884 | var poll erFakeInst ance = { | |
| 1885 | vist aId: '9E7A ', | |
| 1886 | envi ronment: e nvironment , | |
| 1887 | conf ig: config , | |
| 1888 | metr ics: dummy Logger, | |
| 1889 | log: dummyLogg er, | |
| 1890 | paus ed: false, | |
| 1891 | read yToShutdow n: false, | |
| 1892 | allo cationToke n: '', | |
| 1893 | allo cationStat us: 'compl ete', | |
| 1894 | mult ipleMode: true, | |
| 1895 | erro rPublisher : errorPub lisher, | |
| 1896 | poll DelayMilli s: 1000, | |
| 1897 | last UpdateTime : '0', | |
| 1898 | vprU pdateOpDat a: null, | |
| 1899 | vist aProxy: ne w VistaCli entDummy(d ummyLogger , config), | |
| 1900 | isVi staHdr: fa lse, | |
| 1901 | hmpB atchSize: config['hm p.batch.si ze'], | |
| 1902 | succ ess: false , | |
| 1903 | _pro cessBatch: function( wrappedRes ponse, cal lback) { | |
| 1904 | expect(wra ppedRespon se).toBeDe fined(); | |
| 1905 | callback(' ERROR', [] ); | |
| 1906 | } | |
| 1907 | }; | |
| 1908 | pollerFa keInstance ._updateAl locationIn foSynchron ous = Poll er.prototy pe._update Allocation InfoSynchr onous.bind (pollerFak eInstance) ; | |
| 1909 | ||
| 1910 | spyOn(er rorPublish er, 'publi shPollerEr ror').andC allThrough (); | |
| 1911 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"alloca tionToken\ ":\"123456 789\",\"up dated\":\" 2015072112 0512\",\"t otalItems\ ":1000,\"l astUpdate\ " : \"3150 721-11303\ ",\"items\ ":[{},{}]} }'; | |
| 1912 | var comp lete = fal se; | |
| 1913 | pollerFa keInstance .doNext = function() { | |
| 1914 | comp lete = tru e; | |
| 1915 | }; | |
| 1916 | spyOn(po llerFakeIn stance, '_ processBat ch').andCa llThrough( ); | |
| 1917 | runs(fun ction() { | |
| 1918 | Poll er.prototy pe._handle BatchSucce ss.call(po llerFakeIn stance, { | |
| 1919 | hmpBatchSi ze: 200, | |
| 1920 | data: JSON .parse(raw Response). data | |
| 1921 | }); | |
| 1922 | }); | |
| 1923 | waitsFor (function( ) { | |
| 1924 | retu rn complet e; | |
| 1925 | }, 'Proc essing Vis ta Respons e'); | |
| 1926 | runs(fun ction() { | |
| 1927 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(200); | |
| 1928 | expe ct(pollerF akeInstanc e._process Batch.call s.length). toEqual(1) ; | |
| 1929 | expe ct(pollerF akeInstanc e.allocati onToken).t oBe('12345 6789'); | |
| 1930 | expe ct(pollerF akeInstanc e.allocati onStatus). toBe('time out'); | |
| 1931 | expe ct(errorPu blisher.pu blishPolle rError).to HaveBeenCa lled(); | |
| 1932 | }); | |
| 1933 | }) ; | |
| 1934 | it ('Reset ba tch size', function( ) { | |
| 1935 | var poll erFakeInst ance = { | |
| 1936 | vist aId: '9E7A ', | |
| 1937 | envi ronment: e nvironment , | |
| 1938 | conf ig: config , | |
| 1939 | log: dummyLogg er, | |
| 1940 | paus ed: false, | |
| 1941 | read yToShutdow n: false, | |
| 1942 | allo cationToke n: '', | |
| 1943 | allo cationStat us: 'compl ete', | |
| 1944 | mult ipleMode: false, | |
| 1945 | poll DelayMilli s: 1000, | |
| 1946 | last UpdateTime : '0', | |
| 1947 | erro rPublisher : errorPub lisher, | |
| 1948 | vprU pdateOpDat a: null, | |
| 1949 | isVi staHdr: fa lse, | |
| 1950 | succ ess: true, | |
| 1951 | hmpB atchSize: 200, | |
| 1952 | getB atchSize: function() { | |
| 1953 | return con fig['hmp.b atch.size' ]; | |
| 1954 | }, | |
| 1955 | _pro cessBatch: function( data, call back) { | |
| 1956 | expect(dat a).toBeDef ined(); | |
| 1957 | callback(' no data'); | |
| 1958 | } | |
| 1959 | }; | |
| 1960 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"KO DAK.VISTAC ORE.US\",\ "systemId\ ":\"C877\" },\"data\" :{\"update d\":\"2015 0721120512 \",\"total Items\":10 00,\"lastU pdate\" : \"3150721- 11303\",\" items\":[{ },{}]}}'; | |
| 1961 | var comp lete = fal se; | |
| 1962 | pollerFa keInstance .doNext = function() { | |
| 1963 | comp lete = tru e; | |
| 1964 | }; | |
| 1965 | spyOn(po llerFakeIn stance, '_ processBat ch').andCa llThrough( ); | |
| 1966 | runs(fun ction() { | |
| 1967 | Poll er.prototy pe._handle BatchSucce ss.call(po llerFakeIn stance, { | |
| 1968 | hmpBatchSi ze: 200, | |
| 1969 | data: JSON .parse(raw Response). data | |
| 1970 | }); | |
| 1971 | }); | |
| 1972 | waitsFor (function( ) { | |
| 1973 | retu rn complet e; | |
| 1974 | }, 'Proc essing Vis ta Respons e'); | |
| 1975 | runs(fun ction() { | |
| 1976 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config ['hmp.batc h.size']); | |
| 1977 | expe ct(pollerF akeInstanc e._process Batch.call s.length). toEqual(1) ; | |
| 1978 | }); | |
| 1979 | }) ; | |
| 1980 | it ('Reset ba tch size f or VistaHd r', functi on() { | |
| 1981 | var poll erFakeInst ance = { | |
| 1982 | vist aId: '84F0 ', | |
| 1983 | envi ronment: e nvironment , | |
| 1984 | conf ig: config , | |
| 1985 | log: dummyLogg er, | |
| 1986 | paus ed: false, | |
| 1987 | read yToShutdow n: false, | |
| 1988 | allo cationToke n: '', | |
| 1989 | allo cationStat us: 'compl ete', | |
| 1990 | mult ipleMode: false, | |
| 1991 | poll DelayMilli s: 1000, | |
| 1992 | last UpdateTime : '0', | |
| 1993 | erro rPublisher : errorPub lisher, | |
| 1994 | vprU pdateOpDat a: null, | |
| 1995 | succ ess: true, | |
| 1996 | hmpB atchSize: 500, | |
| 1997 | isVi staHdr: tr ue, | |
| 1998 | getB atchSize: function() { | |
| 1999 | return con fig.hdr.pu bsubConfig .maxBatchS ize; | |
| 2000 | }, | |
| 2001 | _pro cessBatch: function( data, call back) { | |
| 2002 | expect(dat a).toBeDef ined(); | |
| 2003 | callback(' no data'); | |
| 2004 | } | |
| 2005 | }; | |
| 2006 | var rawR esponse = '{\"apiVer sion\": 1. 02,\"param s\":{\"dom ain\":\"RA PHAEL.VIST ACORE.US\" ,\"systemI d\":\"84F0 \"},\"data \":{\"upda ted\":\"20 1507211205 12\",\"tot alItems\": 1000,\"las tUpdate\" : \"315072 1-11303\", \"items\": [{},{}]}}' ; | |
| 2007 | var comp lete = fal se; | |
| 2008 | pollerFa keInstance .doNext = function() { | |
| 2009 | comp lete = tru e; | |
| 2010 | }; | |
| 2011 | spyOn(po llerFakeIn stance, '_ processBat ch').andCa llThrough( ); | |
| 2012 | runs(fun ction() { | |
| 2013 | Poll er.prototy pe._handle BatchSucce ss.call(po llerFakeIn stance, { | |
| 2014 | hmpBatchSi ze: 200, | |
| 2015 | data: JSON .parse(raw Response). data | |
| 2016 | }); | |
| 2017 | }); | |
| 2018 | waitsFor (function( ) { | |
| 2019 | retu rn complet e; | |
| 2020 | }, 'Proc essing Vis taHdr Resp onse'); | |
| 2021 | runs(fun ction() { | |
| 2022 | expe ct(pollerF akeInstanc e.hmpBatch Size).toEq ual(config .hdr.pubsu bConfig.ma xBatchSize ); | |
| 2023 | expe ct(pollerF akeInstanc e._process Batch.call s.length). toEqual(1) ; | |
| 2024 | }); | |
| 2025 | }) ; | |
| 2026 | }); | |
| 2027 | ||
| 2028 | descri be('_creat eUnsolicit edUpdateJo bStatus()' , function () { | |
| 2029 | va r vistaId = 'AAAA'; | |
| 2030 | va r pid = 'A AAA;1'; | |
| 2031 | va r hdrPid = '84F0;1'; | |
| 2032 | va r pollerJo bId = '123 4'; | |
| 2033 | ||
| 2034 | it ('Happy Pa th', funct ion() { | |
| 2035 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 2036 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2037 | ||
| 2038 | var actu alError; | |
| 2039 | var actu alResponse ; | |
| 2040 | var call ed = false ; | |
| 2041 | spyOn(jd sClientDum my, 'saveJ obState'). andCallFak e(function (jobState, callback) {callback( null, {sta tusCode:20 0});}); | |
| 2042 | ||
| 2043 | poller._ createUnso licitedUpd ateJobStat us(vistaId , 'allergy ', pid, po llerJobId, environme nt.jobStat usUpdater, dummyLogg er, functi on(error, response) { | |
| 2044 | actu alError = error; | |
| 2045 | actu alResponse = respons e; | |
| 2046 | call ed = true; | |
| 2047 | }); | |
| 2048 | ||
| 2049 | waitsFor (function( ) { | |
| 2050 | retu rn called; | |
| 2051 | }, 'Call to _setJo bStatusToS tarted fai led to ret urn in tim e.', 500); | |
| 2052 | ||
| 2053 | runs(fun ction() { | |
| 2054 | expe ct(actualE rror).toBe Null(); | |
| 2055 | expe ct(environ ment.jobSt atusUpdate r.createJo bStatus.ca lls.length ).toEqual( 1); | |
| 2056 | expe ct(environ ment.jobSt atusUpdate r.createJo bStatus).t oHaveBeenC alledWith( jasmine.ob jectContai ning({ | |
| 2057 | type: 'vis ta-AAAA-da ta-allergy -poller', | |
| 2058 | patientIde ntifier: { | |
| 2059 | type: 'pid', | |
| 2060 | value: pid | |
| 2061 | }, | |
| 2062 | rootJobId: pollerJob Id, | |
| 2063 | jobId: pol lerJobId, | |
| 2064 | status: 'c reated', | |
| 2065 | timestamp: jasmine.a ny(String) | |
| 2066 | }), jasmine.an y(Function )); | |
| 2067 | }); | |
| 2068 | }) ; | |
| 2069 | it ('Happy Pa th For Vis tA HDR', f unction() { | |
| 2070 | var hdrP oller = cr eatePoller (dummyLogg er, hdrIdV alue, conf ig, enviro nment, fal se, false) ; | |
| 2071 | setupSpi es(jdsClie ntDummy, e nvironment , hdrPolle r, publish erRouterDu mmy); | |
| 2072 | ||
| 2073 | var actu alError; | |
| 2074 | var actu alResponse ; | |
| 2075 | var call ed = false ; | |
| 2076 | var hdrI d = '84F0' ; | |
| 2077 | spyOn(jd sClientDum my, 'saveJ obState'). andCallFak e(function (jobState, callback) {callback( null, {sta tusCode:20 0});}); | |
| 2078 | hdrPolle r._createU nsolicited UpdateJobS tatus(hdrI d, null, h drPid, pol lerJobId, environmen t.jobStatu sUpdater, dummyLogge r, functio n(error, r esponse) { | |
| 2079 | actu alError = error; | |
| 2080 | actu alResponse = respons e; | |
| 2081 | call ed = true; | |
| 2082 | }); | |
| 2083 | ||
| 2084 | waitsFor (function( ) { | |
| 2085 | retu rn called; | |
| 2086 | }, 'Call to _setJo bStatusToS tarted fai led to ret urn in tim e.', 500); | |
| 2087 | ||
| 2088 | runs(fun ction() { | |
| 2089 | expe ct(actualE rror).toBe Null(); | |
| 2090 | expe ct(environ ment.jobSt atusUpdate r.createJo bStatus.ca lls.length ).toEqual( 1); | |
| 2091 | expe ct(environ ment.jobSt atusUpdate r.createJo bStatus).t oHaveBeenC alledWith( jasmine.ob jectContai ning({ | |
| 2092 | type: 'vis tahdr-84F0 -data-poll er', | |
| 2093 | patientIde ntifier: { | |
| 2094 | type: 'pid', | |
| 2095 | value: hdrPid | |
| 2096 | }, | |
| 2097 | rootJobId: pollerJob Id, | |
| 2098 | jobId: pol lerJobId, | |
| 2099 | status: 'c reated', | |
| 2100 | timestamp: jasmine.a ny(String) | |
| 2101 | }), jasmine.an y(Function )); | |
| 2102 | }); | |
| 2103 | }) ; | |
| 2104 | }); | |
| 2105 | ||
| 2106 | descri be('_creat eJobsForUn solicitedU pdates()', function( ) { | |
| 2107 | va r unsolici tedUpdateS yncStart2 = { | |
| 2108 | collecti on: 'syncS tart', | |
| 2109 | pid: vis taIdValue + ';1', | |
| 2110 | metaStam p: { | |
| 2111 | stam pTime: '20 1501141151 26', | |
| 2112 | sour ceMetaStam p: { | |
| 2113 | 'C877': { | |
| 2114 | pid: v istaIdValu e + ';1', | |
| 2115 | localI d: '1', | |
| 2116 | stampT ime: '2015 0114115126 ', | |
| 2117 | domain MetaStamp: { | |
| 2118 | 'a llergy': { | |
| 2119 | domain: 'allergy', | |
| 2120 | stampTim e: '201501 14115126', | |
| 2121 | eventMet aStamp: { | |
| 2122 | 'urn :va:allerg y:C877:1:7 51': { | |
| 2123 | stampTime: '20150114 115126' | |
| 2124 | } | |
| 2125 | } | |
| 2126 | } | |
| 2127 | } | |
| 2128 | } | |
| 2129 | } | |
| 2130 | } | |
| 2131 | }; | |
| 2132 | ||
| 2133 | va r unsolici tedUpdateN oMetaStamp = { | |
| 2134 | collecti on: 'syncS tart', | |
| 2135 | pid: vis taIdValue + ';1', | |
| 2136 | }; | |
| 2137 | ||
| 2138 | va r noDomain MetaStamp = { | |
| 2139 | collecti on: 'syncS tart', | |
| 2140 | pid: vis taIdValue + ';1', | |
| 2141 | metaStam p: { | |
| 2142 | stam pTime: '20 1501141151 26', | |
| 2143 | sour ceMetaStam p: { | |
| 2144 | 'C877': { | |
| 2145 | pid: v istaIdValu e + ';1', | |
| 2146 | localI d: '1', | |
| 2147 | stampT ime: '2015 0114115126 ' | |
| 2148 | } | |
| 2149 | } | |
| 2150 | } | |
| 2151 | }; | |
| 2152 | ||
| 2153 | it ('Normal p ath', func tion() { | |
| 2154 | var done ; | |
| 2155 | ||
| 2156 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 2157 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2158 | ||
| 2159 | // Need a deep cop y so we ar e not modi fying our source inf ormation. | |
| 2160 | //------ ---------- ---------- ---------- ---------- ---------- --------- | |
| 2161 | var batc h = JSON.p arse(JSON. stringify( { | |
| 2162 | item s: [syncSt artJobsVal ue[0], uns olicitedUp dateSyncSt art2] | |
| 2163 | })); | |
| 2164 | ||
| 2165 | poller._ createJobs ForUnsolic itedUpdate s(batch, f unction(er ror, respo nse) { | |
| 2166 | done = true; | |
| 2167 | ||
| 2168 | expe ct(error). toBeFalsy( ); | |
| 2169 | expe ct(respons e).toBeTru thy(); | |
| 2170 | expe ct(batch.i tems[1].ro otJobId).t oBeDefined (); | |
| 2171 | expe ct(batch.i tems[1].jo bId).toBeD efined(); | |
| 2172 | expe ct(environ ment.jobSt atusUpdate r.createJo bStatus.ca lls.length ).toEqual( 1); | |
| 2173 | }); | |
| 2174 | ||
| 2175 | waitsFor (function( ) { | |
| 2176 | retu rn done; | |
| 2177 | }); | |
| 2178 | }) ; | |
| 2179 | ||
| 2180 | it ('Error pa th: missin g metastam p', functi on(){ | |
| 2181 | var done ; | |
| 2182 | ||
| 2183 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 2184 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2185 | ||
| 2186 | // Need a deep cop y so we ar e not modi fying our source inf ormation. | |
| 2187 | //------ ---------- ---------- ---------- ---------- ---------- --------- | |
| 2188 | var batc h = JSON.p arse(JSON. stringify( { | |
| 2189 | item s: [unsoli citedUpdat eNoMetaSta mp] | |
| 2190 | })); | |
| 2191 | ||
| 2192 | poller._ createJobs ForUnsolic itedUpdate s(batch, f unction(er ror, respo nse) { | |
| 2193 | done = true; | |
| 2194 | expe ct(error). toBeFalsy( ); | |
| 2195 | expe ct(environ ment.error Publisher. publishPol lerError). toHaveBeen Called(); | |
| 2196 | expe ct(respons e).toEqual ([]); | |
| 2197 | }); | |
| 2198 | ||
| 2199 | waitsFor (function( ) { | |
| 2200 | retu rn done; | |
| 2201 | }); | |
| 2202 | }) ; | |
| 2203 | ||
| 2204 | it ('Error pa th: no dom ain in met astamp', f unction(){ | |
| 2205 | var done ; | |
| 2206 | ||
| 2207 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, false); | |
| 2208 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2209 | ||
| 2210 | // Need a deep cop y so we ar e not modi fying our source inf ormation. | |
| 2211 | //------ ---------- ---------- ---------- ---------- ---------- --------- | |
| 2212 | var batc h = JSON.p arse(JSON. stringify( { | |
| 2213 | item s: [noDoma inMetaStam p] | |
| 2214 | })); | |
| 2215 | ||
| 2216 | poller._ createJobs ForUnsolic itedUpdate s(batch, f unction(er ror, respo nse) { | |
| 2217 | done = true; | |
| 2218 | expe ct(error). toBeFalsy( ); | |
| 2219 | expe ct(environ ment.error Publisher. publishPol lerError). toHaveBeen Called(); | |
| 2220 | expe ct(respons e).toEqual ([]); | |
| 2221 | }); | |
| 2222 | ||
| 2223 | waitsFor (function( ) { | |
| 2224 | retu rn done; | |
| 2225 | }); | |
| 2226 | }) ; | |
| 2227 | }); | |
| 2228 | ||
| 2229 | descri be('_updat eAllocatio nInfo()', function() { | |
| 2230 | it ('Happy Pa th', funct ion() { | |
| 2231 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, true); | |
| 2232 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2233 | ||
| 2234 | var fini shed = fal se; | |
| 2235 | var actu alError; | |
| 2236 | var actu alResponse ; | |
| 2237 | var loca lDataValue = JSON.pa rse(JSON.s tringify(d ataValue)) ; | |
| 2238 | localDat aValue.all ocationTok en = '1234 56789'; | |
| 2239 | runs(fun ction() { | |
| 2240 | ||
| 2241 | poll er._update Allocation Info(local DataValue, 'timeout' , function (error, re sponse) { | |
| 2242 | actualErro r = error; | |
| 2243 | actualResp onse = res ponse; | |
| 2244 | finished = true; | |
| 2245 | }); | |
| 2246 | }); | |
| 2247 | ||
| 2248 | waitsFor (function( ) { | |
| 2249 | retu rn finishe d; | |
| 2250 | }, 'Call to _updat eAllocatio nInfo fail ed to retu rn in time .', 500); | |
| 2251 | ||
| 2252 | runs(fun ction() { | |
| 2253 | expe ct(actualE rror).toBe Null(); | |
| 2254 | expe ct(actualR esponse).t oEqual('su ccess'); | |
| 2255 | expe ct(poller. allocation Token).toB e('1234567 89'); | |
| 2256 | expe ct(poller. allocation Status).to Be('timeou t'); | |
| 2257 | }); | |
| 2258 | }) ; | |
| 2259 | ||
| 2260 | it ('Missing allocation token', f unction() { | |
| 2261 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, true); | |
| 2262 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2263 | ||
| 2264 | var fini shed = fal se; | |
| 2265 | var actu alError; | |
| 2266 | var actu alResponse ; | |
| 2267 | var loca lDataValue = JSON.pa rse(JSON.s tringify(d ataValue)) ; | |
| 2268 | delete l ocalDataVa lue.alloca tionToken; | |
| 2269 | runs(fun ction() { | |
| 2270 | ||
| 2271 | poll er._update Allocation Info(local DataValue, 'complete ', functio n(error, r esponse) { | |
| 2272 | actualErro r = error; | |
| 2273 | actualResp onse = res ponse; | |
| 2274 | finished = true; | |
| 2275 | }); | |
| 2276 | }); | |
| 2277 | ||
| 2278 | waitsFor (function( ) { | |
| 2279 | retu rn finishe d; | |
| 2280 | }, 'Call to _updat eAllocatio nInfo fail ed to retu rn in time .', 500); | |
| 2281 | ||
| 2282 | runs(fun ction() { | |
| 2283 | expe ct(actualE rror).toBe Null(); | |
| 2284 | expe ct(actualR esponse).t oEqual('su ccess'); | |
| 2285 | expe ct(poller. allocation Token).toB e(''); | |
| 2286 | expe ct(poller. allocation Status).to Be('comple te'); | |
| 2287 | }); | |
| 2288 | }) ; | |
| 2289 | ||
| 2290 | ||
| 2291 | }); | |
| 2292 | ||
| 2293 | descri be('_updat eAllocatio nInfoSynch ronous()', function( ) { | |
| 2294 | it ('Happy Pa th', funct ion() { | |
| 2295 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, true); | |
| 2296 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2297 | ||
| 2298 | var loca lDataValue = JSON.pa rse(JSON.s tringify(d ataValue)) ; | |
| 2299 | localDat aValue.all ocationTok en = '1234 56789'; | |
| 2300 | poller._ updateAllo cationInfo Synchronou s(localDat aValue, 't imeout'); | |
| 2301 | expect(p oller.allo cationToke n).toBe('1 23456789') ; | |
| 2302 | expect(p oller.allo cationStat us).toBe(' timeout'); | |
| 2303 | }) ; | |
| 2304 | ||
| 2305 | it ('Missing allocation token', f unction() { | |
| 2306 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, true); | |
| 2307 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2308 | ||
| 2309 | var loca lDataValue = JSON.pa rse(JSON.s tringify(d ataValue)) ; | |
| 2310 | delete l ocalDataVa lue.alloca tionToken; | |
| 2311 | poller._ updateAllo cationInfo Synchronou s(localDat aValue, 't imeout'); | |
| 2312 | expect(p oller.allo cationToke n).toBe('' ); | |
| 2313 | expect(p oller.allo cationStat us).toBe(' complete') ; | |
| 2314 | }) ; | |
| 2315 | ||
| 2316 | ||
| 2317 | }); | |
| 2318 | ||
| 2319 | descri be('_updat eLastBatch ErrorPubli shTime()', function( ) { | |
| 2320 | it ('Happy Pa th', funct ion() { | |
| 2321 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, true); | |
| 2322 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2323 | ||
| 2324 | poller._ updateLast BatchError PublishTim e('1Error1 '); | |
| 2325 | var firs tPublishTi me = polle r.lastBatc hErrors['1 Error1']; | |
| 2326 | expect(f irstPublis hTime).toB eTruthy(); | |
| 2327 | poller._ updateLast BatchError PublishTim e('1Error1 '); | |
| 2328 | var seco ndPublishT ime = poll er.lastBat chErrors[' 1Error1']; | |
| 2329 | expect(s econdPubli shTime).to BeTruthy() ; | |
| 2330 | expect(f irstPublis hTime === secondPubl ishTime).t oBe(false) ; | |
| 2331 | }) ; | |
| 2332 | it ('Happy Pa th - two s eparate er rors', fun ction() { | |
| 2333 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, true); | |
| 2334 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2335 | ||
| 2336 | var erro r1PublishT ime = poll er.lastBat chErrors[' 1Error1']; | |
| 2337 | expect(e rror1Publi shTime).to BeFalsy(); | |
| 2338 | poller._ updateLast BatchError PublishTim e('1Error1 '); | |
| 2339 | error1Pu blishTime = poller.l astBatchEr rors['1Err or1']; | |
| 2340 | expect(e rror1Publi shTime).to BeTruthy() ; | |
| 2341 | ||
| 2342 | var erro r2PublishT ime = poll er.lastBat chErrors[' 2Error2']; | |
| 2343 | expect(e rror2Publi shTime).to BeFalsy(); | |
| 2344 | poller._ updateLast BatchError PublishTim e('2Error2 '); | |
| 2345 | error2Pu blishTime = poller.l astBatchEr rors['2Err or2']; | |
| 2346 | expect(e rror2Publi shTime).to BeTruthy() ; | |
| 2347 | ||
| 2348 | }) ; | |
| 2349 | }); | |
| 2350 | ||
| 2351 | descri be('_isErr orPublishN eeded()', function() { | |
| 2352 | it ('Happy Pa th when th e error ha s never be en logged before.', function() { | |
| 2353 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, true); | |
| 2354 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2355 | ||
| 2356 | var resu lt = polle r._isError PublishNee ded('1Erro r1'); | |
| 2357 | expect(r esult).toB e(true); | |
| 2358 | }) ; | |
| 2359 | ||
| 2360 | it ('Happy Pa th when th e error ha s been log ged and ou r time win dow has no t passed.' , function () { | |
| 2361 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, true); | |
| 2362 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2363 | ||
| 2364 | poller._ updateLast BatchError PublishTim e('1Error1 '); | |
| 2365 | var resu lt = polle r._isError PublishNee ded('1Erro r1'); | |
| 2366 | expect(r esult).toB e(false); | |
| 2367 | }) ; | |
| 2368 | ||
| 2369 | it ('Happy Pa th when th e error ha s been log ged and ou r time win dow has pa ssed.', fu nction() { | |
| 2370 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, confi g, environ ment, fals e, true); | |
| 2371 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2372 | ||
| 2373 | poller._ updateLast BatchError PublishTim e('1Error1 '); | |
| 2374 | poller.l astBatchEr rors['1Err or1'] = mo ment().sub tract(1801 , 'seconds '); | |
| 2375 | ||
| 2376 | var resu lt = polle r._isError PublishNee ded('1Erro r1'); | |
| 2377 | expect(r esult).toB e(true); | |
| 2378 | }) ; | |
| 2379 | it ('Happy Pa th when co nfig does not have a pollerIgn oreDuplica teErrorTim e value.', function( ) { | |
| 2380 | var loca lConfig = JSON.parse (JSON.stri ngify(conf ig)); | |
| 2381 | delete l ocalConfig .pollerIgn oreDuplica teErrorTim e; | |
| 2382 | var poll er = creat ePoller(du mmyLogger, vistaIdVa lue, local Config, en vironment, false, tr ue); | |
| 2383 | setupSpi es(jdsClie ntDummy, e nvironment , poller, publisherR outerDummy ); | |
| 2384 | ||
| 2385 | poller._ updateLast BatchError PublishTim e('1Error1 '); | |
| 2386 | poller.l astBatchEr rors['1Err or1'] = mo ment().sub tract(800, 'seconds' ); | |
| 2387 | ||
| 2388 | var resu lt = polle r._isError PublishNee ded('1Erro r1'); | |
| 2389 | expect(r esult).toB e(false); | |
| 2390 | ||
| 2391 | poller.l astBatchEr rors['1Err or1'] = mo ment().sub tract(910, 'seconds' ); | |
| 2392 | result = poller._i sErrorPubl ishNeeded( '1Error1') ; | |
| 2393 | expect(r esult).toB e(true); | |
| 2394 | }) ; | |
| 2395 | }); | |
| 2396 | ||
| 2397 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.