Produced by Araxis Merge on 10/3/2017 11:16:02 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\eventpriorityruleengine | event-priority-rules-engine-spec.js | Tue Jan 10 16:20:50 2017 UTC |
| 2 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\eventpriorityruleengine | event-priority-rules-engine-spec.js | Tue Oct 3 13:16:02 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 4 | 912 |
| Changed | 3 | 20 |
| 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 eve nt-priorit y-rules-en gine.js. | |
| 5 | // | |
| 6 | // Author: Les Westb erg | |
| 7 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------ | |
| 8 | ||
| 9 | require('. ./../../en v-setup'); | |
| 10 | var _ = re quire('und erscore'); | |
| 11 | var EventP riorityRul esEngine = require(g lobal.VX_E VENTPRIORI TYRULES + 'event-pri ority-rule s-engine') ; | |
| 12 | var JdsCli entDummy = require(g lobal.VX_D UMMIES + ' jds-client -dummy'); | |
| 13 | ||
| 14 | var log = require(gl obal.VX_DU MMIES + 'd ummy-logge r'); | |
| 15 | //-------- ---------- ---------- ---------- ---------- ---------- ---- | |
| 16 | // Uncomme nt the fol lowing to see the lo gging out on the scr een. | |
| 17 | //-------- ---------- ---------- ---------- ---------- ---------- ---- | |
| 18 | // var log Util = req uire(globa l.VX_UTILS + 'log'); | |
| 19 | // logUtil .initializ e([{ | |
| 20 | // nam e: 'root', | |
| 21 | // str eam: proce ss.stdout, | |
| 22 | // lev el: 'debug ' | |
| 23 | // }]); | |
| 24 | // log = l ogUtil.get ('test', ' debug'); | |
| 25 | //-------- ---------- ---------- ---------- ---- | |
| 26 | // End of logging st uff to com ment out.. .. | |
| 27 | //-------- ---------- ---------- ---------- ---- | |
| 28 | // log = r equire('bu nyan').cre ateLogger( { | |
| 29 | // na me: 'event -priority- rules-engi ne-spec', | |
| 30 | // le vel: 'debu g' | |
| 31 | // }); | |
| 32 | ||
| 33 | var hmpSer ver = 'The HmpServer' ; | |
| 34 | ||
| 35 | var config = { | |
| 36 | jd s: { | |
| 37 | prot ocol: 'htt p', | |
| 38 | host: ' IP ', | |
| 39 | port: REDACTED | |
| 40 | }, | |
| 41 | 'v istaSites' : { | |
| 42 | '9E7 A': { | |
| 43 | 'name' : 'panoram a', | |
| 44 | 'host': ' IP ', | |
| 45 | 'port': REDACTED , | |
| 46 | 'accessCod e': ' REDACT ', | |
| 47 | 'verifyCod e': ' REDACTED ', | |
| 48 | 'local IP': '127. 0.0.1', | |
| 49 | 'local Address': 'localhost ', | |
| 50 | 'conne ctTimeout' : 3000, | |
| 51 | 'sendT imeout': 1 0000 | |
| 52 | }, | |
| 53 | 'C87 7': { | |
| 54 | 'name' : 'kodak', | |
| 55 | 'host': ' IP ', | |
| 56 | 'port': REDACTED , | |
| 57 | 'accessCod e': ' REDACT ', | |
| 58 | 'verifyCod e': ' REDACTED ', | |
| 59 | 'local IP': '127. 0.0.1', | |
| 60 | 'local Address': 'localhost ', | |
| 61 | 'conne ctTimeout' : 3000, | |
| 62 | 'sendT imeout': 1 0000 | |
| 63 | } | |
| 64 | }, | |
| 65 | 'e ventPriori tizationRu les': { | |
| 66 | 'sit e-type': { }, | |
| 67 | 'dom ain-type': { | |
| 68 | 'consu lt': 20, | |
| 69 | 'aller gy': -20, | |
| 70 | 'order ': 40 | |
| 71 | } | |
| 72 | }, | |
| 73 | 'h mp.server. id': hmpSe rver, | |
| 74 | 'h mp.version ': '0.7-S6 5', | |
| 75 | 'h mp.batch.s ize': '100 0', | |
| 76 | 'h mp.extract .schema': '3.001', | |
| 77 | 'h dr': { | |
| 78 | 'ope rationMode ': 'REQ/RE S' | |
| 79 | } | |
| 80 | }; | |
| 81 | ||
| 82 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- - | |
| 83 | // Create an instanc e of the e nvironment variable. | |
| 84 | // | |
| 85 | // the_con fig: The config obj ect to be used in th e environm ent. | |
| 86 | // returns : The envi ronment th at was cre ated. | |
| 87 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- - | |
| 88 | function c reateEnvir onment(the _config) { | |
| 89 | va r environm ent = { | |
| 90 | jds: new JdsCl ientDummy( log, the_c onfig), | |
| 91 | metr ics: log | |
| 92 | }; | |
| 93 | ||
| 94 | sp yOn(enviro nment.jds, 'getJobSt atus').and CallThroug h(); | |
| 95 | ||
| 96 | re turn envir onment; | |
| 97 | } | |
| 98 | ||
| 99 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 100 | // Create an instanc e of the j ob and ret urn it. | |
| 101 | // | |
| 102 | // site: T he site to associate with this job. | |
| 103 | // priorit y: The pri ority to a ssociated with this job | |
| 104 | // dataDom ain: The d omain of d ata that r epresents this job. | |
| 105 | // returns : The crea ted job | |
| 106 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 107 | function c reateJob(s ite, prior ity, dataD omain) { | |
| 108 | va r job = { | |
| 109 | type : 'event-p rioritizat ion-reques t', | |
| 110 | pati entIdentif ier: { | |
| 111 | type: 'pid', | |
| 112 | value: site + '; 3' | |
| 113 | }, | |
| 114 | jpid : '8107cc4 1-69eb-406 0-8813-a82 db245a11a' , | |
| 115 | root JobId: '1' , | |
| 116 | data Domain: da taDomain, | |
| 117 | prio rity: prio rity, | |
| 118 | reco rd: {}, | |
| 119 | jobI d: '34' | |
| 120 | }; | |
| 121 | ||
| 122 | re turn job; | |
| 123 | ||
| 124 | } | |
| 125 | ||
| 126 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 127 | // Create an instanc e of the j ob status and return it. | |
| 128 | // | |
| 129 | // site: T he site to associate with this job statu s. | |
| 130 | // priorit y: The pri ority to a ssociated with this job status | |
| 131 | // returns : The crea ted job st atus | |
| 132 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 133 | function c reateJobSt atus(site, priority) { | |
| 134 | va r jobStatu s = { | |
| 135 | 'job Id': '4bbb 4574-68ab- 4fd0-9aaf- 5abf757654 49', | |
| 136 | 'jpi d': '15fbe f90-aed2-4 267-9f8b-9 80ad62c2a0 0', | |
| 137 | 'pat ientIdenti fier': { | |
| 138 | 'type' : 'pid', | |
| 139 | value: site + '; 3' | |
| 140 | }, | |
| 141 | prio rity: prio rity, | |
| 142 | 'roo tJobId': ' 4bbb4574-6 8ab-4fd0-9 aaf-5abf75 765449', | |
| 143 | 'sta tus': 'com pleted', | |
| 144 | 'tim estamp': ' 1458680891 151', | |
| 145 | 'typ e': 'enter prise-sync -request' | |
| 146 | }; | |
| 147 | ||
| 148 | re turn jobSt atus; | |
| 149 | ||
| 150 | } | |
| 151 | ||
| 152 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- -------- | |
| 153 | // Since w e are mock ing out JD S - and si nce each o f the call s to JDS f or this | |
| 154 | // unit te st are sim ilar. Thi s function sets up t he jds res ponse that should | |
| 155 | // be give n when JDS is called . | |
| 156 | // | |
| 157 | // environ ment: The environmen t object c ontaining the handle to JDS | |
| 158 | // jobStat us: The jo bStatus th at will be returned by JDS. | |
| 159 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- -------- | |
| 160 | function s etupDummyJ ds(environ ment, jobS tatus) { | |
| 161 | va r expected JdsError = [null]; | |
| 162 | va r expected JdsRespons e = [{ | |
| 163 | stat usCode: 20 0 | |
| 164 | }] ; | |
| 165 | va r expected JdsResult = [{ | |
| 166 | item s: [jobSta tus] | |
| 167 | }] ; | |
| 168 | en vironment. jds._setRe sponseData (expectedJ dsError, e xpectedJds Response, expectedJd sResult); | |
| 169 | } | |
| 170 | ||
| 171 | describe(' event-prio rity-rules -engine.js ', functio n() { | |
| 172 | de scribe('_g etRulesFro mConfig()' , function () { | |
| 173 | it(' Happy Path ', functio n() { | |
| 174 | ||
| 175 | var en vironment = createEn vironment( config); | |
| 176 | var ru lesEngine = new Even tPriorityR ulesEngine (log, conf ig, enviro nment); | |
| 177 | ||
| 178 | var ru lesFunctio ns = rules Engine._ge tRulesFrom Config(); | |
| 179 | expect (_.isArray (rulesFunc tions)).to Be(true); | |
| 180 | expect (rulesFunc tions.leng th).toBe(2 ); | |
| 181 | expect (_.isFunct ion(rulesF unctions[0 ])).toBe(t rue); | |
| 182 | expect (rulesFunc tions[0]). toBe(requi re(global. VX_EVENTPR IORITYRULE S + 'site- type-rule' )); | |
| 183 | expect (_.isFunct ion(rulesF unctions[1 ])).toBe(t rue); | |
| 184 | expect (rulesFunc tions[1]). toBe(requi re(global. VX_EVENTPR IORITYRULE S + 'domai n-type-rul e')); | |
| 185 | }); | |
| 186 | }) ; | |
| 187 | de scribe('pr ioritize() ', functio n() { | |
| 188 | it(' Happy Path for job a ssociated with MySit e', functi on() { | |
| 189 | ||
| 190 | var en vironment = createEn vironment( config); | |
| 191 | var ru lesEngine = new Even tPriorityR ulesEngine (log, conf ig, enviro nment); | |
| 192 | spyOn( rulesEngin e, '_runRu le').andCa llThrough( ); | |
| 193 | ||
| 194 | var jo b = create Job('9E7A' , 1, 'appo intment'); | |
| 195 | var jo bStatus = createJobS tatus('9E7 A', 1); | |
| 196 | setupD ummyJds(en vironment, jobStatus ); | |
| 197 | ||
| 198 | var fi nished = f alse; | |
| 199 | ||
| 200 | runs(f unction() { | |
| 201 | rulesEng ine.priori tize(job, function(e rr, result Job) { | |
| 202 | expect(err ).toBeFals y(); | |
| 203 | expect(rul esEngine._ runRule.ca lls.length ).toEqual( 2); | |
| 204 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' site-type- rule'), | |
| 205 | ja smine.obje ctContaini ng({ | |
| 206 | type : 'event-p rioritizat ion-reques t', | |
| 207 | root JobId: '1' , | |
| 208 | jobI d: '34', | |
| 209 | prio rity: jasm ine.any(Nu mber) | |
| 210 | }) , jasmine. any(Functi on)); | |
| 211 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' domain-typ e-rule'), | |
| 212 | ja smine.obje ctContaini ng({ | |
| 213 | type : 'event-p rioritizat ion-reques t', | |
| 214 | root JobId: '1' , | |
| 215 | jobI d: '34', | |
| 216 | prio rity: jasm ine.any(Nu mber) | |
| 217 | }) , jasmine. any(Functi on)); | |
| 218 | expect(res ultJob).to BeTruthy() ; | |
| 219 | expect(res ultJob.pri ority).toB e(1); | |
| 220 | finished = true; | |
| 221 | }); | |
| 222 | }); | |
| 223 | ||
| 224 | waitsF or(functio n() { | |
| 225 | return f inished; | |
| 226 | }); | |
| 227 | }); | |
| 228 | it(' Happy Path for job a ssociated with MySit e but with a lower p riority do main', fun ction() { | |
| 229 | ||
| 230 | var en vironment = createEn vironment( config); | |
| 231 | var ru lesEngine = new Even tPriorityR ulesEngine (log, conf ig, enviro nment); | |
| 232 | spyOn( rulesEngin e, '_runRu le').andCa llThrough( ); | |
| 233 | ||
| 234 | var jo b = create Job('9E7A' , 1, 'orde r'); | |
| 235 | var jo bStatus = createJobS tatus('9E7 A', 1); | |
| 236 | setupD ummyJds(en vironment, jobStatus ); | |
| 237 | ||
| 238 | var fi nished = f alse; | |
| 239 | ||
| 240 | runs(f unction() { | |
| 241 | rulesEng ine.priori tize(job, function(e rr, result Job) { | |
| 242 | expect(err ).toBeFals y(); | |
| 243 | expect(rul esEngine._ runRule.ca lls.length ).toEqual( 2); | |
| 244 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' site-type- rule'), | |
| 245 | ja smine.obje ctContaini ng({ | |
| 246 | type : 'event-p rioritizat ion-reques t', | |
| 247 | root JobId: '1' , | |
| 248 | jobI d: '34', | |
| 249 | prio rity: jasm ine.any(Nu mber) | |
| 250 | }) , jasmine. any(Functi on)); | |
| 251 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' domain-typ e-rule'), | |
| 252 | ja smine.obje ctContaini ng({ | |
| 253 | type : 'event-p rioritizat ion-reques t', | |
| 254 | root JobId: '1' , | |
| 255 | jobI d: '34', | |
| 256 | prio rity: jasm ine.any(Nu mber) | |
| 257 | }) , jasmine. any(Functi on)); | |
| 258 | expect(res ultJob).to BeTruthy() ; | |
| 259 | expect(res ultJob.pri ority).toB e(41); | |
| 260 | finished = true; | |
| 261 | }); | |
| 262 | }); | |
| 263 | ||
| 264 | waitsF or(functio n() { | |
| 265 | return f inished; | |
| 266 | }); | |
| 267 | }); | |
| 268 | it(' Happy Path for job a ssociated with Other VistA Sit e', functi on() { | |
| 269 | ||
| 270 | var en vironment = createEn vironment( config); | |
| 271 | var ru lesEngine = new Even tPriorityR ulesEngine (log, conf ig, enviro nment); | |
| 272 | spyOn( rulesEngin e, '_runRu le').andCa llThrough( ); | |
| 273 | ||
| 274 | var jo b = create Job('C877' , 1, 'appo intment'); | |
| 275 | var jo bStatus = createJobS tatus('9E7 A', 1); | |
| 276 | setupD ummyJds(en vironment, jobStatus ); | |
| 277 | ||
| 278 | var fi nished = f alse; | |
| 279 | ||
| 280 | runs(f unction() { | |
| 281 | rulesEng ine.priori tize(job, function(e rr, result Job) { | |
| 282 | expect(err ).toBeFals y(); | |
| 283 | expect(rul esEngine._ runRule.ca lls.length ).toEqual( 2); | |
| 284 | ||
| 285 | // Note fo r the futu re... I n case you fall into the same trap I did ... :) | |
| 286 | // The job that is v erfied by spyOn is w hatever st ate that j ob is in a t the end. Since th e rules en gine | |
| 287 | // is modi fying the priority w ithin the same job o n each rul e call - y ou cannot check the individual priority | |
| 288 | // numbers on each i ndividual call - sin ce it will oonly sho w you the final stat e of the j ob. So th e best we | |
| 289 | // can do is verify that each rule was i ndeed call ed with th e correct job, and t hat in the end, the final | |
| 290 | // priorit y value se tting was correct. | |
| 291 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 292 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' site-type- rule'), | |
| 293 | ja smine.obje ctContaini ng({ | |
| 294 | type : 'event-p rioritizat ion-reques t', | |
| 295 | root JobId: '1' , | |
| 296 | jobI d: '34', | |
| 297 | prio rity: jasm ine.any(Nu mber) | |
| 298 | }) , jasmine. any(Functi on)); | |
| 299 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' domain-typ e-rule'), | |
| 300 | ja smine.obje ctContaini ng({ | |
| 301 | type : 'event-p rioritizat ion-reques t', | |
| 302 | root JobId: '1' , | |
| 303 | jobI d: '34', | |
| 304 | prio rity: jasm ine.any(Nu mber) | |
| 305 | }) , jasmine. any(Functi on)); | |
| 306 | expect(res ultJob).to BeTruthy() ; | |
| 307 | expect(res ultJob.pri ority).toB e(21); | |
| 308 | finished = true; | |
| 309 | }); | |
| 310 | }); | |
| 311 | ||
| 312 | waitsF or(functio n() { | |
| 313 | return f inished; | |
| 314 | }); | |
| 315 | }); | |
| 316 | ||
| 317 | it(' Happy Path for job a ssociated with Other VistA Sit e and no o riginal de fault prio rity set.' , function () { | |
| 318 | ||
| 319 | var en vironment = createEn vironment( config); | |
| 320 | var ru lesEngine = new Even tPriorityR ulesEngine (log, conf ig, enviro nment); | |
| 321 | spyOn( rulesEngin e, '_runRu le').andCa llThrough( ); | |
| 322 | ||
| 323 | var jo b = create Job('C877' , undefine d, 'appoin tment'); | |
| 324 | var jo bStatus = createJobS tatus('9E7 A', undefi ned); | |
| 325 | setupD ummyJds(en vironment, jobStatus ); | |
| 326 | ||
| 327 | var fi nished = f alse; | |
| 328 | ||
| 329 | runs(f unction() { | |
| 330 | rulesEng ine.priori tize(job, function(e rr, result Job) { | |
| 331 | expect(err ).toBeFals y(); | |
| 332 | expect(rul esEngine._ runRule.ca lls.length ).toEqual( 2); | |
| 333 | ||
| 334 | // Note fo r the futu re... I n case you fall into the same trap I did ... :) | |
| 335 | // The job that is v erfied by spyOn is w hatever st ate that j ob is in a t the end. Since th e rules en gine | |
| 336 | // is modi fying the priority w ithin the same job o n each rul e call - y ou cannot check the individual priority | |
| 337 | // numbers on each i ndividual call - sin ce it will oonly sho w you the final stat e of the j ob. So th e best we | |
| 338 | // can do is verify that each rule was i ndeed call ed with th e correct job, and t hat in the end, the final | |
| 339 | // priorit y value se tting was correct. | |
| 340 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 341 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' site-type- rule'), | |
| 342 | ja smine.obje ctContaini ng({ | |
| 343 | type : 'event-p rioritizat ion-reques t', | |
| 344 | root JobId: '1' , | |
| 345 | jobI d: '34', | |
| 346 | prio rity: jasm ine.any(Nu mber) | |
| 347 | }) , jasmine. any(Functi on)); | |
| 348 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' domain-typ e-rule'), | |
| 349 | ja smine.obje ctContaini ng({ | |
| 350 | type : 'event-p rioritizat ion-reques t', | |
| 351 | root JobId: '1' , | |
| 352 | jobI d: '34', | |
| 353 | prio rity: jasm ine.any(Nu mber) | |
| 354 | }) , jasmine. any(Functi on)); | |
| 355 | expect(res ultJob).to BeTruthy() ; | |
| 356 | expect(res ultJob.pri ority).toB e(21); | |
| 357 | finished = true; | |
| 358 | }); | |
| 359 | }); | |
| 360 | ||
| 361 | waitsF or(functio n() { | |
| 362 | return f inished; | |
| 363 | }); | |
| 364 | }); | |
| 365 | ||
| 366 | it(' Happy Path for job a ssociated with Other VistA Sit e and prio rity set w ith out of range low value.', function() { | |
| 367 | ||
| 368 | var en vironment = createEn vironment( config); | |
| 369 | var ru lesEngine = new Even tPriorityR ulesEngine (log, conf ig, enviro nment); | |
| 370 | spyOn( rulesEngin e, '_runRu le').andCa llThrough( ); | |
| 371 | ||
| 372 | var jo b = create Job('C877' , -50, 'ap pointment' ); | |
| 373 | var jo bStatus = createJobS tatus('9E7 A', -50); | |
| 374 | setupD ummyJds(en vironment, jobStatus ); | |
| 375 | ||
| 376 | var fi nished = f alse; | |
| 377 | ||
| 378 | runs(f unction() { | |
| 379 | rulesEng ine.priori tize(job, function(e rr, result Job) { | |
| 380 | expect(err ).toBeFals y(); | |
| 381 | expect(rul esEngine._ runRule.ca lls.length ).toEqual( 2); | |
| 382 | ||
| 383 | // Note fo r the futu re... I n case you fall into the same trap I did ... :) | |
| 384 | // The job that is v erfied by spyOn is w hatever st ate that j ob is in a t the end. Since th e rules en gine | |
| 385 | // is modi fying the priority w ithin the same job o n each rul e call - y ou cannot check the individual priority | |
| 386 | // numbers on each i ndividual call - sin ce it will oonly sho w you the final stat e of the j ob. So th e best we | |
| 387 | // can do is verify that each rule was i ndeed call ed with th e correct job, and t hat in the end, the final | |
| 388 | // priorit y value se tting was correct. | |
| 389 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 390 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' site-type- rule'), | |
| 391 | ja smine.obje ctContaini ng({ | |
| 392 | type : 'event-p rioritizat ion-reques t', | |
| 393 | root JobId: '1' , | |
| 394 | jobI d: '34', | |
| 395 | prio rity: jasm ine.any(Nu mber) | |
| 396 | }) , jasmine. any(Functi on)); | |
| 397 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' domain-typ e-rule'), | |
| 398 | ja smine.obje ctContaini ng({ | |
| 399 | type : 'event-p rioritizat ion-reques t', | |
| 400 | root JobId: '1' , | |
| 401 | jobI d: '34', | |
| 402 | prio rity: jasm ine.any(Nu mber) | |
| 403 | }) , jasmine. any(Functi on)); | |
| 404 | expect(res ultJob).to BeTruthy() ; | |
| 405 | expect(res ultJob.pri ority).toB e(21); | |
| 406 | finished = true; | |
| 407 | }); | |
| 408 | }); | |
| 409 | ||
| 410 | waitsF or(functio n() { | |
| 411 | return f inished; | |
| 412 | }); | |
| 413 | }); | |
| 414 | ||
| 415 | it(' Happy Path for job a ssociated with Other VistA Sit e and prio rity set w ith out of range hig h value.', function( ) { | |
| 416 | ||
| 417 | var en vironment = createEn vironment( config); | |
| 418 | var ru lesEngine = new Even tPriorityR ulesEngine (log, conf ig, enviro nment); | |
| 419 | spyOn( rulesEngin e, '_runRu le').andCa llThrough( ); | |
| 420 | ||
| 421 | var jo b = create Job('C877' , 200, 'ap pointment' ); | |
| 422 | var jo bStatus = createJobS tatus('9E7 A', 200); | |
| 423 | setupD ummyJds(en vironment, jobStatus ); | |
| 424 | ||
| 425 | var fi nished = f alse; | |
| 426 | ||
| 427 | runs(f unction() { | |
| 428 | rulesEng ine.priori tize(job, function(e rr, result Job) { | |
| 429 | expect(err ).toBeFals y(); | |
| 430 | expect(rul esEngine._ runRule.ca lls.length ).toEqual( 2); | |
| 431 | ||
| 432 | // Note fo r the futu re... I n case you fall into the same trap I did ... :) | |
| 433 | // The job that is v erfied by spyOn is w hatever st ate that j ob is in a t the end. Since th e rules en gine | |
| 434 | // is modi fying the priority w ithin the same job o n each rul e call - y ou cannot check the individual priority | |
| 435 | // numbers on each i ndividual call - sin ce it will oonly sho w you the final stat e of the j ob. So th e best we | |
| 436 | // can do is verify that each rule was i ndeed call ed with th e correct job, and t hat in the end, the final | |
| 437 | // priorit y value se tting was correct. | |
| 438 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 439 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' site-type- rule'), | |
| 440 | ja smine.obje ctContaini ng({ | |
| 441 | type : 'event-p rioritizat ion-reques t', | |
| 442 | root JobId: '1' , | |
| 443 | jobI d: '34', | |
| 444 | prio rity: jasm ine.any(Nu mber) | |
| 445 | }) , jasmine. any(Functi on)); | |
| 446 | expect(rul esEngine._ runRule).t oHaveBeenC alledWith( require(gl obal.VX_EV ENTPRIORIT YRULES + ' domain-typ e-rule'), | |
| 447 | ja smine.obje ctContaini ng({ | |
| 448 | type : 'event-p rioritizat ion-reques t', | |
| 449 | root JobId: '1' , | |
| 450 | jobI d: '34', | |
| 451 | prio rity: jasm ine.any(Nu mber) | |
| 452 | }) , jasmine. any(Functi on)); | |
| 453 | expect(res ultJob).to BeTruthy() ; | |
| 454 | expect(res ultJob.pri ority).toB e(100); | |
| 455 | finished = true; | |
| 456 | }); | |
| 457 | }); | |
| 458 | ||
| 459 | waitsF or(functio n() { | |
| 460 | return f inished; | |
| 461 | }); | |
| 462 | }); | |
| 463 | ||
| 464 | ||
| 465 | }) ; | |
| 466 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.