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\event-prioritization-request | event-prioritization-request-handler-spec.js | Mon Jul 10 17:46:22 2017 UTC |
| 2 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\handlers\event-prioritization-request | event-prioritization-request-handler-spec.js | Tue Oct 3 13:16:59 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 4 | 472 |
| 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-prirori tization-r equest-han dler.js. | |
| 5 | // | |
| 6 | // Author: Les Westb erg | |
| 7 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------ | |
| 8 | ||
| 9 | require('. ./../../.. /env-setup '); | |
| 10 | ||
| 11 | var log = require(gl obal.VX_DU MMIES + 'd ummy-logge r'); | |
| 12 | //-------- ---------- ---------- ---------- ---------- ---------- ---- | |
| 13 | // Uncomme nt the fol lowing to see the lo gging out on the scr een. | |
| 14 | //-------- ---------- ---------- ---------- ---------- ---------- ---- | |
| 15 | // var log Util = req uire(globa l.VX_UTILS + 'log'); | |
| 16 | // logUtil .initializ e([{ | |
| 17 | // nam e: 'root', | |
| 18 | // str eam: proce ss.stdout, | |
| 19 | // lev el: 'debug ' | |
| 20 | // }]); | |
| 21 | // log = l ogUtil.get ('test', ' debug'); | |
| 22 | //-------- ---------- ---------- ---------- ---- | |
| 23 | // End of logging st uff to com ment out.. .. | |
| 24 | //-------- ---------- ---------- ---------- ---- | |
| 25 | // log = r equire('bu nyan').cre ateLogger( { | |
| 26 | // na me: 'site- type-rule- spec', | |
| 27 | // le vel: 'debu g' | |
| 28 | // }); | |
| 29 | ||
| 30 | var handle r = requir e(global.V X_HANDLERS + 'event- prioritiza tion-reque st/event-p rioritizat ion-reques t-handler' ); | |
| 31 | var EventP riorityRul esEngine = require(g lobal.VX_E VENTPRIORI TYRULES + 'event-pri ority-rule s-engine') ; | |
| 32 | var Publis herRouterD ummy = req uire(globa l.VX_DUMMI ES + 'publ isherRoute rDummy'); | |
| 33 | var Publis herDummy = require(g lobal.VX_D UMMIES + ' publisherD ummy'); | |
| 34 | ||
| 35 | var hmpSer ver = 'The HmpServer' ; | |
| 36 | ||
| 37 | var config = { | |
| 38 | jd s: { | |
| 39 | prot ocol: 'htt p', | |
| 40 | host: ' IP ', | |
| 41 | port: PORT | |
| 42 | }, | |
| 43 | 'v istaSites' : { | |
| 44 | '9E7 A': { | |
| 45 | 'name' : 'panoram a', | |
| 46 | 'host': ' IP ', | |
| 47 | 'port': PORT , | |
| 48 | 'accessCod e': ' REDACT ', | |
| 49 | 'verifyCod e': ' REDACTED ', | |
| 50 | 'local IP': '127. 0.0.1', | |
| 51 | 'local Address': 'localhost ', | |
| 52 | 'conne ctTimeout' : 3000, | |
| 53 | 'sendT imeout': 1 0000 | |
| 54 | }, | |
| 55 | 'C87 7': { | |
| 56 | 'name' : 'kodak', | |
| 57 | 'host': ' IP ', | |
| 58 | 'port': PORT , | |
| 59 | 'accessCod e': ' REDACT ', | |
| 60 | 'verifyCod e': ' REDACTED ', | |
| 61 | 'local IP': '127. 0.0.1', | |
| 62 | 'local Address': 'localhost ', | |
| 63 | 'conne ctTimeout' : 3000, | |
| 64 | 'sendT imeout': 1 0000 | |
| 65 | } | |
| 66 | }, | |
| 67 | 'h mp.server. id': hmpSe rver, | |
| 68 | 'h mp.version ': '0.7-S6 5', | |
| 69 | 'h mp.batch.s ize': '100 0', | |
| 70 | 'h mp.extract .schema': '3.001', | |
| 71 | 'h dr': { | |
| 72 | 'ope rationMode ': 'REQ/RE S' | |
| 73 | } | |
| 74 | }; | |
| 75 | ||
| 76 | var refere nceInfo = { | |
| 77 | se ssionId: ' test-sessi on-id', | |
| 78 | re questId: ' test-reque st-id' | |
| 79 | }; | |
| 80 | ||
| 81 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- - | |
| 82 | // This is a mock of the event priority rules engi ne priorit ize method | |
| 83 | // that si mulates a successful call. | |
| 84 | // | |
| 85 | // job: Th e job to b e prioriti zed. | |
| 86 | // callbac k: The cal lback hand ler. Sin gature is: | |
| 87 | // func tion(err, job) | |
| 88 | // wh ere: | |
| 89 | // err: Is a n error if one occur s. | |
| 90 | // job: Is t he job wit h the upda ted priori ty. | |
| 91 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 92 | function f akePriorit izeSuccess (job, call back) { | |
| 93 | jo b.priority = 50; | |
| 94 | re turn callb ack(null, job); | |
| 95 | } | |
| 96 | ||
| 97 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- - | |
| 98 | // This is a mock of the event priority rules engi ne priorit ize method | |
| 99 | // that si mulates a err call. | |
| 100 | // | |
| 101 | // job: Th e job to b e prioriti zed. | |
| 102 | // callbac k: The cal lback hand ler. Sin gature is: | |
| 103 | // func tion(err, job) | |
| 104 | // wh ere: | |
| 105 | // err: Is a n error if one occur s. | |
| 106 | // job: Is t he job wit h the upda ted priori ty. | |
| 107 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 108 | function f akePriorit izeErr(job , callback ) { | |
| 109 | re turn callb ack('SomeE rror'. job ); | |
| 110 | } | |
| 111 | ||
| 112 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- - | |
| 113 | // This is a mock of the event priority rules engi ne priorit ize method | |
| 114 | // that si mulates a call where no job is returned. | |
| 115 | // | |
| 116 | // job: Th e job to b e prioriti zed. | |
| 117 | // callbac k: The cal lback hand ler. Sin gature is: | |
| 118 | // func tion(err, job) | |
| 119 | // wh ere: | |
| 120 | // err: Is a n error if one occur s. | |
| 121 | // job: Is t he job wit h the upda ted priori ty. | |
| 122 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 123 | function f akePriorit izeNoJob(j ob, callba ck) { | |
| 124 | re turn callb ack(null, null); | |
| 125 | } | |
| 126 | ||
| 127 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- - | |
| 128 | // Create an instanc e of the e nvironment variable. | |
| 129 | // | |
| 130 | // the_con fig: The config obj ect to be used in th e environm ent. | |
| 131 | // returns : The envi ronment th at was cre ated. | |
| 132 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- - | |
| 133 | function c reateEnvir onment(the _config, f akePriorit izeFunctio n) { | |
| 134 | va r environm ent = { | |
| 135 | metr ics: log, | |
| 136 | publishe rRouter: n ew Publish erRouterDu mmy(log, t he_config, Publisher Dummy), | |
| 137 | }; | |
| 138 | ||
| 139 | va r eventPri orityRules Engine = n ew EventPr iorityRule sEngine(lo g, the_co nfig, envi ronment); | |
| 140 | en vironment. eventPrior ityRulesEn gine = eve ntPriority RulesEngin e; | |
| 141 | ||
| 142 | sp yOn(enviro nment.even tPriorityR ulesEngine , 'priorit ize').andC allFake(fa kePrioriti zeFunction ); | |
| 143 | sp yOn(enviro nment.publ isherRoute r, 'publis h').andCal lThrough() ; | |
| 144 | ||
| 145 | re turn envir onment; | |
| 146 | } | |
| 147 | ||
| 148 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 149 | // Create an instanc e of the j ob and ret urn it. | |
| 150 | // | |
| 151 | // priorit y: The pri ority to a ssociated with this job | |
| 152 | // returns : The crea ted job | |
| 153 | //-------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 154 | function c reateJob(p riority) { | |
| 155 | va r job = { | |
| 156 | type : 'event-p rioritizat ion-reques t', | |
| 157 | pati entIdentif ier: { | |
| 158 | type: 'pid', | |
| 159 | value: '9E7A;3' | |
| 160 | }, | |
| 161 | jpid : '8107cc4 1-69eb-406 0-8813-a82 db245a11a' , | |
| 162 | root JobId: '1' , | |
| 163 | data Domain: 'a ppointment ', | |
| 164 | prio rity: prio rity, | |
| 165 | reco rd: {}, | |
| 166 | jobI d: '34', | |
| 167 | refe renceInfo: reference Info | |
| 168 | }; | |
| 169 | ||
| 170 | re turn job; | |
| 171 | ||
| 172 | } | |
| 173 | ||
| 174 | describe(' event-prir oritizatio n-request- handler.js ', functio n() { | |
| 175 | de scribe('ha ndle()', f unction() { | |
| 176 | it(' Happy Path ', functio n() { | |
| 177 | ||
| 178 | var en vironment = createEn vironment( config, fa kePrioriti zeSuccess) ; | |
| 179 | var jo b = create Job(1); | |
| 180 | ||
| 181 | var fi nished; | |
| 182 | ||
| 183 | runs(f unction() { | |
| 184 | handler( log, confi g, environ ment, job, function( err) { | |
| 185 | expect(err ).toBeFals y(); | |
| 186 | expect(env ironment.e ventPriori tyRulesEng ine.priori tize.calls .length).t oEqual(1); | |
| 187 | expect(env ironment.p ublisherRo uter.publi sh.calls.l ength).toE qual(1); | |
| 188 | expect(env ironment.e ventPriori tyRulesEng ine.priori tize).toHa veBeenCall edWith(job , jasmine. any(Functi on)); | |
| 189 | expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled With(jasmi ne.objectC ontaining( { type: 'r ecord-enri chment', p riority: 5 0, referen ceInfo: re ferenceInf o}), jasmi ne.any(Fun ction)); | |
| 190 | finished = true; | |
| 191 | }); | |
| 192 | }); | |
| 193 | ||
| 194 | waitsF or(functio n() { | |
| 195 | return f inished; | |
| 196 | }); | |
| 197 | }); | |
| 198 | it(' Err Path', function( ) { | |
| 199 | ||
| 200 | var en vironment = createEn vironment( config, fa kePrioriti zeErr); | |
| 201 | var jo b = create Job(1); | |
| 202 | ||
| 203 | var fi nished; | |
| 204 | ||
| 205 | runs(f unction() { | |
| 206 | handler( log, confi g, environ ment, job, function( err) { | |
| 207 | expect(err ).toBeFals y(); | |
| 208 | expect(env ironment.e ventPriori tyRulesEng ine.priori tize.calls .length).t oEqual(1); | |
| 209 | expect(env ironment.p ublisherRo uter.publi sh.calls.l ength).toE qual(1); | |
| 210 | expect(env ironment.e ventPriori tyRulesEng ine.priori tize).toHa veBeenCall edWith(job , jasmine. any(Functi on)); | |
| 211 | expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled With(jasmi ne.objectC ontaining( { type: 'r ecord-enri chment', p riority: 1 , referenc eInfo: ref erenceInfo }), jasmin e.any(Func tion)); | |
| 212 | finished = true; | |
| 213 | }); | |
| 214 | }); | |
| 215 | ||
| 216 | waitsF or(functio n() { | |
| 217 | return f inished; | |
| 218 | }); | |
| 219 | }); | |
| 220 | it(' No result Path', fun ction() { | |
| 221 | ||
| 222 | var en vironment = createEn vironment( config, fa kePrioriti zeNoJob); | |
| 223 | var jo b = create Job(1); | |
| 224 | ||
| 225 | var fi nished; | |
| 226 | ||
| 227 | runs(f unction() { | |
| 228 | handler( log, confi g, environ ment, job, function( err) { | |
| 229 | expect(err ).toBeFals y(); | |
| 230 | expect(env ironment.e ventPriori tyRulesEng ine.priori tize.calls .length).t oEqual(1); | |
| 231 | expect(env ironment.p ublisherRo uter.publi sh.calls.l ength).toE qual(1); | |
| 232 | expect(env ironment.e ventPriori tyRulesEng ine.priori tize).toHa veBeenCall edWith(job , jasmine. any(Functi on)); | |
| 233 | expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled With(jasmi ne.objectC ontaining( { type: 'r ecord-enri chment', p riority: 1 , referenc eInfo: ref erenceInfo }), jasmin e.any(Func tion)); | |
| 234 | finished = true; | |
| 235 | }); | |
| 236 | }); | |
| 237 | ||
| 238 | waitsF or(functio n() { | |
| 239 | return f inished; | |
| 240 | }); | |
| 241 | }); | |
| 242 | ||
| 243 | }) ; | |
| 244 | }); | |
| 245 | ||
| 246 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.