Produced by Araxis Merge on 10/4/2017 8:04:33 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 | rdk.zip\rdk\product\production\rdk\src\fhir\communication | communication-resource-spec.js | Mon Aug 21 12:51:00 2017 UTC |
| 2 | rdk.zip\rdk\product\production\rdk\src\fhir\communication | communication-resource-spec.js | Tue Oct 3 17:15:05 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 5 | 430 |
| Changed | 4 | 8 |
| 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 | var _ = re quire('lod ash'); | |
| 4 | var commun ication = require('. /communica tion-resou rce'); | |
| 5 | var oracle Connection Pool = req uire('../. ./utils/or acle-conne ction-pool '); | |
| 6 | var oracle db = requi re('oracle db'); | |
| 7 | ||
| 8 | ||
| 9 | describe(' Communicat ions Resou rce', func tion() { | |
| 10 | var re q, res; | |
| 11 | ||
| 12 | ||
| 13 | functi on createR eq() { | |
| 14 | va r dbConfig = { | |
| 15 | user: 'u ser', | |
| 16 | password : 'passwor d', | |
| 17 | connectS tring: 'co nnectStrin g' | |
| 18 | }; | |
| 19 | ||
| 20 | re q = {}; | |
| 21 | _. set(req, ' body', {}) ; | |
| 22 | _. set(req, ' param', {} ); | |
| 23 | _. set(req, ' query', {} ); | |
| 24 | _. set(req, ' session.us er.uid', ' a:b:c:d'); | |
| 25 | _. set(req, ' app.config .oracledb. communicat ionsDataba se', dbCon fig); | |
| 26 | _. set(req, ' logger.deb ug', _.noo p); | |
| 27 | _. set(req, ' logger.inf o', _.noop ); | |
| 28 | } | |
| 29 | ||
| 30 | ||
| 31 | functi on createR es() { | |
| 32 | re s = {}; | |
| 33 | _. set(res, ' status', f unction() { | |
| 34 | return t his; | |
| 35 | }) ; | |
| 36 | _. set(res, ' rdkSend', function() { | |
| 37 | return t his; | |
| 38 | }) ; | |
| 39 | } | |
| 40 | ||
| 41 | ||
| 42 | functi on createB ind(dir, t ype, val) { | |
| 43 | re turn { | |
| 44 | dir: dir , | |
| 45 | type: ty pe, | |
| 46 | val: val | |
| 47 | }; | |
| 48 | } | |
| 49 | ||
| 50 | ||
| 51 | before Each(funct ion() { | |
| 52 | cr eateReq(); | |
| 53 | cr eateRes(); | |
| 54 | or acledb.STR ING = 'STR ING'; | |
| 55 | or acledb.CLO B = 'CLOB' ; | |
| 56 | or acledb.NUM BER = 'NUM BER'; | |
| 57 | or acledb.BIN D_OUT = 'O UT'; | |
| 58 | or acledb.BIN D_IN = 'IN '; | |
| 59 | }); | |
| 60 | ||
| 61 | ||
| 62 | descri be('getCom munication s', functi on() { | |
| 63 | it ('returns 400 when r equester.u serId does not match session u ser', func tion() { | |
| 64 | _.set(re q, ['query ', 'reques ter.userId '], 'd:c:b :a'); | |
| 65 | sinon.sp y(res, 'st atus'); | |
| 66 | communic ation._get Communicat ions(req, res); | |
| 67 | expect(r es.status. calledWith (400)).to. be.true(); | |
| 68 | }) ; | |
| 69 | ||
| 70 | it ('returns 500 when i t fails to get a poo l from the connectio n pool', f unction() { | |
| 71 | sinon.st ub(oracleC onnectionP ool, 'getP ool').call sFake(func tion(req, dbConfig, callback) { | |
| 72 | call back({mess age: 'I fo rced this error'}, n ull); | |
| 73 | }); | |
| 74 | ||
| 75 | _.set(re q, ['query ', 'reques ter.userId '], 'a:b:c :d'); | |
| 76 | sinon.sp y(res, 'st atus'); | |
| 77 | communic ation._get Communicat ions(req, res); | |
| 78 | expect(r es.status. calledWith (500)).to. be.true(); | |
| 79 | }) ; | |
| 80 | ||
| 81 | it ('returns a 500 when it fails to establi sh a conne ction', fu nction() { | |
| 82 | _.set(re q, ['query ', 'reques ter.userId '], 'a:b:c :d'); | |
| 83 | ||
| 84 | var getC onnection = function (callback) { | |
| 85 | call back({mess age: 'I fo rced this error'}); | |
| 86 | }; | |
| 87 | ||
| 88 | sinon.st ub(oracleC onnectionP ool, 'getP ool').call sFake(func tion(req, dbConfig, callback) { | |
| 89 | call back(null, {getConne ction: get Connection }); | |
| 90 | }); | |
| 91 | ||
| 92 | sinon.sp y(res, 'st atus'); | |
| 93 | communic ation._get Communicat ions(req, res); | |
| 94 | expect(r es.status. calledWith (500)).to. be.true(); | |
| 95 | }) ; | |
| 96 | ||
| 97 | it ('generate s the corr ect query string wit h minimum set of par ams', func tion(done) { | |
| 98 | var expe cted = 'BE GIN COMMUN ICATION.ME SSAGE_API. FETCH_MESS AGES(i_use r_id => :u serId, i_v ersion => :version, i_category => :categ ory, o_mes sages => : output); E ND;'; | |
| 99 | ||
| 100 | _.set(re q, ['query ', 'reques ter.userId '], 'a:b:c :d'); | |
| 101 | _.set(re q, ['query ', 'reques ter.ehmpAp pVersion'] , 'r2.0'); | |
| 102 | _.set(re q, ['query ', 'catego ry'], 'som e category '); | |
| 103 | ||
| 104 | var exec ute = func tion(query ) { | |
| 105 | expe ct(query). to.equal(e xpected); | |
| 106 | done (); | |
| 107 | }; | |
| 108 | ||
| 109 | var getC onnection = function (callback) { | |
| 110 | call back(null, {execute: execute}) ; | |
| 111 | }; | |
| 112 | ||
| 113 | ||
| 114 | sinon.st ub(oracleC onnectionP ool, 'getP ool').call sFake(func tion(req, dbConfig, callback) { | |
| 115 | call back(null, {getConne ction: get Connection }); | |
| 116 | }); | |
| 117 | ||
| 118 | communic ation._get Communicat ions(req, res); | |
| 119 | }) ; | |
| 120 | ||
| 121 | it ('generate s the corr ect query string wit h maximum set of par ams', func tion(done) { | |
| 122 | var expe cted = 'BE GIN COMMUN ICATION.ME SSAGE_API. FETCH_MESS AGES(i_use r_id => :u serId, i_v ersion => :version, i_category => :categ ory, i_sta tus => :st atus, i_ov erride_pre ferences = > :overrid e, o_messa ges => :ou tput); END ;'; | |
| 123 | ||
| 124 | _.set(re q, ['query ', 'reques ter.userId '], 'a:b:c :d'); | |
| 125 | _.set(re q, ['query ', 'reques ter.ehmpAp pVersion'] , 'r2.0'); | |
| 126 | _.set(re q, ['query ', 'catego ry'], 'som e category '); | |
| 127 | _.set(re q, ['query ', 'status '], 'some status'); | |
| 128 | _.set(re q, ['query ', 'overri dePreferen ces'], fal se); | |
| 129 | ||
| 130 | var exec ute = func tion(query ) { | |
| 131 | expe ct(query). to.equal(e xpected); | |
| 132 | done (); | |
| 133 | }; | |
| 134 | ||
| 135 | var getC onnection = function (callback) { | |
| 136 | call back(null, {execute: execute}) ; | |
| 137 | }; | |
| 138 | ||
| 139 | ||
| 140 | sinon.st ub(oracleC onnectionP ool, 'getP ool').call sFake(func tion(req, dbConfig, callback) { | |
| 141 | call back(null, {getConne ction: get Connection }); | |
| 142 | }); | |
| 143 | ||
| 144 | communic ation._get Communicat ions(req, res); | |
| 145 | }) ; | |
| 146 | ||
| 147 | it ('generate s the corr ect data b inds with minimum se t of param s', functi on(done) { | |
| 148 | var expe cted = {}; | |
| 149 | ||
| 150 | _.set(expe cted, 'cat egory', cr eateBind(o racledb.BI ND_IN, ora cledb.STRI NG, ['http ://ehmp. DNS /messageCa tegories'] )); | |
| 151 | _.set(ex pected, 'u serId', cr eateBind(o racledb.BI ND_IN, ora cledb.STRI NG, 'a:b:c :d')); | |
| 152 | _.set(ex pected, 'v ersion', c reateBind( oracledb.B IND_IN, or acledb.STR ING, 'vers ion')); | |
| 153 | _.set(ex pected, 'o utput', {d ir: oracle db.BIND_OU T, type: o racledb.CL OB}); | |
| 154 | _.set(re q, ['query ', 'reques ter.userId '], 'a:b:c :d'); | |
| 155 | _.set(re q, ['query ', 'reques ter.ehmpAp pVersion'] , 'version '); | |
| 156 | _.set(req, ['query', 'category '], 'http: //ehmp. DNS /messageCa tegories') ; | |
| 157 | ||
| 158 | var exec ute = func tion(query , data) { | |
| 159 | expe ct(data).t o.eql(expe cted); | |
| 160 | done (); | |
| 161 | }; | |
| 162 | ||
| 163 | var getC onnection = function (callback) { | |
| 164 | call back(null, {execute: execute}) ; | |
| 165 | }; | |
| 166 | ||
| 167 | sinon.st ub(oracleC onnectionP ool, 'getP ool').call sFake(func tion(req, dbConfig, callback) { | |
| 168 | call back(null, {getConne ction: get Connection }); | |
| 169 | }); | |
| 170 | ||
| 171 | communic ation._get Communicat ions(req, res); | |
| 172 | }) ; | |
| 173 | ||
| 174 | it ('generate s the corr ect data b inds with maximum se t of param s', functi on(done) { | |
| 175 | var expe cted = {}; | |
| 176 | ||
| 177 | _.set(expe cted, 'cat egory', cr eateBind(o racledb.BI ND_IN, ora cledb.STRI NG, ['http ://ehmp. DNS /messageCa tegories'] )); | |
| 178 | _.set(ex pected, 'o verride', createBind (oracledb. BIND_IN, o racledb.ST RING, 'N') ); | |
| 179 | _.set(ex pected, 's tatus', cr eateBind(o racledb.BI ND_IN, ora cledb.STRI NG, 'statu sSystem/st atusCode') ); | |
| 180 | _.set(ex pected, 'u serId', cr eateBind(o racledb.BI ND_IN, ora cledb.STRI NG, 'a:b:c :d')); | |
| 181 | _.set(ex pected, 'v ersion', c reateBind( oracledb.B IND_IN, or acledb.STR ING, 'vers ion')); | |
| 182 | _.set(ex pected, 'o utput', {d ir: oracle db.BIND_OU T, type: o racledb.CL OB}); | |
| 183 | ||
| 184 | _.set(re q, ['query ', 'reques ter.userId '], 'a:b:c :d'); | |
| 185 | _.set(re q, ['query ', 'reques ter.ehmpAp pVersion'] , 'version '); | |
| 186 | _.set(req, ['query', 'category '], 'http: //ehmp. DNS /messageCa tegories') ; | |
| 187 | _.set(re q, ['query ', 'status '], 'statu sSystem/st atusCode') ; | |
| 188 | _.set(re q, ['query ', 'overri dePreferen ces'], fal se); | |
| 189 | ||
| 190 | var exec ute = func tion(query , data) { | |
| 191 | expe ct(data).t o.eql(expe cted); | |
| 192 | done (); | |
| 193 | }; | |
| 194 | ||
| 195 | var getC onnection = function (callback) { | |
| 196 | call back(null, {execute: execute}) ; | |
| 197 | }; | |
| 198 | ||
| 199 | sinon.st ub(oracleC onnectionP ool, 'getP ool').call sFake(func tion(req, dbConfig, callback) { | |
| 200 | call back(null, {getConne ction: get Connection }); | |
| 201 | }); | |
| 202 | ||
| 203 | communic ation._get Communicat ions(req, res); | |
| 204 | }) ; | |
| 205 | ||
| 206 | it ('handles a get conn ection err or', funct ion() { | |
| 207 | sinon.st ub(oracleC onnectionP ool, 'getP ool').call sFake(func tion(req, dbConfig, callback) { | |
| 208 | call back(null, { | |
| 209 | getConnect ion: funct ion(callba ck) { | |
| 210 | return callback( {message: 'the conne ction fail ed'}); | |
| 211 | } | |
| 212 | }); | |
| 213 | }); | |
| 214 | sinon.sp y(res, 'st atus'); | |
| 215 | communic ation._get Attachment (req, res) ; | |
| 216 | expect(r es.status. calledWith (500)).to. be.true(); | |
| 217 | }) ; | |
| 218 | }); | |
| 219 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.