Produced by Araxis Merge on 2/4/2019 11:34:05 AM 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 | MHPRO_v1.x.zip\mhpro-resources-master@a26412b610c.zip\ws\src\test\java\gov\va\mobile\vamf\mhpro\resource | ProviderGetPatientAssessmentTest.java | Tue Nov 14 19:31:17 2017 UTC |
| 2 | MHPRO_v1.x.zip\mhpro-resources-master@a26412b610c.zip\ws\src\test\java\gov\va\mobile\vamf\mhpro\resource | ProviderGetPatientAssessmentTest.java | Fri Feb 1 19:27:42 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1484 |
| 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 | package go v.va.mobil e.vamf.mhp ro.resourc e; | |
| 2 | ||
| 3 | import sta tic org.ha mcrest.Mat cherAssert .assertTha t; | |
| 4 | import sta tic org.ha mcrest.Mat chers.cont ainsString ; | |
| 5 | import sta tic org.ju nit.Assert .assertTru e; | |
| 6 | import sta tic org.mo ckito.Matc hers.any; | |
| 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 tMatchers. status; | |
| 10 | ||
| 11 | import jav a.lang.ref lect.Type; | |
| 12 | import jav a.util.Arr ayList; | |
| 13 | import jav a.util.Arr ays; | |
| 14 | import jav a.util.Col lection; | |
| 15 | import jav a.util.Ite rator; | |
| 16 | import jav a.util.Lis t; | |
| 17 | ||
| 18 | import org .joda.time .DateTime; | |
| 19 | import org .joda.time .DateTimeZ one; | |
| 20 | import org .junit.Aft er; | |
| 21 | import org .junit.Bef ore; | |
| 22 | import org .junit.Tes t; | |
| 23 | import org .junit.run ner.RunWit h; | |
| 24 | import org .mockito.M ock; | |
| 25 | import org .mockito.M ockito; | |
| 26 | import org .mockito.M ockitoAnno tations; | |
| 27 | import org .mockito.i nvocation. Invocation OnMock; | |
| 28 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 29 | import org .springfra mework.htt p.MediaTyp e; | |
| 30 | import org .springfra mework.sec urity.core .Authentic ation; | |
| 31 | import org .springfra mework.sec urity.core .GrantedAu thority; | |
| 32 | import org .springfra mework.tes t.context. ContextCon figuration ; | |
| 33 | import org .springfra mework.tes t.context. junit4.Spr ingJUnit4C lassRunner ; | |
| 34 | import org .springfra mework.tes t.context. web.WebApp Configurat ion; | |
| 35 | import org .springfra mework.tes t.util.Ref lectionTes tUtils; | |
| 36 | import org .springfra mework.tes t.web.serv let.MvcRes ult; | |
| 37 | ||
| 38 | import com .agilex.he althcare.m obilehealt hplatform. domain.Mhp User; | |
| 39 | import com .agilex.he althcare.m obilehealt hplatform. domain.Pat ientIdenti fier; | |
| 40 | import com .agilex.he althcare.m obilehealt hplatform. security.R oles; | |
| 41 | import com .fasterxml .jackson.d atabind.Ob jectMapper ; | |
| 42 | import com .fasterxml .jackson.d atabind.Se rializatio nFeature; | |
| 43 | import com .fasterxml .jackson.d atatype.jo da.JodaMod ule; | |
| 44 | import com .google.gs on.Gson; | |
| 45 | import com .google.gs on.GsonBui lder; | |
| 46 | import com .google.gs on.JsonArr ay; | |
| 47 | import com .google.gs on.JsonDes erializati onContext; | |
| 48 | import com .google.gs on.JsonDes erializer; | |
| 49 | import com .google.gs on.JsonEle ment; | |
| 50 | import com .google.gs on.JsonPri mitive; | |
| 51 | import com .google.gs on.JsonSer ialization Context; | |
| 52 | import com .google.gs on.JsonSer ializer; | |
| 53 | ||
| 54 | import gov .va.mobile .vamf.mhpr o.datalaye r.Assessme ntReposito ry; | |
| 55 | import gov .va.mobile .vamf.mhpr o.datalaye r.Assignme ntReposito ry; | |
| 56 | import gov .va.mobile .vamf.mhpr o.datalaye r.EventRep ository; | |
| 57 | import gov .va.mobile .vamf.mhpr o.datalaye r.QuartzSe maphoreRep ository; | |
| 58 | import gov .va.mobile .vamf.mhpr o.domain.A nswer; | |
| 59 | import gov .va.mobile .vamf.mhpr o.domain.A ssessment; | |
| 60 | import gov .va.mobile .vamf.mhpr o.domain.A ssessmentV oiceInfo.A ssessmentS everity; | |
| 61 | import gov .va.mobile .vamf.mhpr o.domain.A ssignment; | |
| 62 | import gov .va.mobile .vamf.mhpr o.domain.E vent; | |
| 63 | import gov .va.mobile .vamf.mhpr o.domain.F ormat; | |
| 64 | import gov .va.mobile .vamf.mhpr o.domain.R esponse; | |
| 65 | import gov .va.mobile .vamf.mhpr o.domain.R esponseSec tion; | |
| 66 | import gov .va.mobile .vamf.mhpr o.domain.S core; | |
| 67 | import gov .va.mobile .vamf.mhpr o.domain.S coreMetaDa ta; | |
| 68 | import gov .va.mobile .vamf.mhpr o.jobs.Eve ntsJob; | |
| 69 | import gov .va.mobile .vamf.mhpr o.service. ICurrentUs erService; | |
| 70 | import gov .va.mobile .vamf.mhpr o.service. impl.Asses smentServi ce; | |
| 71 | import gov .va.mobile .vamf.mhpr o.service. impl.Event Service; | |
| 72 | import gov .va.mobile .vamf.mhpr o.service. impl.MVICo nversionSe rvice; | |
| 73 | import gov .va.mobile .vamf.mhpr o.service. impl.Vista Assessment Service; | |
| 74 | ||
| 75 | /** | |
| 76 | * The pro viderGetPa tientAsses sment Test . | |
| 77 | */ | |
| 78 | @RunWith(S pringJUnit 4ClassRunn er.class) | |
| 79 | @WebAppCon figuration | |
| 80 | @ContextCo nfiguratio n({ "class path:appli cationCont ext.xml", "classpath :dispatche r-servlet. xml", | |
| 81 | "cla sspath:mon goContext. xml" }) | |
| 82 | /** | |
| 83 | * | |
| 84 | * @author PII | |
| 85 | * | |
| 86 | */ | |
| 87 | public cla ss Provide rGetPatien tAssessmen tTest exte nds Abstra ctMVCContr ollerTeste r { | |
| 88 | ||
| 89 | pr ivate stat ic List<St ring> asse ssmentIds = new Arra yList<Stri ng>(); | |
| 90 | ||
| 91 | pr ivate stat ic List<St ring> assi gnmentIds = new Arra yList<Stri ng>(); | |
| 92 | ||
| 93 | pr ivate stat ic String patientId0 = "6 66000000"; | |
| 94 | pr ivate stat ic String patientId = "6 66000001"; | |
| 95 | pr ivate stat ic String providerId 1 = "76660 0001"; | |
| 96 | pr ivate stat ic String providerId 2 = "76660 0002"; | |
| 97 | pr ivate stat ic String providerId 3 = "76660 0003"; | |
| 98 | pr ivate stat ic String providerId 4 = "76660 0004"; | |
| 99 | pr ivate stat ic String providerId 5 = "76660 0004"; | |
| 100 | ||
| 101 | pr ivate stat ic String assessment Id1; | |
| 102 | pr ivate stat ic String assessment Id2; | |
| 103 | pr ivate stat ic String assessment Id3; | |
| 104 | ||
| 105 | pr ivate stat ic String rawScore1 = "13"; | |
| 106 | pr ivate stat ic Assessm entSeverit y severity 1 = Assess mentSeveri ty.MODERAT E; | |
| 107 | ||
| 108 | pr ivate stat ic String rawScore2 = "15"; | |
| 109 | pr ivate stat ic Assessm entSeverit y severity 2 = Assess mentSeveri ty.MILD; | |
| 110 | ||
| 111 | pr ivate stat ic String rawScore3 = "77"; | |
| 112 | pr ivate stat ic Assessm entSeverit y severity 3 = Assess mentSeveri ty.SEVERE; | |
| 113 | ||
| 114 | pr ivate stat ic String rawScore4 = "55"; | |
| 115 | pr ivate stat ic Assessm entSeverit y severity 4 = Assess mentSeveri ty.HIGH; | |
| 116 | ||
| 117 | pr ivate stat ic String rawScore5 = "50"; | |
| 118 | pr ivate stat ic Assessm entSeverit y severity 5 = Assess mentSeveri ty.HIGH; | |
| 119 | ||
| 120 | pr ivate stat ic List<St ring> assi gnmentIdsF orDates = Arrays.asL ist("12345 67890", "2 234567890" , "3234567 890", | |
| 121 | "42345 67890", "5 234567890" , "6234567 890", "723 4567890", "823456789 0"); | |
| 122 | pr ivate stat ic List<St ring> assi gnmentIdsF orDatesFin alize = Ar rays.asLis t("9912345 67890", "9 9223456789 0", "99323 4567890", | |
| 123 | "99423 4567890", "995234567 890", "996 234567890" , "9972345 67890", "9 9823456789 0"); | |
| 124 | ||
| 125 | pr ivate stat ic String INSTRUCTIO NS = "orig inal instr uctions"; | |
| 126 | ||
| 127 | /* * The gson . */ | |
| 128 | pr ivate stat ic Gson gs on; | |
| 129 | ||
| 130 | @M ock | |
| 131 | pr ivate Vist aAssessmen tService v istaAssess mentServic e; | |
| 132 | @M ock | |
| 133 | pr ivate ICur rentUserSe rvice user Service; | |
| 134 | @M ock | |
| 135 | pr ivate MVIC onversionS ervice mvi Conversion Service; | |
| 136 | @M ock | |
| 137 | pr ivate Even tService e ventServic e; | |
| 138 | @M ock | |
| 139 | pr ivate Quar tzSemaphor eRepositor y quartzSe maphoreRep ository; | |
| 140 | ||
| 141 | @A utowired | |
| 142 | pr ivate Even tsJob even tsJob; | |
| 143 | @A utowired | |
| 144 | pr ivate Asse ssmentServ ice assess mentServic e; | |
| 145 | @A utowired | |
| 146 | pr ivate Asse ssmentRepo sitory ass essmentRep ository; | |
| 147 | @A utowired | |
| 148 | pr ivate Asse ssmentReso urce contr oller; | |
| 149 | @A utowired | |
| 150 | pr ivate Assi gnmentReso urce assig nmentContr oller; | |
| 151 | @A utowired | |
| 152 | pr ivate Assi gnmentRepo sitory ass ignmentRep ository; | |
| 153 | @A utowired | |
| 154 | pr ivate Even tRepositor y eventRep ository; | |
| 155 | @A utowired | |
| 156 | pr ivate Asse ssmentVoic eInfoResou rce assess mentVoiced Informatio nResource; | |
| 157 | ||
| 158 | pr ivate MhpU ser user; | |
| 159 | pr ivate int counter = 1; | |
| 160 | ||
| 161 | pr ivate clas s CreateAs sessmentAn swer imple ments org. mockito.st ubbing.Ans wer<Assess ment> { | |
| 162 | @Ove rride | |
| 163 | publ ic Assessm ent answer (Invocatio nOnMock in vocation) throws Thr owable { | |
| 164 | Assess ment resul t = (Asses sment) inv ocation.ge tArguments ()[0]; | |
| 165 | if (re sult.get_i d() == nul l) { | |
| 166 | result.s et_id(Stri ng.valueOf (++counter )); | |
| 167 | } | |
| 168 | update Assessment WithRespon se(result) ; | |
| 169 | return result; | |
| 170 | } | |
| 171 | } | |
| 172 | ||
| 173 | /* * | |
| 174 | * Sets the up. | |
| 175 | * | |
| 176 | * @throws E xception | |
| 177 | * the exc eption | |
| 178 | * / | |
| 179 | @B efore | |
| 180 | pu blic void setUp() th rows Excep tion { | |
| 181 | Mock itoAnnotat ions.initM ocks(this) ; | |
| 182 | Refl ectionTest Utils.setF ield(contr oller, "us erService" , userServ ice); | |
| 183 | Refl ectionTest Utils.setF ield(asses smentVoice dInformati onResource , "userSer vice", use rService); | |
| 184 | Refl ectionTest Utils.setF ield(asses smentServi ce, "vista Assessment Service", vistaAsses smentServi ce); | |
| 185 | Refl ectionTest Utils.setF ield(contr oller, "co nversionSe rvice", mv iConversio nService); | |
| 186 | Refl ectionTest Utils.setF ield(assig nmentContr oller, "us erService" , userServ ice); | |
| 187 | Refl ectionTest Utils.setF ield(assig nmentContr oller, "mv iConversio nService", mviConver sionServic e); | |
| 188 | ||
| 189 | user = new Mhp User(); | |
| 190 | Pati entIdentif ier identi fier = new PatientId entifier() ; | |
| 191 | iden tifier.set AssigningA uthority(" EDIPI"); | |
| 192 | iden tifier.set UniqueId(p atientId); | |
| 193 | Refl ectionTest Utils.setF ield(user, "userIden tifier", i dentifier) ; | |
| 194 | ||
| 195 | when (userServi ce.getUser ()).thenRe turn(user) ; | |
| 196 | ||
| 197 | Gson Builder bu ilder = ne w GsonBuil der(); | |
| 198 | gson = builder .registerT ypeAdapter (DateTime. class, new DateTimeT ypeConvert er()) | |
| 199 | .r egisterTyp eAdapter(D ateTime.cl ass, new D ateTimeTyp eConverter ()) | |
| 200 | .c reate(); | |
| 201 | ||
| 202 | //// ////////// /// 1 //// ////////// ////////// /////// | |
| 203 | // a ssessment 1 | |
| 204 | Asse ssment ass essment1 = new Asses sment(); | |
| 205 | asse ssment1.se tPatientId (patientId ); | |
| 206 | asse ssment1.se tPatientAs signAuth(" EDIPI"); | |
| 207 | asse ssment1.se tAssessmen tName("GAD -7"); | |
| 208 | asse ssment1.se tProviderI d(provider Id1); | |
| 209 | asse ssment1.se tCompleted (Boolean.T RUE); | |
| 210 | Date Time today 1 = new Da teTime(); | |
| 211 | Date Time start Date1 = to day1.minus Days(4); | |
| 212 | Date Time endDa te1 = toda y1.plusDay s(5); | |
| 213 | asse ssment1.se tStartDate (startDate 1); | |
| 214 | asse ssment1.se tEndDate(e ndDate1); | |
| 215 | ||
| 216 | // a ssignment 1 | |
| 217 | Assi gnment ass ignment1 = new Assig nment(); | |
| 218 | assi gnment1.se tPatientId (patientId ); | |
| 219 | assi gnment1.se tPatientAs signAuth(a ssessment1 .getPatien tAssignAut h()); | |
| 220 | assi gnment1.se tRecurrenc eEarly(new Integer(4 )); | |
| 221 | assi gnment1.se tRecurrenc eLate(new Integer(5) ); | |
| 222 | assi gnment1.se tCompleted (Boolean.T RUE); | |
| 223 | assi gnmentRepo sitory.sav e(assignme nt1); | |
| 224 | assi gnmentIds. add(assign ment1.get_ id()); | |
| 225 | asse ssment1.se t_assignme ntId(assig nment1.get _id()); | |
| 226 | ||
| 227 | ||
| 228 | Resp onseSectio n response Section1 = new Respo nseSection (); | |
| 229 | List <Answer> a nswers1 = new ArrayL ist<Answer >(); | |
| 230 | resp onseSectio n1.setAnsw ers(answer s1); | |
| 231 | List <ResponseS ection> li stSections 1 = new Ar rayList<Re sponseSect ion>(); | |
| 232 | list Sections1. add(respon seSection1 ); | |
| 233 | ||
| 234 | List <Score> sc ores1 = ne w ArrayLis t<>(); | |
| 235 | scor es1.add(ne w Score("T otal", raw Score1)); | |
| 236 | ||
| 237 | Resp onse respo nse = new Response() ; | |
| 238 | resp onse.setSe ctions(lis tSections1 ); | |
| 239 | resp onse.setDa teSubmitte d(DateTime .now()); | |
| 240 | resp onse.setSc ores(score s1); | |
| 241 | asse ssment1.se tResponse( response); | |
| 242 | ||
| 243 | List <ScoreMeta Data> scor eMetaDataL ist = new ArrayList< ScoreMetaD ata>(); | |
| 244 | Form at format = new Form at(); | |
| 245 | asse ssment1.se tFormat(fo rmat); | |
| 246 | asse ssment1.ge tFormat(). setScoreMe taDataList (scoreMeta DataList); | |
| 247 | ||
| 248 | asse ssmentRepo sitory.sav e(assessme nt1); | |
| 249 | asse ssmentId1 = assessme nt1.get_id (); | |
| 250 | asse ssmentIds. add(assess ment1.get_ id()); | |
| 251 | ||
| 252 | Even t event1 = new Event (); | |
| 253 | even t1.setPati entVirtual Deleted(Bo olean.FALS E); | |
| 254 | even t1.setProv iderVirtua lDeleted(B oolean.FAL SE); | |
| 255 | even t1.setProv iderAssign Auth("EDIP I"); | |
| 256 | even t1.set_ass essmentId( assessment Id1); | |
| 257 | even t1.set_ass ignmentId( assessment 1.get_assi gnmentId() ); | |
| 258 | even t1.setPati entAssignA uth(assess ment1.getP atientAssi gnAuth()); | |
| 259 | even t1.setPati entId(asse ssment1.ge tPatientId ()); | |
| 260 | even t1.setProv iderId(pat ientId); | |
| 261 | even t1.setEven tType(Even t.PAST_DUE ); | |
| 262 | even tRepositor y.save(eve nt1); | |
| 263 | asse ssment1.se t_pastDueE ventId(eve nt1.get_id ()); | |
| 264 | ||
| 265 | Even t eventPro vider1 = n ew Event() ; | |
| 266 | even tProvider1 .setPatien tVirtualDe leted(Bool ean.FALSE) ; | |
| 267 | even tProvider1 .setProvid erVirtualD eleted(Boo lean.FALSE ); | |
| 268 | even tProvider1 .set_asses smentId(as sessmentId 1); | |
| 269 | even tProvider1 .set_assig nmentId(as sessment1. get_assign mentId()); | |
| 270 | even tProvider1 .setProvid erAssignAu th("EDIPI" ); | |
| 271 | even tProvider1 .setProvid erId(provi derId1); | |
| 272 | even tProvider1 .setPatien tAssignAut h(assessme nt1.getPat ientAssign Auth()); | |
| 273 | even tProvider1 .setPatien tId(assess ment1.getP atientId() ); | |
| 274 | even tProvider1 .setEventT ype(Event. PAST_DUE); | |
| 275 | even tRepositor y.save(eve ntProvider 1); | |
| 276 | ||
| 277 | asse ssment1.se t_pastDueE ventId(eve nt1.get_id ()); | |
| 278 | asse ssment1.se tProviderA ssignAuth( "EDIPI"); | |
| 279 | asse ssment1.se tProviderI d(provider Id1); | |
| 280 | ||
| 281 | asse ssmentRepo sitory.sav e(assessme nt1); | |
| 282 | ||
| 283 | //// ////////// /// 2 //// ////////// ////////// /////// | |
| 284 | // a ssessment 2 | |
| 285 | Asse ssment ass essment2 = new Asses sment(); | |
| 286 | asse ssment2.se tPatientId (patientId ); | |
| 287 | asse ssment2.se tPatientAs signAuth(" EDIPI"); | |
| 288 | asse ssment2.se tAssessmen tName("PCL -5"); | |
| 289 | asse ssment2.se tProviderI d(provider Id2); | |
| 290 | asse ssment2.se tCompleted (Boolean.T RUE); | |
| 291 | Date Time today 2 = new Da teTime(); | |
| 292 | Date Time start Date2 = to day2.minus Days(2); | |
| 293 | Date Time endDa te2 = toda y2.plusDay s(6); | |
| 294 | asse ssment2.se tStartDate (startDate 2); | |
| 295 | asse ssment2.se tEndDate(e ndDate2); | |
| 296 | ||
| 297 | ||
| 298 | // a ssignment 2 | |
| 299 | Assi gnment ass ignment2 = new Assig nment(); | |
| 300 | assi gnment2.se tPatientId (patientId ); | |
| 301 | assi gnment2.se tPatientAs signAuth(a ssessment2 .getPatien tAssignAut h()); | |
| 302 | assi gnment2.se tRecurrenc eEarly(new Integer(4 )); | |
| 303 | assi gnment2.se tRecurrenc eLate(new Integer(5) ); | |
| 304 | assi gnment2.se tCompleted (Boolean.T RUE); | |
| 305 | assi gnmentRepo sitory.sav e(assignme nt2); | |
| 306 | assi gnmentIds. add(assign ment2.get_ id()); | |
| 307 | asse ssment2.se t_assignme ntId(assig nment2.get _id()); | |
| 308 | ||
| 309 | ||
| 310 | Resp onseSectio n response Section2 = new Respo nseSection (); | |
| 311 | List <Answer> a nswers2 = new ArrayL ist<Answer >(); | |
| 312 | resp onseSectio n2.setAnsw ers(answer s2); | |
| 313 | List <ResponseS ection> li stSections 2 = new Ar rayList<Re sponseSect ion>(); | |
| 314 | list Sections2. add(respon seSection2 ); | |
| 315 | ||
| 316 | List <Score> sc ores2 = ne w ArrayLis t<>(); | |
| 317 | scor es2.add(ne w Score("T otal", raw Score2)); | |
| 318 | ||
| 319 | Resp onse respo nse2 = new Response( ); | |
| 320 | resp onse2.setS ections(li stSections 2); | |
| 321 | resp onse2.setD ateSubmitt ed(DateTim e.now()); | |
| 322 | resp onse2.setS cores(scor es2); | |
| 323 | asse ssment2.se tResponse( response2) ; | |
| 324 | ||
| 325 | List <ScoreMeta Data> scor eMetaDataL ist2 = new ArrayList <ScoreMeta Data>(); | |
| 326 | Form at format2 = new For mat(); | |
| 327 | asse ssment2.se tFormat(fo rmat2); | |
| 328 | asse ssment2.ge tFormat(). setScoreMe taDataList (scoreMeta DataList2) ; | |
| 329 | ||
| 330 | asse ssmentRepo sitory.sav e(assessme nt2); | |
| 331 | asse ssmentId2 = assessme nt2.get_id (); | |
| 332 | asse ssmentIds. add(assess ment2.get_ id()); | |
| 333 | ||
| 334 | Even t event2 = new Event (); | |
| 335 | even t2.setPati entVirtual Deleted(Bo olean.FALS E); | |
| 336 | even t2.setProv iderVirtua lDeleted(B oolean.FAL SE); | |
| 337 | even t2.setProv iderAssign Auth("EDIP I"); | |
| 338 | even t2.set_ass essmentId( assessment Id2); | |
| 339 | even t2.set_ass ignmentId( assessment 2.get_assi gnmentId() ); | |
| 340 | even t2.setPati entAssignA uth(assess ment2.getP atientAssi gnAuth()); | |
| 341 | even t2.setPati entId(asse ssment2.ge tPatientId ()); | |
| 342 | even t2.setProv iderId(pro viderId2); | |
| 343 | even t2.setEven tType(Even t.PAST_DUE ); | |
| 344 | even tRepositor y.save(eve nt2); | |
| 345 | ||
| 346 | asse ssment2.se t_pastDueE ventId(eve nt2.get_id ()); | |
| 347 | ||
| 348 | Even t eventPro vider2 = n ew Event() ; | |
| 349 | even tProvider2 .setPatien tVirtualDe leted(Bool ean.FALSE) ; | |
| 350 | even tProvider2 .setProvid erVirtualD eleted(Boo lean.FALSE ); | |
| 351 | even tProvider2 .set_asses smentId(as sessmentId 2); | |
| 352 | even tProvider2 .set_assig nmentId(as sessment2. get_assign mentId()); | |
| 353 | even tProvider2 .setProvid erAssignAu th("EDIPI" ); | |
| 354 | even tProvider2 .setProvid erId(provi derId2); | |
| 355 | even tProvider2 .setPatien tAssignAut h(assessme nt2.getPat ientAssign Auth()); | |
| 356 | even tProvider2 .setPatien tId(assess ment2.getP atientId() ); | |
| 357 | even tProvider2 .setEventT ype(Event. PAST_DUE); | |
| 358 | even tRepositor y.save(eve ntProvider 2); | |
| 359 | ||
| 360 | asse ssment2.se t_pastDueE ventId(eve nt2.get_id ()); | |
| 361 | asse ssment2.se tProviderA ssignAuth( "EDIPI"); | |
| 362 | asse ssment2.se tProviderI d(provider Id2); | |
| 363 | ||
| 364 | asse ssmentRepo sitory.sav e(assessme nt2); | |
| 365 | ||
| 366 | // a ssessment 3 | |
| 367 | crea teTestData (patientId , "EDIPI", "PCL-5", providerId 3, true, 1 , 3, 4, 5, rawScore3 , "EDIPI", Event.PAS T_DUE); | |
| 368 | ||
| 369 | // s hould NOT be in any results | |
| 370 | // w rong patie nt id | |
| 371 | // a ssessment 4 | |
| 372 | crea teTestData (patientId 0, "EDIPI" , "PCL-5", providerI d4, true, 5, 10, 4, 5, rawScor e4, "EDIPI ", Event.P AST_DUE); | |
| 373 | ||
| 374 | // s hould NOT be in get completed assessment results | |
| 375 | // c ompleted i s false | |
| 376 | // a ssessment 5 | |
| 377 | crea teTestData (patientId , "EDIPI", "PCL-5", providerId 5, false, 6, 12, 5, 6, rawScor e5, "EDIPI ", Event.P AST_DUE); | |
| 378 | ||
| 379 | ||
| 380 | when (mviConver sionServic e.convertP atientDfnT oEdipi(any (String.cl ass), any( String.cla ss))) | |
| 381 | .thenRet urn(identi fier); | |
| 382 | ||
| 383 | when (userServi ce.getDate TimeZoneFo rProvider( any(String .class), a ny(String. class))) | |
| 384 | .the nReturn(Da teTimeZone .forID("US /Eastern") ); | |
| 385 | } | |
| 386 | ||
| 387 | pr ivate Stri ng createT estData( | |
| 388 | // ass essment | |
| 389 | String patientId , | |
| 390 | String patientAs signAuth, | |
| 391 | String assessmen tName, | |
| 392 | String providerI d, | |
| 393 | Boolea n complete d, | |
| 394 | int st art, | |
| 395 | int en d, | |
| 396 | ||
| 397 | // ass ignment | |
| 398 | int re currenceEa rly, | |
| 399 | int re currenceLa te, | |
| 400 | String rawScore, | |
| 401 | ||
| 402 | // eve nt | |
| 403 | String providerA ssignAuth, | |
| 404 | String eventType | |
| 405 | ) { | |
| 406 | ||
| 407 | // a ssessment | |
| 408 | Asse ssment ass essment = new Assess ment(); | |
| 409 | asse ssment.set PatientId( patientId) ; | |
| 410 | asse ssment.set PatientAss ignAuth(pa tientAssig nAuth); | |
| 411 | asse ssment.set Assessment Name(asses smentName) ; | |
| 412 | asse ssment.set ProviderId (providerI d); | |
| 413 | asse ssment.set Completed( completed) ; | |
| 414 | Date Time today = new Dat eTime(); | |
| 415 | Date Time start Date = tod ay.minusDa ys(start); | |
| 416 | Date Time endDa te = today .plusDays( end); | |
| 417 | asse ssment.set StartDate( startDate) ; | |
| 418 | asse ssment.set EndDate(en dDate); | |
| 419 | ||
| 420 | // a ssignment | |
| 421 | Assi gnment ass ignment = new Assign ment(); | |
| 422 | assi gnment.set PatientId( patientId) ; | |
| 423 | assi gnment.set PatientAss ignAuth(as signment.g etPatientA ssignAuth( )); | |
| 424 | assi gnment.set Recurrence Early(recu rrenceEarl y); | |
| 425 | assi gnment.set Recurrence Late(recur renceLate) ; | |
| 426 | assi gnment.set Completed( completed) ; | |
| 427 | assi gnmentRepo sitory.sav e(assignme nt); | |
| 428 | assi gnmentIds. add(assign ment.get_i d()); | |
| 429 | asse ssment.set _assignmen tId(assign ment.get_i d()); | |
| 430 | ||
| 431 | Resp onseSectio n response Section = new Respon seSection( ); | |
| 432 | List <Answer> a nswers = n ew ArrayLi st<Answer> (); | |
| 433 | resp onseSectio n.setAnswe rs(answers ); | |
| 434 | List <ResponseS ection> li stSections = new Arr ayList<Res ponseSecti on>(); | |
| 435 | list Sections.a dd(respons eSection); | |
| 436 | ||
| 437 | List <Score> sc ores = new ArrayList <>(); | |
| 438 | scor es.add(new Score("To tal", rawS core)); | |
| 439 | ||
| 440 | Resp onse respo nse = new Response() ; | |
| 441 | resp onse.setSe ctions(lis tSections) ; | |
| 442 | resp onse.setDa teSubmitte d(DateTime .now()); | |
| 443 | resp onse.setSc ores(score s); | |
| 444 | asse ssment.set Response(r esponse); | |
| 445 | ||
| 446 | List <ScoreMeta Data> scor eMetaDataL ist = new ArrayList< ScoreMetaD ata>(); | |
| 447 | Form at format = new Form at(); | |
| 448 | asse ssment.set Format(for mat); | |
| 449 | asse ssment.get Format().s etScoreMet aDataList( scoreMetaD ataList); | |
| 450 | ||
| 451 | asse ssmentRepo sitory.sav e(assessme nt); | |
| 452 | Stri ng assessm entId = as sessment.g et_id(); | |
| 453 | asse ssmentIds. add(assess ment.get_i d()); | |
| 454 | ||
| 455 | Even t event = new Event( ); | |
| 456 | even t.setPatie ntVirtualD eleted(Boo lean.FALSE ); | |
| 457 | even t.setProvi derVirtual Deleted(Bo olean.FALS E); | |
| 458 | even t.setProvi derAssignA uth(provid erAssignAu th); | |
| 459 | even t.set_asse ssmentId(a ssessmentI d); | |
| 460 | even t.set_assi gnmentId(a ssessment. get_assign mentId()); | |
| 461 | even t.setPatie ntAssignAu th(assessm ent.getPat ientAssign Auth()); | |
| 462 | even t.setPatie ntId(asses sment.getP atientId() ); | |
| 463 | even t.setProvi derId(prov iderId); | |
| 464 | even t.setEvent Type(event Type); | |
| 465 | even tRepositor y.save(eve nt); | |
| 466 | ||
| 467 | asse ssment.set _pastDueEv entId(even t.get_id() ); | |
| 468 | Even t eventPro vider = ne w Event(); | |
| 469 | even tProvider. setPatient VirtualDel eted(Boole an.FALSE); | |
| 470 | even tProvider. setProvide rVirtualDe leted(Bool ean.FALSE) ; | |
| 471 | even tProvider. set_assign mentId(ass essment.ge t_assignme ntId()); | |
| 472 | even tProvider. setProvide rAssignAut h(provider AssignAuth ); | |
| 473 | even tProvider. setProvide rId(provid erId); | |
| 474 | even tProvider. setPatient AssignAuth (assessmen t.getPatie ntAssignAu th()); | |
| 475 | even tProvider. setPatient Id(assessm ent.getPat ientId()); | |
| 476 | even tProvider. setEventTy pe(Event.P AST_DUE); | |
| 477 | even tRepositor y.save(eve ntProvider ); | |
| 478 | ||
| 479 | asse ssment.set _pastDueEv entId(even t.get_id() ); | |
| 480 | asse ssment.set ProviderAs signAuth(p roviderAss ignAuth); | |
| 481 | asse ssment.set ProviderId (providerI d); | |
| 482 | ||
| 483 | asse ssmentRepo sitory.sav e(assessme nt); | |
| 484 | ||
| 485 | retu rn assessm entId; | |
| 486 | } | |
| 487 | ||
| 488 | ||
| 489 | /* * | |
| 490 | * Tear down . | |
| 491 | * | |
| 492 | * @throws E xception | |
| 493 | * the exc eption | |
| 494 | * / | |
| 495 | @A fter | |
| 496 | pu blic void tearDown() throws Ex ception { | |
| 497 | ||
| 498 | clea nupAssignm entData(as signmentId sForDates) ; | |
| 499 | clea nupAssignm entData(as signmentId sForDatesF inalize); | |
| 500 | clea nupAssignm entData(as signmentId s); | |
| 501 | for (String id : assessm entIds) { | |
| 502 | assess mentReposi tory.delet e(id); | |
| 503 | } | |
| 504 | ||
| 505 | } | |
| 506 | ||
| 507 | pr ivate void cleanupAs signmentDa ta(List<St ring> ids) { | |
| 508 | for (String as signmentId : ids) { | |
| 509 | Assign ment assig nment = as signmentRe pository.f indBy_id(a ssignmentI d); | |
| 510 | if (as signment ! = null) { | |
| 511 | List<Str ing> asses smentIds = assignmen t.get_asse ssmentIds( ); | |
| 512 | for (Str ing id : a ssessmentI ds) { | |
| 513 | Assessment assessmen t = assess mentReposi tory.findB y_id(id); | |
| 514 | if (assess ment != nu ll) { | |
| 515 | if (assessme nt.get_due EventId() != null) { | |
| 516 | even tRepositor y.delete(a ssessment. get_dueEve ntId()); | |
| 517 | } | |
| 518 | as sessmentRe pository.d elete(asse ssment); | |
| 519 | } | |
| 520 | ||
| 521 | } | |
| 522 | List<Eve nt> list = eventRepo sitory.fin dBy_assign mentId(ass ignment.ge t_id()); | |
| 523 | if (list != null & & list.siz e() > 0) { | |
| 524 | for (Event e : list) { | |
| 525 | ev entReposit ory.delete (e); | |
| 526 | } | |
| 527 | } | |
| 528 | ||
| 529 | assignme ntReposito ry.delete( assignment ); | |
| 530 | } | |
| 531 | } | |
| 532 | ||
| 533 | } | |
| 534 | ||
| 535 | /* | |
| 536 | get all for gi ven patien t-id, rega rdless if completed or not | |
| 537 | ||
| 538 | defa ult - no c ompleted p aram provi ded | |
| 539 | * / | |
| 540 | @T est | |
| 541 | pu blic void testProvid er_provide rGetPatien tAssessmen t_All() th rows Excep tion { | |
| 542 | // V erify MHPR O-5266 | |
| 543 | MvcR esult resu lt = mockM vc.perform (get(Asses smentResou rce.REQUES T_PROVIDER _MAPPING, "EDIPI", p atientId)) | |
| 544 | .andExpe ct(status( ).is2xxSuc cessful()) .andReturn (); | |
| 545 | ||
| 546 | Stri ng respons eBody = re sult.getRe sponse().g etContentA sString(); | |
| 547 | ||
| 548 | //Sy stem.out.p rintln(res ponseBody) ; | |
| 549 | ||
| 550 | getR ecordCount (4, respon seBody); | |
| 551 | } | |
| 552 | ||
| 553 | ||
| 554 | /* * | |
| 555 | * get only NOT comple ted (?comp leted=fals e) | |
| 556 | * / | |
| 557 | @T est | |
| 558 | pu blic void testProvid er_provide rGetPatien tAssessmen t_not_comp leted() th rows Excep tion { | |
| 559 | // V erify MHPR O-5266 | |
| 560 | MvcR esult resu lt = mockM vc.perform ( | |
| 561 | get(Asse ssmentReso urce.REQUE ST_PROVIDE R_MAPPING + "?comple ted=false" , "EDIPI", patientId ) | |
| 562 | .content Type(Media Type.APPLI CATION_JSO N)) | |
| 563 | .andExpe ct(status( ).is2xxSuc cessful()) .andReturn (); | |
| 564 | ||
| 565 | Stri ng respons eBody = re sult.getRe sponse().g etContentA sString(); | |
| 566 | ||
| 567 | //Sy stem.out.p rintln(res ponseBody) ; | |
| 568 | ||
| 569 | getR ecordCount (1, respon seBody); | |
| 570 | ||
| 571 | asse rtThat(res ponseBody, containsS tring("\"p atientId\" : \"66600 0001\"")); | |
| 572 | } | |
| 573 | ||
| 574 | /* * | |
| 575 | * get only compl eted (?com pleted=tru e) | |
| 576 | * / | |
| 577 | @T est | |
| 578 | pu blic void testProvid er_provide rGetPatien tAssessmen t_complete d() throws Exception { | |
| 579 | // V erify MHPR O-5266 | |
| 580 | MvcR esult resu lt = mockM vc.perform ( | |
| 581 | get(Asse ssmentReso urce.REQUE ST_PROVIDE R_MAPPING + "?comple ted=true", "EDIPI", patientId) | |
| 582 | .content Type(Media Type.APPLI CATION_JSO N)) | |
| 583 | .andExpe ct(status( ).is2xxSuc cessful()) .andReturn (); | |
| 584 | ||
| 585 | Stri ng respons eBody = re sult.getRe sponse().g etContentA sString(); | |
| 586 | ||
| 587 | //Sy stem.out.p rintln(res ponseBody) ; | |
| 588 | ||
| 589 | getR ecordCount (3, respon seBody); | |
| 590 | ||
| 591 | asse rtThat(res ponseBody, containsS tring("\"p atientId\" : \"66600 0001\"")); | |
| 592 | ||
| 593 | // a ssessment 1 | |
| 594 | asse rtThat(res ponseBody, containsS tring("\"p roviderId\ " : \""+pr oviderId1+ "\"")); | |
| 595 | asse rtThat(res ponseBody, containsS tring("\"r awScore\" : \""+rawS core1+"\"" )); | |
| 596 | asse rtThat(res ponseBody, containsS tring("\"s core\" : " +rawScore1 )); | |
| 597 | asse rtThat(res ponseBody, containsS tring("\"s everity\" : \""+seve rity1.getN ame()+"\"" )); | |
| 598 | ||
| 599 | // a ssessment 2 | |
| 600 | asse rtThat(res ponseBody, containsS tring("\"p roviderId\ " : \""+pr oviderId2+ "\"")); | |
| 601 | asse rtThat(res ponseBody, containsS tring("\"r awScore\" : \""+rawS core2+"\"" )); | |
| 602 | asse rtThat(res ponseBody, containsS tring("\"s core\" : " +rawScore2 )); | |
| 603 | asse rtThat(res ponseBody, containsS tring("\"s everity\" : \""+seve rity2.getN ame()+"\"" )); | |
| 604 | ||
| 605 | // a ssessment 3 | |
| 606 | asse rtThat(res ponseBody, containsS tring("\"p roviderId\ " : \""+pr oviderId3+ "\"")); | |
| 607 | asse rtThat(res ponseBody, containsS tring("\"r awScore\" : \""+rawS core3+"\"" )); | |
| 608 | asse rtThat(res ponseBody, containsS tring("\"s core\" : " +rawScore3 )); | |
| 609 | asse rtThat(res ponseBody, containsS tring("\"s everity\" : \""+seve rity3.getN ame()+"\"" )); | |
| 610 | } | |
| 611 | ||
| 612 | ||
| 613 | /* * | |
| 614 | * Uses Gson to get re cords and perform re cord count assertion | |
| 615 | * | |
| 616 | * @param re cCount | |
| 617 | * - number of expect ed records | |
| 618 | * @param re sponseBody | |
| 619 | * - the re sponse dat a to parse | |
| 620 | * @return | |
| 621 | * - the in teger coun t of recor ds found i n response data | |
| 622 | * / | |
| 623 | pr ivate int getRecordC ount(int r ecCount, S tring resp onseBody) { | |
| 624 | int recordCoun t = 0; | |
| 625 | try { | |
| 626 | JsonEl ement json = new Gso n().fromJs on(respons eBody, Jso nElement.c lass); | |
| 627 | JsonAr ray jsonAr ray = json .getAsJson Array(); | |
| 628 | Iterat or<JsonEle ment> it = jsonArray .iterator( ); | |
| 629 | ||
| 630 | while (it.hasNex t()) { | |
| 631 | JsonElem ent elem = it.next() ; | |
| 632 | ||
| 633 | //System .out.print ln("print json data" ); | |
| 634 | if (elem != null) { | |
| 635 | //System.o ut.println ("json\n"+ elem.toStr ing()); | |
| 636 | recordCoun t++; | |
| 637 | } | |
| 638 | } | |
| 639 | assert True(recor dCount == recCount); | |
| 640 | } ca tch (Excep tion e) { | |
| 641 | System .out.print ln(e); | |
| 642 | } | |
| 643 | ||
| 644 | retu rn recordC ount; | |
| 645 | } | |
| 646 | ||
| 647 | ||
| 648 | pr ivate void updateAss essmentWit hResponse( Assessment assessmen t) { | |
| 649 | Resp onseSectio n section = new Resp onseSectio n(); | |
| 650 | Answ er answer = new Answ er(); | |
| 651 | answ er.setAnsw erText("An swer"); | |
| 652 | sect ion.addAns wer(answer ); | |
| 653 | Resp onse respo nse = new Response() ; | |
| 654 | resp onse.setDa teSubmitte d(DateTime .now()); | |
| 655 | resp onse.addSe ction(sect ion); | |
| 656 | Scor e score = new Score( ); | |
| 657 | scor e.setRawSc ore("15"); | |
| 658 | scor e.setScale Name("Tota l"); | |
| 659 | resp onse.addSc ore(score) ; | |
| 660 | asse ssment.set Response(r esponse); | |
| 661 | Form at format = new Form at(); | |
| 662 | asse ssment.set Format(for mat); | |
| 663 | Scor eMetaData scoreMetaD ata = new ScoreMetaD ata(); | |
| 664 | scor eMetaData. setDefault Score(true ); | |
| 665 | scor eMetaData. setHighRis kAlertValu e("15"); | |
| 666 | scor eMetaData. setScaleNa me("Total" ); | |
| 667 | form at.getScor eMetaDataL ist().add( scoreMetaD ata); | |
| 668 | } | |
| 669 | ||
| 670 | pr otected St ring getJs onFromObje ctMapper(O bject obj) throws Ex ception { | |
| 671 | Obje ctMapper m apper = ne w ObjectMa pper(); | |
| 672 | mapp er.enable( Serializat ionFeature .INDENT_OU TPUT); | |
| 673 | mapp er.registe rModule(ne w JodaModu le()); | |
| 674 | retu rn mapper. writeValue AsString(o bj); | |
| 675 | } | |
| 676 | ||
| 677 | cl ass MockAu thenticati on impleme nts Authen tication { | |
| 678 | ||
| 679 | /** | |
| 680 | * | |
| 681 | */ | |
| 682 | priv ate static final lon g serialVe rsionUID = 533359337 1483334411 L; | |
| 683 | ||
| 684 | @Ove rride | |
| 685 | publ ic String getName() { | |
| 686 | // TOD O Auto-gen erated met hod stub | |
| 687 | return null; | |
| 688 | } | |
| 689 | ||
| 690 | @Ove rride | |
| 691 | publ ic Collect ion<? exte nds Grante dAuthority > getAutho rities() { | |
| 692 | Grante dAuthority grantedAu thority = Mockito.mo ck(Granted Authority. class); | |
| 693 | List<G rantedAuth ority> lis t = new Ar rayList<>( ); | |
| 694 | list.a dd(granted Authority) ; | |
| 695 | Mockit o.when(gra ntedAuthor ity.getAut hority()). thenReturn (Roles.ROL E_STAFF); | |
| 696 | return list; | |
| 697 | } | |
| 698 | ||
| 699 | @Ove rride | |
| 700 | publ ic Object getCredent ials() { | |
| 701 | // TOD O Auto-gen erated met hod stub | |
| 702 | return null; | |
| 703 | } | |
| 704 | ||
| 705 | @Ove rride | |
| 706 | publ ic Object getDetails () { | |
| 707 | // TOD O Auto-gen erated met hod stub | |
| 708 | return null; | |
| 709 | } | |
| 710 | ||
| 711 | @Ove rride | |
| 712 | publ ic Object getPrincip al() { | |
| 713 | // TOD O Auto-gen erated met hod stub | |
| 714 | return null; | |
| 715 | } | |
| 716 | ||
| 717 | @Ove rride | |
| 718 | publ ic boolean isAuthent icated() { | |
| 719 | // TOD O Auto-gen erated met hod stub | |
| 720 | return false; | |
| 721 | } | |
| 722 | ||
| 723 | @Ove rride | |
| 724 | publ ic void se tAuthentic ated(boole an isAuthe nticated) throws Ill egalArgume ntExceptio n { | |
| 725 | // TOD O Auto-gen erated met hod stub | |
| 726 | ||
| 727 | } | |
| 728 | ||
| 729 | } | |
| 730 | ||
| 731 | pr ivate clas s DateTime TypeConver ter implem ents JsonS erializer< DateTime>, JsonDeser ializer<Da teTime> { | |
| 732 | // N o need for an Instan ceCreator since Date Time provi des a no-a rgs constr uctor | |
| 733 | @Ove rride | |
| 734 | publ ic JsonEle ment seria lize(DateT ime src, T ype srcTyp e, JsonSer ialization Context co ntext) { | |
| 735 | return new JsonP rimitive(s rc.toStrin g()); | |
| 736 | } | |
| 737 | @Ove rride | |
| 738 | publ ic DateTim e deserial ize(JsonEl ement json , Type typ e, JsonDes erializati onContext context) | |
| 739 | { | |
| 740 | return new DateT ime(json.g etAsString ()); | |
| 741 | } | |
| 742 | } | |
| 743 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.