Produced by Araxis Merge on 1/4/2018 4:54:42 PM Eastern Standard 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 | CHAMPVA_Benefit_Eligibility_v1.0.0.zip\webservice\champvapay-service\src\test\java\gov\va\med\mbcp\champva\rest | ChampVAResourceTest.java | Thu Dec 21 19:52:28 2017 UTC |
| 2 | CHAMPVA_Benefit_Eligibility_v1.0.0.zip\webservice\champvapay-service\src\test\java\gov\va\med\mbcp\champva\rest | ChampVAResourceTest.java | Thu Jan 4 21:02:14 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 712 |
| Changed | 1 | 2 |
| 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 | /** | |
| 2 | * The pac kage gov.v a.med.mbcp .champva.r est contai ns the RES Tful Web A pplication & Resourc e classes for | |
| 3 | * retriev al of Code Results f rom the ta rget VistA instance. | |
| 4 | * | |
| 5 | */ | |
| 6 | package go v.va.med.m bcp.champv a.rest; | |
| 7 | ||
| 8 | import sta tic org.ju nit.Assert .assertEqu als; | |
| 9 | import sta tic org.ju nit.Assert .assertNot Null; | |
| 10 | import sta tic org.ju nit.Assert .assertTru e; | |
| 11 | import sta tic org.ju nit.Assert .fail; | |
| 12 | import sta tic org.mo ckito.Mock ito.mock; | |
| 13 | import sta tic org.mo ckito.Mock ito.times; | |
| 14 | import sta tic org.mo ckito.Mock ito.verify ; | |
| 15 | import sta tic org.mo ckito.Mock ito.when; | |
| 16 | import sta tic org.po wermock.ap i.mockito. PowerMocki to.mockSta tic; | |
| 17 | import sta tic org.po wermock.ap i.mockito. PowerMocki to.verifyS tatic; | |
| 18 | ||
| 19 | import jav ax.naming. NamingExce ption; | |
| 20 | import jav ax.resourc e.Resource Exception; | |
| 21 | import jav ax.ws.rs.c ore.Respon se; | |
| 22 | import jav ax.ws.rs.c ore.Respon se.Respons eBuilder; | |
| 23 | ||
| 24 | import org .junit.Aft er; | |
| 25 | import org .junit.Bef ore; | |
| 26 | import org .junit.Tes t; | |
| 27 | import org .junit.run ner.RunWit h; | |
| 28 | import org .powermock .core.clas sloader.an notations. PrepareFor Test; | |
| 29 | import org .powermock .modules.j unit4.Powe rMockRunne r; | |
| 30 | ||
| 31 | import com .fasterxml .jackson.c ore.JsonGe nerationEx ception; | |
| 32 | import com .fasterxml .jackson.c ore.JsonPr ocessingEx ception; | |
| 33 | import com .fasterxml .jackson.d atabind.Ob jectMapper ; | |
| 34 | ||
| 35 | import gov .va.med.ex ception.Fo undationsE xception; | |
| 36 | import gov .va.med.mb cp.champva .dao.commo n.IChampVA PayDAO; | |
| 37 | import gov .va.med.mb cp.champva .dao.impl. ChampVAPay DAO; | |
| 38 | import gov .va.med.mb cp.champva .domain.co mmon.ICode Result; | |
| 39 | import gov .va.med.mb cp.champva .domain.im pl.ChampVA Exception; | |
| 40 | import gov .va.med.mb cp.champva .domain.im pl.ChampVA Foundation sException ; | |
| 41 | import gov .va.med.mb cp.champva .domain.im pl.ChampVA NamingExce ption; | |
| 42 | import gov .va.med.mb cp.champva .domain.im pl.ChampVA ResourceEx ception; | |
| 43 | import gov .va.med.mb cp.champva .domain.im pl.ChampVA VLFaultExc eption; | |
| 44 | import gov .va.med.mb cp.champva .domain.im pl.CodeRes ult; | |
| 45 | import gov .va.med.vi stalink.ad apter.reco rd.VistaLi nkFaultExc eption; | |
| 46 | ||
| 47 | /** | |
| 48 | * Test cl ass for Ch ampVAResou rce Class. | |
| 49 | * | |
| 50 | * @author PII | |
| 51 | * @versio n 1.0.0 | |
| 52 | */ | |
| 53 | @RunWith(P owerMockRu nner.class ) | |
| 54 | @PrepareFo rTest({ Re sponse.cla ss }) | |
| 55 | public cla ss ChampVA ResourceTe st { | |
| 56 | ||
| 57 | privat e static f inal Strin g NDC_RESU LT = "No"; | |
| 58 | ||
| 59 | privat e static f inal Strin g CPT_RESU LT = "Yes" ; | |
| 60 | ||
| 61 | privat e static f inal Strin g ICD_RESU LT = "Yes^ I can't lo ve ya 'cau se your fe et's too B IG!"; | |
| 62 | ||
| 63 | privat e static f inal Strin g ICD9 = " 253.8"; // condition al | |
| 64 | ||
| 65 | privat e static f inal Strin g NDC = "5 5700-0373- 30"; // "N o" | |
| 66 | ||
| 67 | privat e static f inal Strin g CPT = "9 8941"; // "Yes" | |
| 68 | ||
| 69 | privat e static f inal Objec t EXPECTED _JSON = "{ \"result\" :\"No\",\" message\": null}"; | |
| 70 | ||
| 71 | privat e ChampVAR esource cr ; | |
| 72 | ||
| 73 | /** | |
| 74 | * The setUp met hod, to be executed before eac h test and initializ e the | |
| 75 | * Cha mpVAResour ce under t est. | |
| 76 | * | |
| 77 | * @th rows java. lang.Excep tion - an Exception propagated during se t up. | |
| 78 | */ | |
| 79 | @Befor e | |
| 80 | public void setU p() throws Exception { | |
| 81 | th is.cr = ne w ChampVAR esource(); | |
| 82 | } | |
| 83 | ||
| 84 | /** | |
| 85 | * The tearDown method, to be execut ed after e ach test a nd dispose of the | |
| 86 | * Cha mpVAResour ce under t est. | |
| 87 | * | |
| 88 | * @th rows java. lang.Excep tion - an Exception propagated during te ar down. | |
| 89 | */ | |
| 90 | @After | |
| 91 | public void tear Down() thr ows Except ion { | |
| 92 | th is.cr = nu ll; | |
| 93 | } | |
| 94 | ||
| 95 | /** | |
| 96 | * Tes t that get CodeResult (code) cal ls | |
| 97 | * cha mpVAPayDAO .getCodeRe sult(codeS ystem, cod e) | |
| 98 | */ | |
| 99 | @Test | |
| 100 | public void test ThatGetCod eResultCal lsChampVAP ayDAOGetCo deResultWi thCodeSyst emAndCode( ) { | |
| 101 | IC odeResult ecr = new CodeResult (ICD_RESUL T); | |
| 102 | th is.cr.code System = " ICD9"; | |
| 103 | tr y { | |
| 104 | IChampVA PayDAO moc kedDAO = m ock(ChampV APayDAO.cl ass); | |
| 105 | when(moc kedDAO.get CodeResult (this.cr.c odeSystem, ICD9)).th enReturn(e cr); | |
| 106 | ||
| 107 | assertNo tNull("cr failed to initialize .", this.c r); | |
| 108 | ||
| 109 | cr.setCh ampVAPayDA O(mockedDA O); | |
| 110 | ||
| 111 | Response resp = cr .getCodeRe sult(ICD9) ; | |
| 112 | ||
| 113 | assertNo tNull("res p is null. ", resp); | |
| 114 | verify(m ockedDAO, times(1)). getCodeRes ult(this.c r.codeSyst em, ICD9); | |
| 115 | ||
| 116 | } catch (Cha mpVAExcept ion e) { | |
| 117 | fail("fa iled with ChampVAExc eption: " + e.getMes sage()); | |
| 118 | } | |
| 119 | } | |
| 120 | ||
| 121 | /** | |
| 122 | * Tes t that get CodeResult (code) cal ls | |
| 123 | * obj ectMapper. writeValue AsString(c odeResult) | |
| 124 | */ | |
| 125 | @Test | |
| 126 | public void test ThatGetCod eResultCal lsObjectMa pperWriteV alueAsStri ngWithCode () { | |
| 127 | IC odeResult ecr = new CodeResult (CPT_RESUL T); | |
| 128 | th is.cr.code System = " CPT"; | |
| 129 | tr y { | |
| 130 | IChampVA PayDAO moc kedDAO = m ock(ChampV APayDAO.cl ass); | |
| 131 | when(moc kedDAO.get CodeResult (this.cr.c odeSystem, CPT)).the nReturn(ec r); | |
| 132 | ||
| 133 | ObjectMa pper mocke dMapper = mock(Objec tMapper.cl ass); | |
| 134 | when(moc kedMapper. writeValue AsString(e cr)).thenR eturn("[]" ); | |
| 135 | ||
| 136 | assertNo tNull("cr failed to initialize .", this.c r); | |
| 137 | ||
| 138 | cr.setCh ampVAPayDA O(mockedDA O); | |
| 139 | cr.setMa pper(mocke dMapper); | |
| 140 | ||
| 141 | Response resp = cr .getCodeRe sult(CPT); | |
| 142 | ||
| 143 | assertNo tNull("res p is null. ", resp); | |
| 144 | verify(m ockedMappe r, times(1 )).writeVa lueAsStrin g(ecr); | |
| 145 | ||
| 146 | } catch (Cha mpVAExcept ion e) { | |
| 147 | fail("fa iled with ChampVAExc eption: " + e.getMes sage()); | |
| 148 | } catch (Jso nProcessin gException e) { | |
| 149 | fail("fa iled with JsonProces singExcept ion: " + e .getMessag e()); | |
| 150 | } | |
| 151 | } | |
| 152 | ||
| 153 | /** | |
| 154 | * Tes t that get CodeResult (code) cal ls Respons e.status(R esponse.St atus.OK), | |
| 155 | * res ponseBuild er.entity( json), and responseB uilder.bui ld() once. | |
| 156 | * | |
| 157 | */ | |
| 158 | @Test | |
| 159 | public void test ThatGetCod eResultCal lsResponse StatusOnce () { | |
| 160 | IC odeResult ecr = new CodeResult (NDC_RESUL T); | |
| 161 | th is.cr.code System = " NDC"; | |
| 162 | tr y { | |
| 163 | IChampVA PayDAO moc kedDAO = m ock(ChampV APayDAO.cl ass); | |
| 164 | when(moc kedDAO.get CodeResult (this.cr.c odeSystem, NDC)).the nReturn(ec r); | |
| 165 | ||
| 166 | Response Builder mo ckedBuilde r = mock(R esponseBui lder.class ); | |
| 167 | when(moc kedBuilder .entity(EX PECTED_JSO N)).thenRe turn(mocke dBuilder); | |
| 168 | Response mockedRes ponse = mo ck(Respons e.class); | |
| 169 | when(moc kedBuilder .build()). thenReturn (mockedRes ponse); | |
| 170 | mockStat ic(Respons e.class); | |
| 171 | when(Res ponse.stat us(Respons e.Status.O K)).thenRe turn(mocke dBuilder); | |
| 172 | ||
| 173 | assertNo tNull("cr failed to initialize .", this.c r); | |
| 174 | ||
| 175 | cr.setCh ampVAPayDA O(mockedDA O); | |
| 176 | ||
| 177 | Response resp = cr .getCodeRe sult(NDC); | |
| 178 | ||
| 179 | assertNo tNull("res p is null. ", resp); | |
| 180 | ||
| 181 | verifySt atic(times (1)); | |
| 182 | Response .status(Re sponse.Sta tus.OK); | |
| 183 | ||
| 184 | verify(m ockedBuild er, times( 1)).entity (EXPECTED_ JSON); | |
| 185 | verify(m ockedBuild er, times( 1)).build( ); | |
| 186 | ||
| 187 | } catch (Cha mpVAExcept ion e) { | |
| 188 | fail("fa iled with ChampVAExc eption: " + e.getMes sage()); | |
| 189 | } | |
| 190 | } | |
| 191 | ||
| 192 | /** | |
| 193 | * Tes t method f or | |
| 194 | * {@l ink gov.va .med.mbcp. champva.re st.ChampVA Resource#g etCodeResu lt(java.la ng.String) }. | |
| 195 | */ | |
| 196 | @Test | |
| 197 | public void test GetCodeRes ult() { | |
| 198 | IC odeResult ecr = new CodeResult (NDC_RESUL T); | |
| 199 | th is.cr.code System = " NDC"; | |
| 200 | tr y { | |
| 201 | IChampVA PayDAO moc kedDAO = m ock(ChampV APayDAO.cl ass); | |
| 202 | when(moc kedDAO.get CodeResult (this.cr.c odeSystem, NDC)).the nReturn(ec r); | |
| 203 | ||
| 204 | assertNo tNull("cr failed to initialize .", this.c r); | |
| 205 | ||
| 206 | cr.setCh ampVAPayDA O(mockedDA O); | |
| 207 | ||
| 208 | Response resp = cr .getCodeRe sult(NDC); | |
| 209 | ||
| 210 | assertNo tNull("res p is null. ", resp); | |
| 211 | assertTr ue(resp.ge tEntity(). equals(EXP ECTED_JSON )); | |
| 212 | } catch (Cha mpVAExcept ion e) { | |
| 213 | fail("fa iled with ChampVAExc eption: " + e.getMes sage()); | |
| 214 | } | |
| 215 | } | |
| 216 | ||
| 217 | /** | |
| 218 | * Tes t that get CodeResult (code) ret urns Inter nal Server Error whe n | |
| 219 | * cha mpVAPayDAO .getCodeRe sult(codeS ystem, cod e) raises a | |
| 220 | * Cha mpVAVLFaul tVAExcepti on | |
| 221 | */ | |
| 222 | @Test | |
| 223 | public void test ThatGetCod eResultRet urnsIntern alServerEr rorOnVista LinkFaultE xception() { | |
| 224 | Vi staLinkFau ltExceptio n vlfe = n ew VistaLi nkFaultExc eption("BO OM!"); | |
| 225 | th is.cr.code System = " NDC"; | |
| 226 | tr y { | |
| 227 | IChampVA PayDAO moc kedDAO = m ock(ChampV APayDAO.cl ass); | |
| 228 | when(moc kedDAO.get CodeResult (this.cr.c odeSystem, NDC)).the nThrow(new ChampVAVL FaultExcep tion(vlfe) ); | |
| 229 | ||
| 230 | assertNo tNull("cr failed to initialize .", this.c r); | |
| 231 | ||
| 232 | cr.setCh ampVAPayDA O(mockedDA O); | |
| 233 | ||
| 234 | Response resp = cr .getCodeRe sult(NDC); | |
| 235 | ||
| 236 | assertNo tNull("res p is null. ", resp); | |
| 237 | assertEq uals(Respo nse.Status .INTERNAL_ SERVER_ERR OR.getStat usCode(), resp.getSt atus()); | |
| 238 | assertEq uals(Champ VAExceptio n.VISTALIN K_FAULT_EX CEPTION, r esp.getHea derString( "Exception ")); | |
| 239 | } catch (Cha mpVAExcept ion e) { | |
| 240 | fail("fa iled with ChampVAExc eption: " + e.getMes sage()); | |
| 241 | } | |
| 242 | } | |
| 243 | ||
| 244 | /** | |
| 245 | * Tes t that get CodeResult (code) ret urns Inter nal Server Error whe n | |
| 246 | * cha mpVAPayDAO .getCodeRe sult(codeS ystem, cod e) raises a | |
| 247 | * Cha mpVAFounda tionsExcep tion | |
| 248 | */ | |
| 249 | @Test | |
| 250 | public void test ThatGetCod eResultRet urnsIntern alServerEr rorOnFound ationsExce ption() { | |
| 251 | Fo undationsE xception f e = new Fo undationsE xception(" BOOM!"); | |
| 252 | th is.cr.code System = " NDC"; | |
| 253 | tr y { | |
| 254 | IChampVA PayDAO moc kedDAO = m ock(ChampV APayDAO.cl ass); | |
| 255 | when(moc kedDAO.get CodeResult (this.cr.c odeSystem, NDC)).the nThrow(new ChampVAFo undationsE xception(f e)); | |
| 256 | ||
| 257 | assertNo tNull("cr failed to initialize .", this.c r); | |
| 258 | ||
| 259 | cr.setCh ampVAPayDA O(mockedDA O); | |
| 260 | ||
| 261 | Response resp = cr .getCodeRe sult(NDC); | |
| 262 | ||
| 263 | assertNo tNull("res p is null. ", resp); | |
| 264 | assertEq uals(Respo nse.Status .INTERNAL_ SERVER_ERR OR.getStat usCode(), resp.getSt atus()); | |
| 265 | assertEq uals(Champ VAExceptio n.FOUNDATI ONS_EXCEPT ION, resp. getHeaderS tring("Exc eption")); | |
| 266 | } catch (Cha mpVAExcept ion e) { | |
| 267 | fail("fa iled with ChampVAExc eption: " + e.getMes sage()); | |
| 268 | } | |
| 269 | } | |
| 270 | ||
| 271 | /** | |
| 272 | * Tes t that get CodeResult (code) ret urns Inter nal Server Error whe n | |
| 273 | * cha mpVAPayDAO .getCodeRe sult(codeS ystem, cod e) raises a | |
| 274 | * Cha mpVANaming Exception | |
| 275 | */ | |
| 276 | @Test | |
| 277 | public void test ThatGetCod eResultRet urnsIntern alServerEr rorOnNamin gException () { | |
| 278 | Na mingExcept ion ne = n ew NamingE xception(" BOOM!"); | |
| 279 | th is.cr.code System = " NDC"; | |
| 280 | tr y { | |
| 281 | IChampVA PayDAO moc kedDAO = m ock(ChampV APayDAO.cl ass); | |
| 282 | when(moc kedDAO.get CodeResult (this.cr.c odeSystem, NDC)).the nThrow(new ChampVANa mingExcept ion(ne)); | |
| 283 | ||
| 284 | assertNo tNull("cr failed to initialize .", this.c r); | |
| 285 | ||
| 286 | cr.setCh ampVAPayDA O(mockedDA O); | |
| 287 | ||
| 288 | Response resp = cr .getCodeRe sult(NDC); | |
| 289 | ||
| 290 | assertNo tNull("res p is null. ", resp); | |
| 291 | assertEq uals(Respo nse.Status .INTERNAL_ SERVER_ERR OR.getStat usCode(), resp.getSt atus()); | |
| 292 | assertEq uals(Champ VAExceptio n.NAMING_E XCEPTION, resp.getHe aderString ("Exceptio n")); | |
| 293 | } catch (Cha mpVAExcept ion e) { | |
| 294 | fail("fa iled with ChampVAExc eption: " + e.getMes sage()); | |
| 295 | } | |
| 296 | } | |
| 297 | ||
| 298 | /** | |
| 299 | * Tes t that get CodeResult (code) ret urns Inter nal Server Error whe n | |
| 300 | * cha mpVAPayDAO .getCodeRe sult(codeS ystem, cod e) raises a | |
| 301 | * Cha mpVAResour ceExceptio n | |
| 302 | */ | |
| 303 | @Test | |
| 304 | public void test ThatGetCod eResultRet urnsIntern alServerEr rorOnResou rceExcepti on() { | |
| 305 | Re sourceExce ption re = new Resou rceExcepti on("BOOM!" ); | |
| 306 | th is.cr.code System = " NDC"; | |
| 307 | tr y { | |
| 308 | IChampVA PayDAO moc kedDAO = m ock(ChampV APayDAO.cl ass); | |
| 309 | when(moc kedDAO.get CodeResult (this.cr.c odeSystem, NDC)).the nThrow(new ChampVARe sourceExce ption(re)) ; | |
| 310 | ||
| 311 | assertNo tNull("cr failed to initialize .", this.c r); | |
| 312 | ||
| 313 | cr.setCh ampVAPayDA O(mockedDA O); | |
| 314 | ||
| 315 | Response resp = cr .getCodeRe sult(NDC); | |
| 316 | ||
| 317 | assertNo tNull("res p is null. ", resp); | |
| 318 | assertEq uals(Respo nse.Status .INTERNAL_ SERVER_ERR OR.getStat usCode(), resp.getSt atus()); | |
| 319 | assertEq uals(Champ VAExceptio n.RESOURCE _EXCEPTION , resp.get HeaderStri ng("Except ion")); | |
| 320 | } catch (Cha mpVAExcept ion e) { | |
| 321 | fail("fa iled with ChampVAExc eption: " + e.getMes sage()); | |
| 322 | } | |
| 323 | } | |
| 324 | ||
| 325 | /** | |
| 326 | * Tes t that get CodeResult (code) ret urns Inter nal Server Error whe n | |
| 327 | * cha mpVAPayDAO .getCodeRe sult(codeS ystem, cod e) raises a | |
| 328 | * Cha mpVAJsonPr ocessingEx ception | |
| 329 | */ | |
| 330 | @Test | |
| 331 | public void test ThatGetCod eResultRet urnsIntern alServerEr rorOnJsonP rocessingE xception() { | |
| 332 | IC odeResult ecr = new CodeResult (NDC_RESUL T); | |
| 333 | Js onProcessi ngExceptio n jpe = ne w JsonGene rationExce ption("BOO M!"); | |
| 334 | th is.cr.code System = " NDC"; | |
| 335 | tr y { | |
| 336 | IChampVA PayDAO moc kedDAO = m ock(ChampV APayDAO.cl ass); | |
| 337 | when(moc kedDAO.get CodeResult (this.cr.c odeSystem, NDC)).the nReturn(ec r); | |
| 338 | ObjectMa pper mocke dMapper = mock(Objec tMapper.cl ass); | |
| 339 | when(moc kedMapper. writeValue AsString(e cr)).thenT hrow(jpe); | |
| 340 | assertNo tNull("cr failed to initialize .", this.c r); | |
| 341 | ||
| 342 | cr.setCh ampVAPayDA O(mockedDA O); | |
| 343 | cr.setMa pper(mocke dMapper); | |
| 344 | ||
| 345 | Response resp = cr .getCodeRe sult(NDC); | |
| 346 | ||
| 347 | assertNo tNull("res p is null. ", resp); | |
| 348 | assertEq uals(Respo nse.Status .INTERNAL_ SERVER_ERR OR.getStat usCode(), resp.getSt atus()); | |
| 349 | assertEq uals(Champ VAExceptio n.JSON_PRO CESSING_EX CEPTION, r esp.getHea derString( "Exception ")); | |
| 350 | } catch (Cha mpVAExcept ion e) { | |
| 351 | fail("fa iled with ChampVAExc eption: " + e.getMes sage()); | |
| 352 | } catch (Jso nProcessin gException e) { | |
| 353 | fail("fa iled with JsonProces singExcept ion: " + e .getMessag e()); | |
| 354 | } | |
| 355 | } | |
| 356 | ||
| 357 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.