Produced by Araxis Merge on 5/30/2019 1:49:17 PM Eastern 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 | var_web_release_4_18.zip\var_web_release_4_8_ebb0ab2774d.zip\MockServices\src\main\java | BookedAppointmentsMock.java | Fri May 10 18:55:49 2019 UTC |
| 2 | var_web_release_4_18.zip\var_web_release_4_8_ebb0ab2774d.zip\MockServices\src\main\java | BookedAppointmentsMock.java | Wed May 29 20:04:07 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 334 |
| 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 | import sta tic com.xe bialabs.re stito.buil der.stub.S tubHttp.wh enHttp; | |
| 3 | import sta tic com.xe bialabs.re stito.sema ntics.Cond ition.cust om; | |
| 4 | import sta tic com.xe bialabs.re stito.sema ntics.Cond ition.meth od; | |
| 5 | ||
| 6 | import jav a.io.IOExc eption; | |
| 7 | import jav a.util.Cal endar; | |
| 8 | import jav a.util.Dat e; | |
| 9 | ||
| 10 | import org .glassfish .grizzly.h ttp.Method ; | |
| 11 | import org .glassfish .grizzly.h ttp.server .Response; | |
| 12 | import org .glassfish .grizzly.h ttp.util.H ttpStatus; | |
| 13 | ||
| 14 | import com .xebialabs .restito.s emantics.C all; | |
| 15 | import com .xebialabs .restito.s emantics.F unction; | |
| 16 | import com .xebialabs .restito.s emantics.P redicate; | |
| 17 | import com .xebialabs .restito.s erver.Stub Server; | |
| 18 | ||
| 19 | public cla ss BookedA ppointment sMock exte nds Abstra ctMock { | |
| 20 | privat e static S tring appo intmentTem plate; | |
| 21 | privat e static S tring appo intmentsTe mplate; | |
| 22 | ||
| 23 | public BookedApp ointmentsM ock() { | |
| 24 | ap pointmentT emplate = loadTempl ate("appoi ntment-tem plate.txt" ); | |
| 25 | ap pointments Template = loadTempl ate("appoi ntments-te mplate.txt "); | |
| 26 | } | |
| 27 | ||
| 28 | @Overr ide | |
| 29 | public void run( StubServer server) { | |
| 30 | Pr edicate<Ca ll> validB ookedAppoi ntmentRequ est = new Predicate< Call>() { | |
| 31 | @Overrid e | |
| 32 | public b oolean app ly(final C all input) { | |
| 33 | retu rn input.g etUri().ma tches(".*/ VeteranApp ointmentRe questServi ce/v4/rest /direct-sc heduling/s ite/\\d+/p atient/EDI PI/.*/book ed-appoint ments"); | |
| 34 | } | |
| 35 | }; | |
| 36 | ||
| 37 | Pr edicate<Ca ll> validB ookedAppoi ntmentPost Request = new Predic ate<Call>( ) { | |
| 38 | @Overrid e | |
| 39 | public b oolean app ly(final C all input) { | |
| 40 | retu rn input.g etUri().ma tches(".*/ VeteranApp ointmentRe questServi ce/v4/rest /direct-sc heduling/s ite/\\d+/p atient/EDI PI/.*/book ed-appoint ments"); | |
| 41 | } | |
| 42 | }; | |
| 43 | ||
| 44 | Pr edicate<Ca ll> reques tToGenerat eErrorMess age = new Predicate< Call>() { | |
| 45 | @Overrid e | |
| 46 | public b oolean app ly(final C all input) { | |
| 47 | retu rn input.g etUri().ma tches(".*/ VeteranApp ointmentRe questServi ce/v4/rest /direct-sc heduling/s ite/\\d+/p atient/EDI PI/0000000 001/booked -appointme nts"); | |
| 48 | } | |
| 49 | }; | |
| 50 | ||
| 51 | Fu nction<Res ponse, Res ponse> app ointments = new Func tion<Respo nse, Respo nse>() { | |
| 52 | @Overrid e | |
| 53 | public R esponse ap ply(Respon se input) { | |
| 54 | Stri ng uri = i nput.getRe quest().ge tRequestUR I(); | |
| 55 | Stri ng siteCod eRegex = " .*/site/(\ \d+)/patie nt"; | |
| 56 | Stri ng patient IdRegex = ".*/EDIPI/ (.*)/booke d-appointm ents"; | |
| 57 | ||
| 58 | String hos t = "https :// IP "; | |
| 59 | Stri ng siteCod e = matchi ngRegex(ur i, siteCod eRegex); | |
| 60 | Stri ng patient Id = match ingRegex(u ri, patien tIdRegex); | |
| 61 | ||
| 62 | Meth od method = input.ge tRequest() .getMethod (); | |
| 63 | Stri ng output = "{\"book edAppointm entCollect ions\": [] }"; | |
| 64 | ||
| 65 | if ( patientId. equals("P0 11")) { | |
| 66 | output = c reateNotCa ncellableA ppointment s(host, si teCode, pa tientId, m ethod); | |
| 67 | } el se if (!pa tientId.eq uals("D123 401")) { | |
| 68 | output = c reateAppoi ntments(ho st, siteCo de, patien tId, metho d); | |
| 69 | } | |
| 70 | ||
| 71 | try { | |
| 72 | input.getW riter().wr ite(output ); | |
| 73 | } ca tch (IOExc eption e) { | |
| 74 | e.printSta ckTrace(); | |
| 75 | } | |
| 76 | retu rn input; | |
| 77 | } | |
| 78 | }; | |
| 79 | ||
| 80 | wh enHttp(ser ver).match (custom(va lidBookedA ppointment Request), method(Met hod.GET)) | |
| 81 | .then(ge nerateResp onse(HttpS tatus.OK_2 00, appoin tments)); | |
| 82 | ||
| 83 | wh enHttp(ser ver).match (custom(va lidBookedA ppointment PostReques t), method (Method.PO ST)) | |
| 84 | .t hen(genera teResponse (HttpStatu s.OK_200, appointmen ts)); | |
| 85 | ||
| 86 | wh enHttp(ser ver).match (custom(re questToGen erateError Message), method(Met hod.POST)) | |
| 87 | .t hen(genera teResponse (HttpStatu s.BAD_REQU EST_400, " Error: Una ble to sav e appointm ent")); | |
| 88 | } | |
| 89 | ||
| 90 | privat e String c reateAppoi ntments(St ring host, String si teCode, St ring patie ntIdentifi er, Method method) { | |
| 91 | St ring appoi ntmentTime = "09:00: 00"; | |
| 92 | ||
| 93 | St ring tomor row = form atDate(xDa ysFromNow( 1)) + " " + appointm entTime; | |
| 94 | St ring dayAf terTomorro w = format Date(xDays FromNow(2) ) + " " + appointmen tTime; | |
| 95 | St ring next3 0Day = for matDate(xD aysFromNow (30)) + " " + appoin tmentTime; | |
| 96 | St ring next3 1Day = for matDate(xD aysFromNow (31)) + " " + appoin tmentTime; | |
| 97 | ||
| 98 | if (method.ma tchesMetho d("POST")) { | |
| 99 | return c reateAppoi ntment(hos t, siteCod e, patient Identifier , next31Da y, "1789", "ABC Clin ic", "FUTU RE"); | |
| 100 | } | |
| 101 | ||
| 102 | St ring cance lledTomorr owAppointm ent = crea teAppointm ent(host, siteCode, patientIde ntifier, t omorrow, " 1789", "AB C Clinic", "CANCELLE D BY CLINI C & AUTO R E-BOOK"); | |
| 103 | St ring tomor rowAppoint ment = cre ateAppoint ment(host, siteCode, patientId entifier, tomorrow, "1789", "A BC Clinic" , "FUTURE" ); | |
| 104 | St ring cance lledDayAft erTomorrow Appointmen t = create Appointmen t(host, si teCode, pa tientIdent ifier, day AfterTomor row, "2001 ", "DEF Cl inic", "CA NCELLED BY CLINIC"); | |
| 105 | St ring dayAf terTomorro wAppointme nt = creat eAppointme nt(host, s iteCode, p atientIden tifier, da yAfterTomo rrow, "200 1", "DEF C linic", "F UTURE"); | |
| 106 | St ring next3 0DayAppoin tment = cr eateAppoin tment(host , siteCode , patientI dentifier, next30Day , "2005", "ERG Clini c", "FUTUR E"); | |
| 107 | St ring next3 1DayAppoin tment = cr eateAppoin tment(host , siteCode , patientI dentifier, next31Day , "3002", "XYZ Clini c", "FUTUR E"); | |
| 108 | ||
| 109 | St ring prima ryCareAppo intments = tomorrowA ppointment + ',' + c ancelledTo morrowAppo intment + ',' + dayA fterTomorr owAppointm ent; | |
| 110 | St ring other Appointmen ts = next3 0DayAppoin tment + ", " + cancel ledDayAfte rTomorrowA ppointment + "," + n ext31DayAp pointment; | |
| 111 | ||
| 112 | re turn Strin g.format(a ppointment sTemplate, primaryCa reAppointm ents, othe rAppointme nts); | |
| 113 | } | |
| 114 | ||
| 115 | privat e String c reateNotCa ncellableA ppointment s(String h ost, Strin g siteCode , String p atientIden tifier, Me thod metho d) { | |
| 116 | St ring appoi ntmentTime = "09:00: 00"; | |
| 117 | ||
| 118 | St ring tomor row = form atDate(xDa ysFromNow( 1)) + " " + appointm entTime; | |
| 119 | St ring dayAf terTomorro w = format Date(xDays FromNow(2) ) + " " + appointmen tTime; | |
| 120 | St ring next3 0Day = for matDate(xD aysFromNow (30)) + " " + appoin tmentTime; | |
| 121 | St ring next3 1Day = for matDate(xD aysFromNow (31)) + " " + appoin tmentTime; | |
| 122 | ||
| 123 | if (method.ma tchesMetho d("POST")) { | |
| 124 | return c reateAppoi ntment(hos t, siteCod e, patient Identifier , next31Da y, "1789", "ABC Clin ic", "FUTU RE"); | |
| 125 | } | |
| 126 | ||
| 127 | St ring next3 0DayAppoin tment = "" ; | |
| 128 | St ring next3 1DayAppoin tment = "" ; | |
| 129 | St ring other Appointmen ts = ""; | |
| 130 | ||
| 131 | if (siteCode .equals("5 23")) { | |
| 132 | // varia ble length appointme nt | |
| 133 | next30Da yAppointme nt = creat eAppointme nt(host, s iteCode, p atientIden tifier, 30 , next30Da y, "2005", "ERG-VAR Clinic", " FUTURE"); | |
| 134 | // 10 mi nute appoi ntment | |
| 135 | next31Da yAppointme nt = creat eAppointme nt(host, s iteCode, p atientIden tifier, 10 , next31Da y, "3002", "XYZ-10 C linic", "F UTURE"); | |
| 136 | otherApp ointments = next30Da yAppointme nt + "," + next31Day Appointmen t; | |
| 137 | } else if (s iteCode.eq uals("650" )) { | |
| 138 | // 20 mi nute appoi ntment | |
| 139 | next31Da yAppointme nt = creat eAppointme nt(host, s iteCode, p atientIden tifier, 20 , next31Da y, "3002", "XYZ-20 C linic", "F UTURE"); | |
| 140 | otherAppo intments = next31Day Appointmen t; | |
| 141 | } else { | |
| 142 | next31Da y = format Date(xDays FromNow(31 )) + " 10: 15:00"; | |
| 143 | ||
| 144 | // odd a ppointment | |
| 145 | next31Da yAppointme nt = creat eAppointme nt(host, s iteCode, p atientIden tifier, 30 , next31Da y, "2005", "ERG-ODD Clinic", " FUTURE"); | |
| 146 | otherAppo intments = next31Day Appointmen t; | |
| 147 | } | |
| 148 | ||
| 149 | ||
| 150 | re turn Strin g.format(a ppointment sTemplate, "", other Appointmen ts); | |
| 151 | } | |
| 152 | ||
| 153 | privat e Date xDa ysFromNow( int amount ) { | |
| 154 | Ca lendar cal = Calenda r.getInsta nce(); | |
| 155 | ca l.add(Cale ndar.DAY_O F_YEAR, am ount); | |
| 156 | re turn cal.g etTime(); | |
| 157 | } | |
| 158 | ||
| 159 | privat e String c reateAppoi ntment(Str ing host, String sit eCode, Str ing patien tIdentifie r, | |
| 160 | int appointme ntLength, String app ointmentTi me, String clinicId, String cl inicName, String sta tus) { | |
| 161 | re turn Strin g.format(a ppointment Template, host, site Code, pati entIdentif ier, appoi ntmentLeng th, appoin tmentTime, clinicId, clinicNam e, status) ; | |
| 162 | } | |
| 163 | ||
| 164 | privat e String c reateAppoi ntment(Str ing host, String sit eCode, Str ing patien tIdentifie r, | |
| 165 | Str ing appoin tmentTime, String cl inicId, St ring clini cName, Str ing status ) { | |
| 166 | re turn Strin g.format(a ppointment Template, host, site Code, pati entIdentif ier, 30, a ppointment Time, clin icId, clin icName, st atus); | |
| 167 | } | |
| 168 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.