Produced by Araxis Merge on 4/2/2019 1:06:57 PM 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 | C:\AraxisMergeCompare\Pri_un\ARS_Backend\ars_app\src\test\java\gov\va\med\ars\controller | UserAdministrationRestControllerTest.java | Wed Mar 27 19:21:15 2019 UTC |
2 | C:\AraxisMergeCompare\Pri_re\ARS_Backend\ars_app\src\test\java\gov\va\med\ars\controller | UserAdministrationRestControllerTest.java | Fri Mar 29 17:40:30 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 8 | 444 |
Changed | 7 | 14 |
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 gov.va.med .ars.contr oller; | |
2 | ||
3 | import sta tic org.ha mcrest.Mat chers.is; | |
4 | import sta tic org.mo ckito.Matc hers.any; | |
5 | import sta tic org.mo ckito.Mock ito.times; | |
6 | import sta tic org.mo ckito.Mock ito.verify ; | |
7 | import sta tic org.mo ckito.Mock ito.verify NoMoreInte ractions; | |
8 | import sta tic org.mo ckito.Mock ito.when; | |
9 | import sta tic org.sp ringframew ork.test.w eb.servlet .request.M ockMvcRequ estBuilder s.get; | |
10 | import sta tic org.sp ringframew ork.test.w eb.servlet .request.M ockMvcRequ estBuilder s.post; | |
11 | import sta tic org.sp ringframew ork.test.w eb.servlet .result.Mo ckMvcResul tHandlers. print; | |
12 | import sta tic org.sp ringframew ork.test.w eb.servlet .result.Mo ckMvcResul tMatchers. content; | |
13 | import sta tic org.sp ringframew ork.test.w eb.servlet .result.Mo ckMvcResul tMatchers. jsonPath; | |
14 | import sta tic org.sp ringframew ork.test.w eb.servlet .result.Mo ckMvcResul tMatchers. status; | |
15 | ||
16 | import jav a.nio.char set.Charse t; | |
17 | import jav a.util.Arr ayList; | |
18 | import jav a.util.Lis t; | |
19 | ||
20 | import org .apache.lo gging.log4 j.LogManag er; | |
21 | import org .apache.lo gging.log4 j.Logger; | |
22 | import org .junit.Bef ore; | |
23 | import org .junit.Tes t; | |
24 | import org .junit.run ner.RunWit h; | |
25 | import org .mockito.I njectMocks ; | |
26 | import org .mockito.M atchers; | |
27 | import org .mockito.M ock; | |
28 | import org .mockito.M ockitoAnno tations; | |
29 | import org .mockito.r unners.Moc kitoJUnitR unner; | |
30 | import org .springfra mework.htt p.HttpStat us; | |
31 | import org .springfra mework.htt p.MediaTyp e; | |
32 | import org .springfra mework.tes t.web.serv let.MockMv c; | |
33 | import org .springfra mework.tes t.web.serv let.Result Actions; | |
34 | import org .springfra mework.tes t.web.serv let.setup. MockMvcBui lders; | |
35 | ||
36 | import com .fasterxml .jackson.d atabind.Ob jectMapper ; | |
37 | import com .fasterxml .jackson.d atabind.Ob jectWriter ; | |
38 | import com .fasterxml .jackson.d atabind.Se rializatio nFeature; | |
39 | ||
40 | import gov .va.med.ar s.constant s.ErrorMes sages; | |
41 | import gov .va.med.ar s.exceptio ns.Generic Exception; | |
42 | import gov .va.med.ar s.filter.C ORSFilter; | |
43 | import gov .va.med.ar s.model.re quest.User SearchRequ est; | |
44 | import gov .va.med.ar s.model.re sponse.Gen ericRespon se; | |
45 | import gov .va.med.ar s.model.re sponse.Use rDetailsRe sponse; | |
46 | import gov .va.med.ar s.service. IUserAdmin istrationS ervice; | |
47 | import jav afx.util.P air; | |
48 | ||
49 | @RunWith(M ockitoJUni tRunner.cl ass) | |
50 | public cla ss UserAdm inistratio nRestContr ollerTest { | |
51 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(User Administra tionRestCo ntrollerTe st.class); | |
52 | pr ivate Mock Mvc mockMv c; | |
53 | pu blic stati c final Me diaType AP PLICATION_ JSON_UTF8 = new Medi aType(Medi aType.APPL ICATION_JS ON.getType (), | |
54 | MediaT ype.APPLIC ATION_JSON .getSubtyp e(), Chars et.forName ("utf8")); | |
55 | ||
56 | @M ock | |
57 | pr ivate IUse rAdministr ationServi ce userAdm inistratio nService; | |
58 | ||
59 | @M ock | |
60 | pr ivate Gene ricExcepti on generic Exception = new Gene ricExcepti on(ErrorMe ssages.INV ALID_REQUE ST, | |
61 | "At le ast one fi eld inform ation need s to be ad ded", Http Status.NOT _FOUND); | |
62 | ||
63 | @I njectMocks | |
64 | pr ivate User Administra tionRestCo ntroller u serAdminis trationRes tControlle r; | |
65 | ||
66 | @B efore | |
67 | pu blic void init() thr ows Except ion { | |
68 | Mock itoAnnotat ions.initM ocks(this) ; | |
69 | mock Mvc = Mock MvcBuilder s.standalo neSetup(us erAdminist rationRest Controller ).addFilte rs(new COR SFilter()) | |
70 | .build() ; | |
71 | } | |
72 | ||
73 | @T est | |
74 | pu blic void testsearch AllUsers() throws Ex ception { | |
75 | User SearchRequ est userSe archReques t = new Us erSearchRe quest(); | |
76 | user SearchRequ est.setAdm in("true") ; | |
77 | user SearchRequ est.setCre atedBy("") ; | |
78 | user SearchRequ est.setDes cending(fa lse); | |
79 | user SearchRequ est.setDom ain(""); | |
80 | user SearchRequ est.setEdi t(""); | |
81 | user SearchRequ est.setEma il(""); | |
82 | user SearchRequ est.setExp ort(""); | |
83 | user SearchRequ est.setFir stName("") ; | |
84 | user SearchRequ est.setLas tName(""); | |
85 | user SearchRequ est.setPag eNumber(1) ; | |
86 | user SearchRequ est.setPag eSize(10); | |
87 | user SearchRequ est.setPho ne(""); | |
88 | user SearchRequ est.setSor tColumn("" ); | |
89 | user SearchRequ est.setSta tus(""); | |
90 | userSearch Request.se tUserName( "
|
|
91 | user SearchRequ est.setExp ort("Y"); | |
92 | user SearchRequ est.setEdi t("Y"); | |
93 | user SearchRequ est.setAdm in("Y"); | |
94 | ||
95 | User DetailsRes ponse user DetailsRes ponse = ne w UserDeta ilsRespons e(); | |
96 | List <UserDetai lsResponse > listuser Details = new ArrayL ist<>(); | |
97 | user DetailsRes ponse.setS tatus("act ive"); | |
98 | user DetailsRes ponse.setD omain("Bas e"); | |
99 | userDetail sResponse. setUserNam e("
|
|
100 | user DetailsRes ponse.setE xport("y") ; | |
101 | user DetailsRes ponse.setA dmin("y"); | |
102 | user DetailsRes ponse.setE dit("y"); | |
103 | list userDetail s.add(user DetailsRes ponse); | |
104 | ||
105 | Gene ricRespons e genericR esponse = new Generi cResponse( ); | |
106 | gene ricRespons e.setpageN umber(1); | |
107 | gene ricRespons e.setpageS ize(10); | |
108 | gene ricRespons e.setsortC olumn("use rName"); | |
109 | gene ricRespons e.settotal NumberOfRe sults((lon g) 3); | |
110 | gene ricRespons e.setRespo nse(listus erDetails) ; | |
111 | ||
112 | when (userAdmin istrationS ervice.get AllUserDet ails(any(U serSearchR equest.cla ss))).then Return(gen ericRespon se); | |
113 | ||
114 | Obje ctMapper m apper = ne w ObjectMa pper(); | |
115 | mapp er.configu re(Seriali zationFeat ure.WRAP_R OOT_VALUE, false); | |
116 | Obje ctWriter o w = mapper .writer(). withDefaul tPrettyPri nter(); | |
117 | Stri ng request Json = ow. writeValue AsString(u serSearchR equest); | |
118 | mock Mvc.perfor m(post("/a pi/v1/user Search").c ontentType (MediaType .APPLICATI ON_JSON).c ontent(req uestJson)) | |
119 | .andDo(p rint()).an dExpect(st atus().isO k()) | |
120 | .andExpe ct(content ().content Type("appl ication/js on;charset =UTF-8")) | |
121 | .andExpe ct(jsonPat h("$.pageN umber", is (1))).andE xpect(json Path("$.pa geSize", i s(10))) | |
122 | .andExpe ct(jsonPat h("$.sortC olumn", is ("userName "))) | |
123 | .andExpe ct(jsonPat h("$.total NumberOfRe sults", is (3))) | |
124 | .andExpe ct(jsonPat h("$.respo nse[0].sta tus", is(" active"))) | |
125 | .andExpe ct(jsonPat h("$.respo nse[0].dom ain", is(" Base"))) | |
126 | .andExpect (jsonPath( "$.respons e[0].userN ame", is("
|
|
127 | .andExpe ct(jsonPat h("$.respo nse[0].exp ort", is(" y"))) | |
128 | .andExpe ct(jsonPat h("$.respo nse[0].adm in", is("y "))).andEx pect(jsonP ath("$.res ponse[0].e dit", is(" y"))); | |
129 | ||
130 | veri fy(userAdm inistratio nService, times(1)). getAllUser Details(Ma tchers.ref Eq(userSea rchRequest )); | |
131 | veri fyNoMoreIn teractions (userAdmin istrationS ervice); | |
132 | ||
133 | } | |
134 | ||
135 | @T est | |
136 | pu blic void testEditUs erSuccess( ) throws E xception { | |
137 | Pair <String, B oolean> pa irResult = new Pair <>("succes s", true); | |
138 | User SearchRequ est userSe archReques t = new Us erSearchRe quest(); | |
139 | user SearchRequ est.setAdm in("true") ; | |
140 | user SearchRequ est.setCre atedBy("") ; | |
141 | user SearchRequ est.setDes cending(fa lse); | |
142 | user SearchRequ est.setDom ain(""); | |
143 | user SearchRequ est.setEdi t(""); | |
144 | user SearchRequ est.setEma il(""); | |
145 | user SearchRequ est.setExp ort(""); | |
146 | user SearchRequ est.setFir stName("") ; | |
147 | user SearchRequ est.setLas tName(""); | |
148 | user SearchRequ est.setPag eNumber(1) ; | |
149 | user SearchRequ est.setPag eSize(10); | |
150 | user SearchRequ est.setPho ne(""); | |
151 | user SearchRequ est.setSor tColumn("" ); | |
152 | user SearchRequ est.setSta tus(""); | |
153 | userSearch Request.se tUserName( "
|
|
154 | user SearchRequ est.setExp ort("Y"); | |
155 | user SearchRequ est.setEdi t("Y"); | |
156 | user SearchRequ est.setAdm in("Y"); | |
157 | ||
158 | when (userAdmin istrationS ervice.edi tUserByUse rName(user SearchRequ est)).then Return(pai rResult); | |
159 | ||
160 | Obje ctMapper m apper = ne w ObjectMa pper(); | |
161 | mapp er.configu re(Seriali zationFeat ure.WRAP_R OOT_VALUE, false); | |
162 | Obje ctWriter o w = mapper .writer(). withDefaul tPrettyPri nter(); | |
163 | Stri ng request Json = ow. writeValue AsString(u serSearchR equest); | |
164 | Resu ltActions andExpect = mockMvc | |
165 | .perform (post("/ap i/v1/editU ser").cont entType(Me diaType.AP PLICATION_ JSON).cont ent(reques tJson)) | |
166 | .andDo(p rint()).an dExpect(st atus().is( 200)); | |
167 | logg er.info("s tatus resu lts:" + an dExpect.an dReturn(). getRespons e().getCon tentAsStri ng()); | |
168 | ||
169 | veri fy(userAdm inistratio nService, times(1)). editUserBy UserName(M atchers.re fEq(userSe archReques t)); | |
170 | veri fyNoMoreIn teractions (userAdmin istrationS ervice); | |
171 | ||
172 | } | |
173 | ||
174 | @T est | |
175 | pu blic void testgetUse rByIdSucce ss() throw s Exceptio n { | |
176 | Stri ng userId = "100"; | |
177 | User DetailsRes ponse user DetailsRes ponse = ne w UserDeta ilsRespons e(); | |
178 | user DetailsRes ponse.setS tatus("Use r"); | |
179 | user DetailsRes ponse.setD omain("Bas e"); | |
180 | userDetail sResponse. setUserNam e("
|
|
181 | user DetailsRes ponse.setE xport("y") ; | |
182 | user DetailsRes ponse.setA dmin("y"); | |
183 | user DetailsRes ponse.setE dit("y"); | |
184 | ||
185 | when (userAdmin istrationS ervice.get UserDetail s(userId, "ARS")).th enReturn(u serDetails Response); | |
186 | Obje ctMapper m apper = ne w ObjectMa pper(); | |
187 | mapp er.configu re(Seriali zationFeat ure.WRAP_R OOT_VALUE, false); | |
188 | Obje ctWriter o w = mapper .writer(). withDefaul tPrettyPri nter(); | |
189 | Stri ng request Json = ow. writeValue AsString(u serId); | |
190 | mock Mvc.perfor m( | |
191 | get("/ap i/v1/userD etails/" + userId).c ontentType (MediaType .APPLICATI ON_JSON).c ontent(req uestJson)) | |
192 | .andDo(p rint()).an dExpect(st atus().isO k()) | |
193 | .andExpe ct(jsonPat h("$.domai n", is("Ba se"))) | |
194 | .andExpect (jsonPath( "$.userNam e", is("
|
|
195 | .andExpe ct(jsonPat h("$.expor t", is("y" ))) | |
196 | .andExpe ct(jsonPat h("$.admin ", is("y") )) | |
197 | .andExpe ct(jsonPat h("$.edit" , is("y")) ) | |
198 | .andExpe ct(jsonPat h("$.statu s", is("Us er"))); | |
199 | ||
200 | veri fy(userAdm inistratio nService, times(1)). getUserDet ails(Match ers.refEq( userId), " ARS"); | |
201 | veri fyNoMoreIn teractions (userAdmin istrationS ervice); | |
202 | ||
203 | } | |
204 | ||
205 | @T est | |
206 | pu blic void testdelete UserSucces s() throws Exception { | |
207 | Long userId = (long) 100 ; | |
208 | User DetailsRes ponse user DetailsRes ponse = ne w UserDeta ilsRespons e(); | |
209 | user DetailsRes ponse.setS tatus("Use r"); | |
210 | user DetailsRes ponse.setD omain("Bas e"); | |
211 | userDetail sResponse. setUserNam e("
|
|
212 | user DetailsRes ponse.setE xport("1") ; | |
213 | user DetailsRes ponse.setA dmin("!"); | |
214 | user DetailsRes ponse.setE dit("2"); | |
215 | ||
216 | when (userAdmin istrationS ervice.del eteUserByU serName(us erId)).the nReturn(tr ue); | |
217 | Obje ctMapper m apper = ne w ObjectMa pper(); | |
218 | mapp er.configu re(Seriali zationFeat ure.WRAP_R OOT_VALUE, false); | |
219 | Obje ctWriter o w = mapper .writer(). withDefaul tPrettyPri nter(); | |
220 | Stri ng request Json = ow. writeValue AsString(u serId); | |
221 | mock Mvc.perfor m( | |
222 | get("/ap i/v1/userD elete/" + userId).co ntentType( MediaType. APPLICATIO N_JSON).co ntent(requ estJson)) | |
223 | .andDo(p rint()).an dExpect(st atus().isO k()); | |
224 | veri fy(userAdm inistratio nService, times(1)). deleteUser ByUserName (Matchers. refEq(user Id)); | |
225 | veri fyNoMoreIn teractions (userAdmin istrationS ervice); | |
226 | } | |
227 | ||
228 | } | |
229 | */ |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.