Produced by Araxis Merge on 12/8/2017 1:33:39 PM Central 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 | PC_CP4_CiF.zip\FPPS_Backend\fpps_app\src\test\java\gov\va\med\fee\controller | UserRequestControllerTest.java | Fri Dec 8 17:51:36 2017 UTC |
| 2 | PC_CP4_CiF.zip\FPPS_Backend\fpps_app\src\test\java\gov\va\med\fee\controller | UserRequestControllerTest.java | Fri Dec 8 18:30:07 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 5 | 286 |
| 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 | package go v.va.med.f ee.control ler; | |
| 2 | ||
| 3 | import sta tic org.ha mcrest.Mat chers.is; | |
| 4 | import sta tic org.mo ckito.Mock ito.times; | |
| 5 | import sta tic org.mo ckito.Mock ito.verify ; | |
| 6 | import sta tic org.mo ckito.Mock ito.verify NoMoreInte ractions; | |
| 7 | import sta tic org.mo ckito.Mock ito.when; | |
| 8 | import sta tic org.sp ringframew ork.test.w eb.servlet .request.M ockMvcRequ estBuilder s.get; | |
| 9 | import sta tic org.sp ringframew ork.test.w eb.servlet .result.Mo ckMvcResul tHandlers. print; | |
| 10 | import sta tic org.sp ringframew ork.test.w eb.servlet .result.Mo ckMvcResul tMatchers. content; | |
| 11 | import sta tic org.sp ringframew ork.test.w eb.servlet .result.Mo ckMvcResul tMatchers. jsonPath; | |
| 12 | import sta tic org.sp ringframew ork.test.w eb.servlet .result.Mo ckMvcResul tMatchers. status; | |
| 13 | ||
| 14 | import jav a.util.Arr ays; | |
| 15 | ||
| 16 | import org .apache.lo gging.log4 j.LogManag er; | |
| 17 | import org .apache.lo gging.log4 j.Logger; | |
| 18 | import org .junit.Bef ore; | |
| 19 | import org .junit.Tes t; | |
| 20 | import org .junit.run ner.RunWit h; | |
| 21 | import org .mockito.I njectMocks ; | |
| 22 | import org .mockito.M ock; | |
| 23 | import org .mockito.r unners.Moc kitoJUnitR unner; | |
| 24 | import org .springfra mework.htt p.MediaTyp e; | |
| 25 | import org .springfra mework.tes t.web.serv let.MockMv c; | |
| 26 | import org .springfra mework.tes t.web.serv let.setup. MockMvcBui lders; | |
| 27 | import org .springfra mework.web .servlet.m vc.method. annotation .Exception HandlerExc eptionReso lver; | |
| 28 | ||
| 29 | import gov .va.med.fe e.model.re sponse.Use rReqRespon se; | |
| 30 | import gov .va.med.fe e.service. IUserReque stService; | |
| 31 | ||
| 32 | @RunWith(M ockitoJUni tRunner.cl ass) | |
| 33 | public cla ss UserReq uestContro llerTest { | |
| 34 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(User RequestCon trollerTes t.class); | |
| 35 | ||
| 36 | pr ivate Mock Mvc mockMv c; | |
| 37 | ||
| 38 | @I njectMocks | |
| 39 | Us erRequestC ontroller userReques tControlle r; | |
| 40 | ||
| 41 | @M ock | |
| 42 | IU serRequest Service us erRequestS ervice; | |
| 43 | ||
| 44 | @B efore | |
| 45 | pu blic void init() thr ows Except ion { | |
| 46 | mock Mvc = Mock MvcBuilder s.standalo neSetup(us erRequestC ontroller) .setHandle rException Resolvers( new Except ionHandler ExceptionR esolver()) .build(); | |
| 47 | } | |
| 48 | ||
| 49 | @T est | |
| 50 | pu blic void testLoadRe questUser( ) throws E xception { | |
| 51 | Stri ng [] avai lable_role s = new St ring[] {"F PPS_HELP_D ESK","FEE_ SUPERVISOR ","FEE_VIS N_PGM_MANA GER"}; | |
| 52 | ||
| 53 | //St ring facLa bel = "Vis n: " + req .getVisnId Cd() + " / Facility: " + req.g etVaFacili tyCd() + r eq.getShor tName(); | |
| 54 | Stri ng [] avai lable_faci lities = n ew String[ ] {"Visn: 16 / Facil ity: 520 ( BILOXI MS) ","Visn: 1 6 / Facili ty: 564 (F ayettevill e NC VAMC) "}; | |
| 55 | User ReqRespons e response = new Use rReqRespon se(Arrays. asList(ava ilable_rol es), Array s.asList(a vailable_f acilities) ); | |
| 56 | ||
| 57 | when (userReque stService. loadUserRe questForm( )).thenRet urn(respon se); | |
| 58 | ||
| 59 | mock Mvc.perfor m(get("/ap i/v1/userR equest/for m")).andDo (print()). andExpect( status().i sOk()) | |
| 60 | .andExpe ct(content ().content Type(Media Type.APPLI CATION_JSO N_UTF8_VAL UE)) | |
| 61 | .andExpe ct(jsonPat h("$.avail able_roles [0]", is(" FPPS_HELP_ DESK"))) | |
| 62 | .andExpe ct(jsonPat h("$.avail able_roles [1]", is(" FEE_SUPERV ISOR"))) | |
| 63 | .andExpe ct(jsonPat h("$.avail able_roles [2]", is(" FEE_VISN_P GM_MANAGER "))) | |
| 64 | .andExpe ct(jsonPat h("$.avail able_facil ities[0]", is("Visn: 16 / Faci lity: 520 (BILOXI MS )"))) | |
| 65 | .andExpe ct(jsonPat h("$.avail able_facil ities[1]", is("Visn: 16 / Faci lity: 564 (Fayettevi lle NC VAM C)"))); | |
| 66 | ||
| 67 | veri fy(userReq uestServic e, times(1 )).loadUse rRequestFo rm(); | |
| 68 | veri fyNoMoreIn teractions (userReque stService) ; | |
| 69 | } | |
| 70 | ||
| 71 | ||
| 72 | @T est | |
| 73 | pu blic void testLoadRe questModif yUser() th rows Excep tion { | |
| 74 | // s et up | |
| 75 | long appUserRe questId = 1L; | |
| 76 | Stri ng current _user_name = "VHAISM BAIAHBBB"; | |
| 77 | String win dow_nt_nam e = " DN S ABBA"; | |
| 78 | Stri ng last_na me = "Jack son"; | |
| 79 | Stri ng middle_ name = "B" ; | |
| 80 | Stri ng first_n ame = "Jac ky"; | |
| 81 | Stri ng phone = "98765432 10"; | |
| 82 | String ema il = " PII "; | |
| 83 | bool ean enable d = Boolea n.TRUE; | |
| 84 | Stri ng disable _comments = "CCSE"; | |
| 85 | ||
| 86 | Stri ng [] avai lable_role s = new St ring[] {"F PPS_HELP_D ESK"}; | |
| 87 | Stri ng [] avai lable_faci lities = n ew String[ ] {"Visn: 16 / Facil ity: 520 ( BILOXI MS) ","Visn: 1 6 / Facili ty: 564 (F ayettevill e NC VAMC) ","Visn: 1 6 / Facili ty: 565 (F ayettevill e NC VAMC) "}; | |
| 88 | Stri ng [] requ est_roles = new Stri ng[] {};// "FPPS_HEL P_DESK"}; | |
| 89 | Stri ng [] requ est_facili ties = new String[] {"Visn: 16 / Facilit y: 520 (BI LOXI MS)", "Visn: 16 / Facility : 564 (Fay etteville NC VAMC)"} ; | |
| 90 | ||
| 91 | User ReqRespons e resp = n ew UserReq Response(w indow_nt_n ame, last_ name, firs t_name, mi ddle_name, | |
| 92 | phone, e mail, enab led, disab le_comment s, Arrays. asList(req uest_roles ), Arrays. asList(req uest_facil ities)); | |
| 93 | resp .setAvaila ble_roles( Arrays.as List(avail able_roles )); | |
| 94 | resp .setAvaila ble_facili ties(Array s.asList(a vailable_f acilities) ); | |
| 95 | ||
| 96 | ||
| 97 | when (userReque stService. loadModify UserReques tFormByNam e(current_ user_name) ).thenRetu rn(resp); | |
| 98 | ||
| 99 | mock Mvc.perfor m(get("/ap i/v1/userR equest/for m/{userNam e}", curre nt_user_na me)).andDo (print()). andExpect( status().i sOk()) | |
| 100 | .and Expect(con tent().con tentType(M ediaType.A PPLICATION _JSON_UTF8 _VALUE)); | |
| 101 | // . andExpect( jsonPath(" $.result", is(1))); | |
| 102 | } | |
| 103 | ||
| 104 | /* @Test | |
| 105 | pu blic void test_reque stAddUser( ) throws E xception { | |
| 106 | // s et up | |
| 107 | Stri ng current _user_name = "VHAISM BAIAHBBB"; | |
| 108 | String win dow_nt_nam e = " DN S ABBA"; | |
| 109 | Stri ng last_na me = "Jack son"; | |
| 110 | Stri ng middle_ name = "B" ; | |
| 111 | Stri ng first_n ame = "Jac ky"; | |
| 112 | Stri ng phone = "98765432 10"; | |
| 113 | String ema il = " PII "; | |
| 114 | bool ean enable d = Boolea n.TRUE; | |
| 115 | ||
| 116 | Stri ng [] requ est_roles = new Stri ng[] {};// "FPPS_HEL P_DESK"}; | |
| 117 | Stri ng [] requ est_facili ties = new String[] {"Visn: 16 / Facilit y: 520 (BI LOXI MS)", "Visn: 16 / Facility : 564 (Fay etteville NC VAMC)"} ; | |
| 118 | ||
| 119 | User ReqRequest req = new UserReqRe quest(curr ent_user_n ame, windo w_nt_name, last_name , first_na me, middle _name, pho ne, | |
| 120 | email, e nabled, Ar rays.asLis t(request_ roles), Ar rays.asLis t(request_ facilities )); | |
| 121 | ||
| 122 | when (userReque stService. requestAdd User(req)) .thenRetur n(1); | |
| 123 | ||
| 124 | mock Mvc.perfor m(post("/a pi/v1/user Request/") .contentTy pe(MediaTy pe.APPLICA TION_JSON) | |
| 125 | .content (getReques tJson(req) )).andDo(p rint()); | |
| 126 | ||
| 127 | veri fy(userReq uestServic e, times(1 )).request AddUser(re q); | |
| 128 | } | |
| 129 | ||
| 130 | pr ivate Stri ng getRequ estJson(Ob ject reque st) { | |
| 131 | Stri ng request Json = nul l; | |
| 132 | try { | |
| 133 | Object Mapper map per = new ObjectMapp er(); | |
| 134 | mapper.con figure(Ser ialization Feature.WR AP_ROOT_VA LUE, false ); | |
| 135 | ObjectWrit er ow = ma pper.write r().withDe faultPrett yPrinter() ; | |
| 136 | reques tJson = ow .writeValu eAsString( request); | |
| 137 | System .out.print ln("reques tJson - " + requestJ son); | |
| 138 | ||
| 139 | } ca tch (JsonP rocessingE xception e ) { | |
| 140 | logger .error("te stRequestA ddUser Jso nProcessin gException -- "); | |
| 141 | e.prin tStackTrac e(); | |
| 142 | ||
| 143 | } | |
| 144 | ||
| 145 | retu rn request Json; | |
| 146 | }* / | |
| 147 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.