Produced by Araxis Merge on 12/8/2017 1:33:40 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\service\impl | VaFacilityServiceImplTest.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\service\impl | VaFacilityServiceImplTest.java | Fri Dec 8 18:30:22 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1082 |
| 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.med.f ee.service .impl; | |
| 2 | ||
| 3 | import sta tic org.ju nit.Assert .assertEqu als; | |
| 4 | import sta tic org.mo ckito.Mock ito.when; | |
| 5 | ||
| 6 | import jav a.math.Big Decimal; | |
| 7 | import jav a.util.Arr ayList; | |
| 8 | import jav a.util.Dat e; | |
| 9 | import jav a.util.Has hSet; | |
| 10 | import jav a.util.Lis t; | |
| 11 | import jav a.util.Set ; | |
| 12 | ||
| 13 | import org .apache.lo gging.log4 j.LogManag er; | |
| 14 | import org .apache.lo gging.log4 j.Logger; | |
| 15 | import org .junit.Tes t; | |
| 16 | import org .junit.run ner.RunWit h; | |
| 17 | import org .mockito.I njectMocks ; | |
| 18 | import org .mockito.M ock; | |
| 19 | import org .mockito.M ockito; | |
| 20 | import org .mockito.r unners.Moc kitoJUnitR unner; | |
| 21 | ||
| 22 | import gov .va.med.do main.fee.A ppRole; | |
| 23 | import gov .va.med.do main.fee.A ppUser; | |
| 24 | import gov .va.med.do main.fee.C ontactInfo ; | |
| 25 | import gov .va.med.do main.fee.U serRoleUsa ges; | |
| 26 | import gov .va.med.do main.fee.U serRoleUsa gesId; | |
| 27 | import gov .va.med.do main.fee.V aFacility; | |
| 28 | import gov .va.med.do main.fee.V aFacilityT ype; | |
| 29 | import gov .va.med.do main.fee.V isn; | |
| 30 | import gov .va.med.do main.fee.Z ipCode; | |
| 31 | import gov .va.med.fe e.dao.IApp UserReposi tory; | |
| 32 | import gov .va.med.fe e.dao.ICon tactInfoRe pository; | |
| 33 | import gov .va.med.fe e.dao.IVaF acilityRep ository; | |
| 34 | import gov .va.med.fe e.dao.IVaF acilityRep ositoryTem plate; | |
| 35 | import gov .va.med.fe e.dao.IVaF acilityTyp eRepositor y; | |
| 36 | import gov .va.med.fe e.dao.IVis nRepositor y; | |
| 37 | import gov .va.med.fe e.dao.IZip CodeReposi tory; | |
| 38 | import gov .va.med.fe e.exceptio ns.Generic Exception; | |
| 39 | import gov .va.med.fe e.model.re quest.Cont actInfoReq uest; | |
| 40 | import gov .va.med.fe e.model.re quest.VaFa cilityRequ est; | |
| 41 | import gov .va.med.fe e.model.re quest.VaFa cilitySear chRequest; | |
| 42 | import gov .va.med.fe e.model.re quest.ZipC odeRequest ; | |
| 43 | import gov .va.med.fe e.model.re sponse.Gen ericRespon se; | |
| 44 | import gov .va.med.fe e.model.re sponse.VaF acilityRes ponse; | |
| 45 | import gov .va.med.fe e.model.re sponse.VaF acilityTyp eResponse; | |
| 46 | import gov .va.med.fe e.model.re sponse.VaF acilityVis nResponse; | |
| 47 | ||
| 48 | @RunWith(M ockitoJUni tRunner.cl ass) | |
| 49 | public cla ss VaFacil ityService ImplTest { | |
| 50 | ||
| 51 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(VaFa cilityServ iceImplTes t.class); | |
| 52 | ||
| 53 | @I njectMocks | |
| 54 | Va FacilitySe rviceImpl vaFacility ServiceImp l; | |
| 55 | ||
| 56 | @M ock | |
| 57 | IV aFacilityR epositoryT emplate va FacilityRe poTemplate ; | |
| 58 | ||
| 59 | @M ock | |
| 60 | IZ ipCodeRepo sitory zip CodeReposi tory; | |
| 61 | ||
| 62 | @M ock | |
| 63 | IV aFacilityR epository iVaFacilit yRepositor y; | |
| 64 | ||
| 65 | @M ock | |
| 66 | IV isnReposit ory iVisnR epository; | |
| 67 | ||
| 68 | @M ock | |
| 69 | IV aFacilityT ypeReposit ory iVaFac ilityTypeR epository; | |
| 70 | ||
| 71 | @M ock | |
| 72 | IA ppUserRepo sitory app UserReposi tory; | |
| 73 | ||
| 74 | @M ock | |
| 75 | IC ontactInfo Repository iContactI nfoReposit ory; | |
| 76 | ||
| 77 | Li st<AppUser > list = n ew ArrayLi st<>(); | |
| 78 | ||
| 79 | @T est | |
| 80 | pu blic void test_getAl lVisns() { | |
| 81 | VaFa cilityVisn Response r esponse = new VaFaci lityVisnRe sponse(); | |
| 82 | List <VaFacilit yVisnRespo nse> res = new Array List<VaFac ilityVisnR esponse>() ; | |
| 83 | ||
| 84 | resp onse.setVi snIdCd(123 4); | |
| 85 | resp onse.setDe scription( "This is a test visn "); | |
| 86 | res. add(respon se); | |
| 87 | ||
| 88 | Mock ito.when(v aFacilityR epoTemplat e.getAllVi snsForForm Load()).th enReturn(r es); | |
| 89 | ||
| 90 | List <VaFacilit yVisnRespo nse> resul t = new Ar rayList<Va FacilityVi snResponse >(); | |
| 91 | try { | |
| 92 | result = vaFacil ityService Impl.getAl lVisns(); | |
| 93 | } ca tch (Gener icExceptio n e) { | |
| 94 | e.prin tStackTrac e(); | |
| 95 | } | |
| 96 | asse rtEquals(r esult.get( 0).getDesc ription(), "This is a test vis n"); | |
| 97 | } | |
| 98 | ||
| 99 | @T est | |
| 100 | pu blic void test_getAl lVaFacilit yType() { | |
| 101 | VaFa cilityType Response r esponse = new VaFaci lityTypeRe sponse(); | |
| 102 | List <VaFacilit yTypeRespo nse> res = new Array List<VaFac ilityTypeR esponse>() ; | |
| 103 | ||
| 104 | resp onse.setVa TypeCd("Te st"); | |
| 105 | resp onse.setDe scription( "This is a test type "); | |
| 106 | res. add(respon se); | |
| 107 | ||
| 108 | Mock ito.when(v aFacilityR epoTemplat e.getAllVa FacilityTy peForFormL oad()).the nReturn(re s); | |
| 109 | ||
| 110 | List <VaFacilit yTypeRespo nse> resul t = new Ar rayList<Va FacilityTy peResponse >(); | |
| 111 | try { | |
| 112 | result = vaFacil ityService Impl.getAl lVaFacilit yType(); | |
| 113 | } ca tch (Gener icExceptio n e) { | |
| 114 | ||
| 115 | e.prin tStackTrac e(); | |
| 116 | } | |
| 117 | ||
| 118 | asse rtEquals(r esult.get( 0).getVaTy peCd(), "T est"); | |
| 119 | } | |
| 120 | ||
| 121 | @T est | |
| 122 | pu blic void test_addVa Facility_s uccess() { | |
| 123 | VaFa cilityRequ est reques t = new Va FacilityRe quest(); | |
| 124 | ||
| 125 | requ est.setAge dDefinitio n(new Long (1234)); | |
| 126 | requ est.setApp UserName(" test user" ); | |
| 127 | requ est.setPar entVaFacil ityCd("par ent cd"); | |
| 128 | requ est.setRer outingAllo wed(true); | |
| 129 | requ est.setSho rtName("te st short n ame"); | |
| 130 | requ est.setVaF acilityCd( "test faci lity cd"); | |
| 131 | requ est.setVaF acilityNam e("test va facility name"); | |
| 132 | requ est.setVaT ypeCd("tes t type cd" ); | |
| 133 | requ est.setVis nIdCd(1234 L); | |
| 134 | ||
| 135 | setU pforZipCod e(); | |
| 136 | when (appUserRe pository.f indByAppUs erName(req uest.getAp pUserName( ))).thenRe turn(list) ; | |
| 137 | ||
| 138 | Mock ito.when(v aFacilityR epoTemplat e.insertNe wVaFacilit y(request) ).thenRetu rn(1); | |
| 139 | ||
| 140 | int rowCount = 0; | |
| 141 | try { | |
| 142 | rowCou nt = vaFac ilityServi ceImpl.add VaFacility (request); | |
| 143 | } ca tch (Gener icExceptio n e) { | |
| 144 | assert Equals(e.g etMessage( ), "Unable to add a new facili ty"); | |
| 145 | } | |
| 146 | asse rtEquals(r owCount, 1 ); | |
| 147 | } | |
| 148 | ||
| 149 | @T est | |
| 150 | pu blic void test_addVa Facility_e rror() { | |
| 151 | VaFa cilityRequ est reques t = new Va FacilityRe quest(); | |
| 152 | ||
| 153 | requ est.setAge dDefinitio n(new Long (1234)); | |
| 154 | requ est.setApp UserName(" test user" ); | |
| 155 | requ est.setPar entVaFacil ityCd("par ent cd"); | |
| 156 | requ est.setRer outingAllo wed(true); | |
| 157 | requ est.setSho rtName("te st short n ame"); | |
| 158 | requ est.setVaF acilityCd( "test faci lity cd"); | |
| 159 | requ est.setVaF acilityNam e("test va facility name"); | |
| 160 | requ est.setVaT ypeCd("tes t type cd" ); | |
| 161 | requ est.setVis nIdCd(1234 L); | |
| 162 | ||
| 163 | setU pforZipCod e(); | |
| 164 | when (appUserRe pository.f indByAppUs erName(req uest.getAp pUserName( ))).thenRe turn(list) ; | |
| 165 | ||
| 166 | Mock ito.when(v aFacilityR epoTemplat e.insertNe wVaFacilit y(request) ).thenRetu rn(0); | |
| 167 | ||
| 168 | int rowCount = 0; | |
| 169 | try { | |
| 170 | rowCou nt = vaFac ilityServi ceImpl.add VaFacility (request); | |
| 171 | } ca tch (Gener icExceptio n e) { | |
| 172 | assert Equals(e.g etMessage( ), "Unable to add a new facili ty"); | |
| 173 | } | |
| 174 | asse rtEquals(r owCount, 0 ); | |
| 175 | } | |
| 176 | ||
| 177 | @T est | |
| 178 | pu blic void test_modif yVaFacilit y_success( ) throws E xception { | |
| 179 | VaFa cilityRequ est reques t = new Va FacilityRe quest(); | |
| 180 | ||
| 181 | requ est.setAge dDefinitio n(new Long (1234)); | |
| 182 | requ est.setApp UserName(" Test"); | |
| 183 | requ est.setPar entVaFacil ityCd("par ent cd"); | |
| 184 | requ est.setRer outingAllo wed(true); | |
| 185 | requ est.setSho rtName("te st short n ame"); | |
| 186 | requ est.setVaF acilityCd( "test faci lity cd"); | |
| 187 | requ est.setVaF acilityNam e("test va facility name"); | |
| 188 | requ est.setVaT ypeCd("tes t type cd" ); | |
| 189 | requ est.setVis nIdCd(1234 L); | |
| 190 | Date date = ne w Date(); | |
| 191 | bool ean result = false; | |
| 192 | VaFa cility vaF acilityTes t = new Va Facility() ; | |
| 193 | Visn visn = ne w Visn(123 4L, "Test User", dat e); | |
| 194 | VaFa cilityType vaFacilit yType = ne w VaFacili tyType("te st type cd ", "Test U ser", date ); | |
| 195 | ||
| 196 | VaFa cility vaF acility = new VaFaci lity(); | |
| 197 | vaFa cility.set Visn(visn) ; | |
| 198 | vaFa cility.set VaFacility Type(vaFac ilityType) ; | |
| 199 | vaFa cility.set VaFacility Name(reque st.getVaFa cilityName ()); | |
| 200 | vaFa cility.set ShortName( request.ge tShortName ()); | |
| 201 | vaFa cility.set AgedDefini tion(reque st.getAged Definition ()); | |
| 202 | vaFa cility.set ReroutingA llowed(req uest.isRer outingAllo wed()); | |
| 203 | vaFa cility.set ParentVaFa cilityCd(r equest.get ParentVaFa cilityCd() ); | |
| 204 | vaFa cility.set ModifiedBy (request.g etAppUserN ame()); | |
| 205 | ||
| 206 | Mock ito.when(i VaFacility Repository .findVaFac ilityByVaF acilityCd( request.ge tVaFacilit yCd())).th enReturn(v aFacility) ; | |
| 207 | Mock ito.when(i VisnReposi tory.findO ne(request .getVisnId Cd())).the nReturn(vi sn); | |
| 208 | Mock ito.when(i VaFacility TypeReposi tory.findO ne(request .getVaType Cd())).the nReturn(va FacilityTy pe); | |
| 209 | Mock ito.when(i VaFacility Repository .save(vaFa cility)).t henReturn( vaFacility Test); | |
| 210 | ||
| 211 | setU pforZipCod e(); | |
| 212 | when (appUserRe pository.f indByAppUs erName(req uest.getAp pUserName( ))).thenRe turn(list) ; | |
| 213 | ||
| 214 | try { | |
| 215 | result = vaFacil ityService Impl.modif yStation(r equest); | |
| 216 | assert Equals(res ult, true) ; | |
| 217 | } ca tch (Gener icExceptio n e) { | |
| 218 | assert Equals(e.g etMessage( ), "Unable to add a new facili ty"); | |
| 219 | } | |
| 220 | } | |
| 221 | ||
| 222 | @T est | |
| 223 | pu blic void test_modif yVaFacilit y_error() { | |
| 224 | VaFa cilityRequ est reques t = new Va FacilityRe quest(); | |
| 225 | ||
| 226 | requ est.setAge dDefinitio n(new Long (1234)); | |
| 227 | requ est.setApp UserName(" test user" ); | |
| 228 | requ est.setPar entVaFacil ityCd("par ent cd"); | |
| 229 | requ est.setRer outingAllo wed(true); | |
| 230 | requ est.setSho rtName("te st short n ame"); | |
| 231 | requ est.setVaF acilityCd( "test faci lity cd"); | |
| 232 | requ est.setVaF acilityNam e("test va facility name"); | |
| 233 | requ est.setVaT ypeCd("tes t type cd" ); | |
| 234 | requ est.setVis nIdCd(1234 L); | |
| 235 | ||
| 236 | Date date = ne w Date(); | |
| 237 | bool ean result = false; | |
| 238 | VaFa cility vaF acilityTes t = null; | |
| 239 | Visn visn = ne w Visn(123 4L, "Test User", dat e); | |
| 240 | VaFa cilityType vaFacilit yType = ne w VaFacili tyType("te st type cd ", "Test U ser", date ); | |
| 241 | ||
| 242 | VaFa cility vaF acility = new VaFaci lity(); | |
| 243 | vaFa cility.set Visn(visn) ; | |
| 244 | vaFa cility.set VaFacility Type(vaFac ilityType) ; | |
| 245 | vaFa cility.set VaFacility Name(reque st.getVaFa cilityName ()); | |
| 246 | vaFa cility.set ShortName( request.ge tShortName ()); | |
| 247 | vaFa cility.set AgedDefini tion(reque st.getAged Definition ()); | |
| 248 | vaFa cility.set ReroutingA llowed(req uest.isRer outingAllo wed()); | |
| 249 | vaFa cility.set ParentVaFa cilityCd(r equest.get ParentVaFa cilityCd() ); | |
| 250 | vaFa cility.set ModifiedBy (request.g etAppUserN ame()); | |
| 251 | ||
| 252 | setU pforZipCod e(); | |
| 253 | when (appUserRe pository.f indByAppUs erName(req uest.getAp pUserName( ))).thenRe turn(list) ; | |
| 254 | ||
| 255 | Mock ito.when(i VaFacility Repository .findVaFac ilityByVaF acilityCd( request.ge tVaFacilit yCd())).th enReturn(v aFacility) ; | |
| 256 | Mock ito.when(i VisnReposi tory.findO ne(request .getVisnId Cd())).the nReturn(vi sn); | |
| 257 | Mock ito.when(i VaFacility TypeReposi tory.findO ne(request .getVaType Cd())).the nReturn(va FacilityTy pe); | |
| 258 | Mock ito.when(i VaFacility Repository .save(vaFa cility)).t henReturn( vaFacility Test); | |
| 259 | ||
| 260 | try { | |
| 261 | result = vaFacil ityService Impl.modif yStation(r equest); | |
| 262 | } ca tch (Gener icExceptio n e) { | |
| 263 | assert Equals(e.g etMessage( ), "Unable to add a new facili ty"); | |
| 264 | } | |
| 265 | asse rtEquals(r esult, fal se); | |
| 266 | } | |
| 267 | ||
| 268 | /* @Test | |
| 269 | pu blic void test_remov eVaFacilit y() throws Exception { | |
| 270 | Stri ng appUser Name = "AB C"; | |
| 271 | Stri ng zip_cod e= "20855" ; | |
| 272 | Stri ng vaFacil ityCd = "1 0"; | |
| 273 | ||
| 274 | ZipC ode zipcod e = new Zi pCode(); | |
| 275 | zipc ode.setCre atedBy(app UserName); | |
| 276 | zipc ode.setDat eCreated(n ew Date()) ; | |
| 277 | ||
| 278 | VaFa cilityRequ est reques t = new Va FacilityRe quest(); | |
| 279 | requ est.setAge dDefinitio n(new Long (1234)); | |
| 280 | requ est.setApp UserName(" test user" ); | |
| 281 | requ est.setPar entVaFacil ityCd("par ent cd"); | |
| 282 | requ est.setRer outingAllo wed(true); | |
| 283 | requ est.setSho rtName("te st short n ame"); | |
| 284 | requ est.setVaF acilityCd( "test faci lity cd"); | |
| 285 | requ est.setVaF acilityNam e("test va facility name"); | |
| 286 | requ est.setVaT ypeCd("tes t type cd" ); | |
| 287 | requ est.setVis nIdCd(1234 L); | |
| 288 | ||
| 289 | Date date = ne w Date(); | |
| 290 | bool ean result = false; | |
| 291 | VaFa cility vaF acilityTes t = null; | |
| 292 | Visn visn = ne w Visn(123 4L, "Test User", dat e); | |
| 293 | VaFa cilityType vaFacilit yType = ne w VaFacili tyType("te st type cd ", "Test U ser", date ); | |
| 294 | ||
| 295 | VaFa cility vaF acility = new VaFaci lity(); | |
| 296 | vaFa cility.set Visn(visn) ; | |
| 297 | vaFa cility.set VaFacility Type(vaFac ilityType) ; | |
| 298 | vaFa cility.set VaFacility Name(reque st.getVaFa cilityName ()); | |
| 299 | vaFa cility.set ShortName( request.ge tShortName ()); | |
| 300 | vaFa cility.set AgedDefini tion(reque st.getAged Definition ()); | |
| 301 | vaFa cility.set ReroutingA llowed(req uest.isRer outingAllo wed()); | |
| 302 | vaFa cility.set ParentVaFa cilityCd(r equest.get ParentVaFa cilityCd() ); | |
| 303 | vaFa cility.set ModifiedBy (request.g etAppUserN ame()); | |
| 304 | vaFa cility.set ContactInf os(null); | |
| 305 | vaFa cility.set ZipCodes(n ull); | |
| 306 | ||
| 307 | zipc ode.setZip Code(zip_c ode); | |
| 308 | when (zipCodeRe pository.f indZipCode ByZipcode( zip_code)) .thenRetur n(zipcode) ; | |
| 309 | when (iVaFacili tyReposito ry.findVaF acilityByC ontactInfo (vaFacilit yCd.toUppe rCase())). thenReturn (vaFacilit y); | |
| 310 | ||
| 311 | setU pforZipCod e(); | |
| 312 | when (appUserRe pository.f indByAppUs erName(app UserName)) .thenRetur n(list); | |
| 313 | ||
| 314 | Mock ito.doNoth ing().when (zipCodeRe pository). delete(zip code); | |
| 315 | ||
| 316 | ZipC odeRequest request = new ZipCo deRequest( ); | |
| 317 | requ est.setZip _code(zip_ code); | |
| 318 | requ est.setApp UserName(a ppUserName ); | |
| 319 | requ est.setVaF acilityCd( vaFacility Cd); | |
| 320 | ||
| 321 | Bool ean respon se = vaFac ilityServi ceImpl.rem oveZipCode (request); | |
| 322 | asse rtEquals(r esponse, B oolean.TRU E); | |
| 323 | }* / | |
| 324 | ||
| 325 | @T est | |
| 326 | pu blic void test_searc hStation() throws Ex ception { | |
| 327 | List <VaFacilit yResponse> vaFacilit yResponseL ist = new ArrayList< VaFacility Response>( ); | |
| 328 | Long resultsCo unt = 2L; | |
| 329 | BigD ecimal val ue = new B igDecimal( 30); | |
| 330 | VaFa cilitySear chRequest vaFacility Request = new VaFaci litySearch Request(10 0, null, f alse, 1, n ull, "TOGU S", | |
| 331 | null, "A DMIN", nul l); | |
| 332 | VaFa cilityResp onse vaFac ilityRespo nse = new VaFacility Response(" 119", "ToG Us ME", "T OGUS VA ME D/REGIONAL OFFICE CE NTER", "FA C", "7", t rue, value , null, "C PE_OWNER", "06/01/20 17 00:00:0 0 AM"); | |
| 333 | vaFa cilityResp onseList.a dd(vaFacil ityRespons e); | |
| 334 | when (vaFacilit yRepoTempl ate.getSea rchResults Count(vaFa cilityRequ est)).then Return(res ultsCount) ; | |
| 335 | when (vaFacilit yRepoTempl ate.getSea rchResults (vaFacilit yRequest)) .thenRetur n(vaFacili tyResponse List); | |
| 336 | Gene ricRespons e visnSear chResponse = new Gen ericRespon se(1, 100, | |
| 337 | "station ", 2L); | |
| 338 | visn SearchResp onse.setRe sponse(vaF acilityRes ponseList) ; | |
| 339 | try { | |
| 340 | Generi cResponse response = vaFacilit yServiceIm pl.getSear chVisn(vaF acilityReq uest); | |
| 341 | assert Equals(vis nSearchRes ponse.getR esponse(), response. getRespons e()); | |
| 342 | logger .info("sta tion searc hed succes sfully"); | |
| 343 | } ca tch (Gener icExceptio n e) { | |
| 344 | logger .info("Exc eption occ ured in se arching th e station" ); | |
| 345 | assert Equals(e.g etMessage( ), "Unable to search for a fac ility"); | |
| 346 | } | |
| 347 | ||
| 348 | } | |
| 349 | ||
| 350 | @T est | |
| 351 | pu blic void test_addCo ntactInfo( ) throws E xception { | |
| 352 | Stri ng appUser Name = "AB C"; | |
| 353 | Stri ng vaFacil ityCd = "1 23"; | |
| 354 | ||
| 355 | Cont actInfoReq uest reque st = new C ontactInfo Request(); | |
| 356 | requ est.setApp UserName(a ppUserName ); | |
| 357 | requ est.setVaF acilityCd( vaFacility Cd); | |
| 358 | requ est.setAdd ress1("1 O racle Dr." ); | |
| 359 | requ est.setCit y("Palo Al to"); | |
| 360 | requ est.setCon tactName(" Mr. ABC"); | |
| 361 | requ est.setCon tactType(" Admin"); | |
| 362 | request.se tEmail(" PII "); | |
| 363 | requ est.setZip ("99988"); | |
| 364 | requ est.setPho ne("123456 7890"); | |
| 365 | ||
| 366 | Visn toVisn = new Visn(L ong.valueO f("16"), " CCSE", new Date()); | |
| 367 | VaFa cility fac ility = ne w VaFacili ty(vaFacil ityCd, toV isn, | |
| 368 | new VaFa cilityType ("FAC", "C CSE", new Date()), t rue,"CCSE" , new Date ()); | |
| 369 | when (iVaFacili tyReposito ry.findVaF acilityByV aFacilityC d(vaFacili tyCd)).the nReturn(fa cility); | |
| 370 | ||
| 371 | Cont actInfo co ntactInfoM odel = new ContactIn fo(); | |
| 372 | cont actInfoMod el.setCont actName(re quest.getC ontactName ()); | |
| 373 | cont actInfoMod el.setCont actType(re quest.getC ontactType ()); | |
| 374 | cont actInfoMod el.setDate Created(ne w Date()); | |
| 375 | cont actInfoMod el.setAddr ess1(reque st.getAddr ess1()); | |
| 376 | cont actInfoMod el.setAddr ess2(reque st.getAddr ess2()); | |
| 377 | cont actInfoMod el.setCity (request.g etCity()); | |
| 378 | cont actInfoMod el.setZip( request.ge tZip()); | |
| 379 | cont actInfoMod el.setEmai l(request. getEmail() ); | |
| 380 | cont actInfoMod el.setPhon e(request. getPhone() ); | |
| 381 | cont actInfoMod el.setFax( request.ge tFax()); | |
| 382 | cont actInfoMod el.setCrea tedBy(requ est.getApp UserName() ); | |
| 383 | Bool ean respon se = Boole an.TRUE; | |
| 384 | when (iContactI nfoReposit ory.saveAn dFlush(con tactInfoMo del)).then Return(con tactInfoMo del); | |
| 385 | ||
| 386 | setU pforZipCod e(); | |
| 387 | when (appUserRe pository.f indByAppUs erName(app UserName)) .thenRetur n(list); | |
| 388 | ||
| 389 | resp onse = vaF acilitySer viceImpl.p ostContact Info(reque st); | |
| 390 | asse rtEquals(r esponse, B oolean.TRU E); | |
| 391 | } | |
| 392 | ||
| 393 | @T est | |
| 394 | pu blic void test_addZi pCode() th rows Excep tion { | |
| 395 | Stri ng appUser Name = "AB C"; | |
| 396 | Stri ng vaFacil ityCd = "1 0"; | |
| 397 | Stri ng zip_cod e= "20855" ; | |
| 398 | Stri ng urban_i ndicator= "100"; | |
| 399 | Stri ng fips_co unty_code= "100"; | |
| 400 | Stri ng fips_st ate_code= "10"; | |
| 401 | Bool ean active = Boolean. TRUE; | |
| 402 | ||
| 403 | Visn toVisn = new Visn(L ong.valueO f("16"), " CCSE", new Date()); | |
| 404 | VaFa cility fac ility = ne w VaFacili ty(vaFacil ityCd, toV isn, | |
| 405 | new VaFa cilityType ("FAC", "C CSE", new Date()), t rue,"CCSE" , new Date ()); | |
| 406 | when (iVaFacili tyReposito ry.findVaF acilityByV aFacilityC d(vaFacili tyCd)).the nReturn(fa cility); | |
| 407 | ||
| 408 | ZipC ode zipcod e = new Zi pCode(); | |
| 409 | zipc ode.setVaF acility(fa cility); | |
| 410 | zipc ode.setCre atedBy(app UserName); | |
| 411 | zipc ode.setDat eCreated(n ew Date()) ; | |
| 412 | zipc ode.setAct iveFlag(Bo olean.TRUE .equals(ac tive) ? 'Y ' : 'N'); | |
| 413 | zipc ode.setFip sCountyCod e(fips_cou nty_code); | |
| 414 | zipc ode.setFip sStateCode (fips_stat e_code); | |
| 415 | zipc ode.setUrb anIndicato r(urban_in dicator); | |
| 416 | zipc ode.setZip Code(zip_c ode); | |
| 417 | ||
| 418 | ZipC odeRequest request = new ZipCo deRequest( appUserNam e, vaFacil ityCd, zip _code, urb an_indicat or, | |
| 419 | fips_cou nty_code, fips_state _code, act ive); | |
| 420 | Bool ean respon se = Boole an.TRUE; | |
| 421 | ||
| 422 | when (zipCodeRe pository.s aveAndFlus h(zipcode) ).thenRetu rn(zipcode ); | |
| 423 | ||
| 424 | setU pforZipCod e(); | |
| 425 | when (appUserRe pository.f indByAppUs erName(app UserName)) .thenRetur n(list); | |
| 426 | ||
| 427 | resp onse = vaF acilitySer viceImpl.a ddZipCode( request); | |
| 428 | asse rtEquals(r esponse, B oolean.TRU E); | |
| 429 | } | |
| 430 | ||
| 431 | @T est | |
| 432 | pu blic void test_editZ ipCode() t hrows Exce ption { | |
| 433 | Stri ng appUser Name = "AB C"; | |
| 434 | Stri ng vaFacil ityCd = "1 0"; | |
| 435 | Stri ng zip_cod e= "20855" ; | |
| 436 | Stri ng urban_i ndicator= "10"; | |
| 437 | Stri ng fips_co unty_code= "10"; | |
| 438 | Stri ng fips_st ate_code= "10"; | |
| 439 | Bool ean active = Boolean. TRUE; | |
| 440 | ||
| 441 | ZipC ode zipcod e = new Zi pCode(); | |
| 442 | zipc ode.setCre atedBy(app UserName); | |
| 443 | zipc ode.setDat eCreated(n ew Date()) ; | |
| 444 | zipc ode.setAct iveFlag(Bo olean.TRUE .equals(ac tive) ? 'Y ' : 'N'); | |
| 445 | zipc ode.setFip sCountyCod e(fips_cou nty_code); | |
| 446 | zipc ode.setFip sStateCode (fips_stat e_code); | |
| 447 | zipc ode.setUrb anIndicato r(urban_in dicator); | |
| 448 | zipc ode.setZip Code(zip_c ode); | |
| 449 | when (zipCodeRe pository.f indZipCode ByZipcode( zip_code)) .thenRetur n(zipcode) ; | |
| 450 | ||
| 451 | zipc ode.setAct iveFlag('N '); | |
| 452 | zipc ode.setFip sCountyCod e("100"); | |
| 453 | zipc ode.setFip sStateCode ("50"); | |
| 454 | zipc ode.setUrb anIndicato r("100"); | |
| 455 | when (zipCodeRe pository.s aveAndFlus h(zipcode) ).thenRetu rn(zipcode ); | |
| 456 | ||
| 457 | setU pforZipCod e(); | |
| 458 | when (appUserRe pository.f indByAppUs erName(app UserName)) .thenRetur n(list); | |
| 459 | ||
| 460 | ZipC odeRequest request = new ZipCo deRequest( appUserNam e, vaFacil ityCd, zip _code, urb an_indicat or, | |
| 461 | fips_cou nty_code, fips_state _code, act ive); | |
| 462 | ||
| 463 | Bool ean respon se = vaFac ilityServi ceImpl.edi tZipCode(r equest); | |
| 464 | asse rtEquals(r esponse, B oolean.TRU E); | |
| 465 | } | |
| 466 | ||
| 467 | @T est | |
| 468 | pu blic void test_remov eZipCode() throws Ex ception { | |
| 469 | Stri ng appUser Name = "AB C"; | |
| 470 | Stri ng zip_cod e= "20855" ; | |
| 471 | Stri ng vaFacil ityCd = "1 0"; | |
| 472 | ||
| 473 | ZipC ode zipcod e = new Zi pCode(); | |
| 474 | zipc ode.setCre atedBy(app UserName); | |
| 475 | zipc ode.setDat eCreated(n ew Date()) ; | |
| 476 | ||
| 477 | zipc ode.setZip Code(zip_c ode); | |
| 478 | when (zipCodeRe pository.f indZipCode ByZipcode( zip_code)) .thenRetur n(zipcode) ; | |
| 479 | ||
| 480 | setU pforZipCod e(); | |
| 481 | when (appUserRe pository.f indByAppUs erName(app UserName)) .thenRetur n(list); | |
| 482 | ||
| 483 | Mock ito.doNoth ing().when (zipCodeRe pository). delete(zip code); | |
| 484 | ||
| 485 | ZipC odeRequest request = new ZipCo deRequest( ); | |
| 486 | requ est.setZip _code(zip_ code); | |
| 487 | requ est.setApp UserName(a ppUserName ); | |
| 488 | requ est.setVaF acilityCd( vaFacility Cd); | |
| 489 | ||
| 490 | Bool ean respon se = vaFac ilityServi ceImpl.rem oveZipCode (request); | |
| 491 | asse rtEquals(r esponse, B oolean.TRU E); | |
| 492 | } | |
| 493 | ||
| 494 | pr ivate void setUpforZ ipCode() { | |
| 495 | Set< UserRoleUs ages> user Roles = ne w HashSet< >(); | |
| 496 | AppU ser appUse r = new Ap pUser(); | |
| 497 | appU ser.setApp UserId(Lon g.valueOf( 100)); | |
| 498 | appU ser.setUse rName("ABC "); | |
| 499 | appU ser.setFir stName("Te st"); | |
| 500 | appU ser.setLas tName("Tes t"); | |
| 501 | ||
| 502 | // R ole Admin | |
| 503 | AppR ole appRol e1 = new A ppRole(); | |
| 504 | appR ole1.setAp pRoleId(Lo ng.valueOf (1)); | |
| 505 | appR ole1.setRo leName("AD MIN"); | |
| 506 | appR ole1.setDe scription( "Admin can do everyt hing"); | |
| 507 | ||
| 508 | User RoleUsages Id id1 = n ew UserRol eUsagesId( Long.value Of(1), Lon g.valueOf( 1), "VAFAC 001", "Y", "", new D ate()); | |
| 509 | User RoleUsages userRole1 = new Use rRoleUsage s(id1, new VaFacilit y(), appRo le1, appUs er); | |
| 510 | user Roles.add( userRole1) ; | |
| 511 | appU ser.setUse rRoleUsage s(userRole s); | |
| 512 | ||
| 513 | list .add(appUs er); | |
| 514 | } | |
| 515 | ||
| 516 | @T est | |
| 517 | pu blic void test_getSt ationInfo( ) throws E xception { | |
| 518 | Stri ng station Name = "te st va faci lity name" ; | |
| 519 | ||
| 520 | VaFa cility req uest = new VaFacilit y(); | |
| 521 | ||
| 522 | requ est.setAge dDefinitio n(new Long (1234)); | |
| 523 | requ est.setCre atedBy("te st user"); | |
| 524 | requ est.setPar entVaFacil ityCd("par ent cd"); | |
| 525 | requ est.setRer outingAllo wed(true); | |
| 526 | requ est.setSho rtName("te st short n ame"); | |
| 527 | requ est.setVaF acilityCd( "test faci lity cd"); | |
| 528 | requ est.setVaF acilityNam e(stationN ame); | |
| 529 | requ est.setVaF acilityTyp e(new VaFa cilityType ("test typ e cd", "te st user", new Date() )); | |
| 530 | requ est.setVis n(new Visn (1234L, "t est user", new Date( ))); | |
| 531 | requ est.setDat eCreated(n ew Date()) ; | |
| 532 | ||
| 533 | when (iVaFacili tyReposito ry.findVaF acilityByS tation(sta tionName)) .thenRetur n(request) ; | |
| 534 | VaFa cilityRequ est vaFaci lityReques t = vaFaci lityServic eImpl.getS tationInfo (stationNa me); | |
| 535 | asse rtEquals(v aFacilityR equest.get VaFacility Name(), st ationName) ; | |
| 536 | asse rtEquals(v aFacilityR equest.get VaFacility Cd(), requ est.getVaF acilityCd( )); | |
| 537 | asse rtEquals(v aFacilityR equest.get ParentVaFa cilityCd() , request. getParentV aFacilityC d()); | |
| 538 | asse rtEquals(v aFacilityR equest.get ShortName( ), request .getShortN ame()); | |
| 539 | asse rtEquals(v aFacilityR equest.get VisnIdCd() , request. getVisn(). getVisnIdC d()); | |
| 540 | asse rtEquals(v aFacilityR equest.get AgedDefini tion(), re quest.getA gedDefinit ion()); | |
| 541 | } | |
| 542 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.