Produced by Araxis Merge on 5/25/2018 9:21:41 AM 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\ZIP\DSM-cif\Direct Implementation\java\config\config-service-client\src\test\java\org\nhind\config\rest\impl | DefaultDNSService_updateDNSRecordTest.java | Tue May 22 13:50:20 2018 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\ZIP\DSM-cif\Direct Implementation\java\config\config-service-client\src\test\java\org\nhind\config\rest\impl | DefaultDNSService_updateDNSRecordTest.java | Wed May 23 16:22:05 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 5 | 664 |
| 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 or g.nhind.co nfig.rest. impl; | |
| 2 | ||
| 3 | import sta tic org.mo ckito.Matc hers.any; | |
| 4 | import sta tic org.mo ckito.Matc hers.eq; | |
| 5 | import sta tic org.mo ckito.Mock ito.doThro w; | |
| 6 | import sta tic org.mo ckito.Mock ito.mock; | |
| 7 | import sta tic org.mo ckito.Mock ito.when; | |
| 8 | ||
| 9 | import jav a.util.Arr ays; | |
| 10 | import jav a.util.Col lection; | |
| 11 | ||
| 12 | import org .junit.Tes t; | |
| 13 | import org .nhind.con fig.client .ConfigSer viceRunner ; | |
| 14 | import org .nhind.con fig.rest.D NSService; | |
| 15 | import org .nhind.con fig.testba se.BaseTes tPlan; | |
| 16 | ||
| 17 | import org .nhindirec t.common.r est.except ions.Servi ceExceptio n; | |
| 18 | import org .nhindirec t.common.r est.except ions.Servi ceMethodEx ception; | |
| 19 | import org .nhindirec t.config.m odel.DNSRe cord; | |
| 20 | import org .nhindirec t.config.m odel.utils .DNSUtils; | |
| 21 | import org .nhindirec t.config.r esources.D NSResource ; | |
| 22 | ||
| 23 | import org .nhindirec t.config.r esources.u til.Entity ModelConve rsion; | |
| 24 | import org .nhindirec t.config.s tore.dao.D NSDao; | |
| 25 | ||
| 26 | public cla ss Default DNSService _updateDNS RecordTest | |
| 27 | { | |
| 28 | protected DNSDao dn sDao; | |
| 29 | ||
| 30 | stat ic DNSServ ice resour ce; | |
| 31 | ||
| 32 | abst ract class TestPlan extends Ba seTestPlan | |
| 33 | { | |
| 34 | protec ted DNSRec ord addedR ecord; | |
| 35 | ||
| 36 | @Overr ide | |
| 37 | protec ted void s etupMocks( ) | |
| 38 | { | |
| 39 | try | |
| 40 | { | |
| 41 | dnsDao = ( DNSDao)Con figService Runner.get SpringAppl icationCon text().get Bean("DNSD aoImpl"); | |
| 42 | ||
| 43 | resource = (DNS Service)Ba seTestPlan .getServic e(ConfigSe rviceRunne r.getRestA PIBaseURL( ), DNS_SER VICE); | |
| 44 | ||
| 45 | } | |
| 46 | catch (T hrowable t ) | |
| 47 | { | |
| 48 | throw new RuntimeExc eption(t); | |
| 49 | } | |
| 50 | } | |
| 51 | ||
| 52 | @Overr ide | |
| 53 | protec ted void t earDownMoc ks() | |
| 54 | { | |
| 55 | ||
| 56 | } | |
| 57 | ||
| 58 | protec ted DNSRec ord getDNS RecordToAd d() | |
| 59 | { | |
| 60 | ||
| 61 | addedRecor d = DNSUti ls.createA Record("my server.com ", PORT , " IP "); | |
| 62 | return a ddedRecord ; | |
| 63 | } | |
| 64 | ||
| 65 | protec ted abstra ct DNSReco rd getReco rdToUpdate (); | |
| 66 | ||
| 67 | @Overr ide | |
| 68 | protec ted void p erformInne r() throws Exception | |
| 69 | { | |
| 70 | ||
| 71 | final DN SRecord ad dRecord = getDNSReco rdToAdd(); | |
| 72 | ||
| 73 | if (addR ecord != n ull) | |
| 74 | { | |
| 75 | try | |
| 76 | { | |
| 77 | re source.add DNSRecord( addRecord) ; | |
| 78 | } | |
| 79 | catch (Ser viceExcept ion e) | |
| 80 | { | |
| 81 | th row e; | |
| 82 | } | |
| 83 | } | |
| 84 | ||
| 85 | final DN SRecord re cordToUpda te = getRe cordToUpda te(); | |
| 86 | ||
| 87 | try | |
| 88 | { | |
| 89 | resource.u pdatedDNSR ecord(reco rdToUpdate ); | |
| 90 | } | |
| 91 | catch (S erviceExce ption e) | |
| 92 | { | |
| 93 | throw e; | |
| 94 | } | |
| 95 | ||
| 96 | try | |
| 97 | { | |
| 98 | final Coll ection<DNS Record> ge tRecords = resource. getDNSReco rd(recordT oUpdate.ge tType(), r ecordToUpd ate.getNam e()); | |
| 99 | doAssertio ns(getReco rds); | |
| 100 | } | |
| 101 | catch (S erviceExce ption e) | |
| 102 | { | |
| 103 | throw e; | |
| 104 | } | |
| 105 | ||
| 106 | } | |
| 107 | ||
| 108 | ||
| 109 | protec ted void d oAssertion s(Collecti on<DNSReco rd> record s) throws Exception | |
| 110 | { | |
| 111 | ||
| 112 | } | |
| 113 | } | |
| 114 | ||
| 115 | @Tes t | |
| 116 | publ ic void te stUpdateDN SRecord_up dateExisti ngRecord_a ssertRecor dUpdated() throws Ex ception | |
| 117 | { | |
| 118 | new Te stPlan() | |
| 119 | { | |
| 120 | protecte d DNSRecor d updatedR ecord; | |
| 121 | ||
| 122 | @Overrid e | |
| 123 | protecte d DNSRecor d getRecor dToUpdate( ) | |
| 124 | { | |
| 125 | Collection <org.nhind irect.conf ig.store.D NSRecord> records = dnsDao.get (addedReco rd.getName (), addedR ecord.getT ype()); | |
| 126 | ||
| 127 | // should be one rec ord | |
| 128 | assertEqua ls(1, reco rds.size() ); | |
| 129 | ||
| 130 | org.nhindi rect.confi g.store.DN SRecord re cord = rec ords.itera tor().next (); | |
| 131 | record.set Name("serv er2.com.") ; | |
| 132 | ||
| 133 | updatedRec ord = Enti tyModelCon version.to ModelDNSRe cord(recor d); | |
| 134 | ||
| 135 | return upd atedRecord ; | |
| 136 | } | |
| 137 | ||
| 138 | @Overrid e | |
| 139 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 140 | { | |
| 141 | assertEqua ls(1, reco rds.size() ); | |
| 142 | ||
| 143 | DNSRecord record = r ecords.ite rator().ne xt(); | |
| 144 | ||
| 145 | assertEqua ls("server 2.com.", r ecord.getN ame()); | |
| 146 | assertTrue (Arrays.eq uals(updat edRecord.g etData(), record.get Data())); | |
| 147 | } | |
| 148 | }.perf orm(); | |
| 149 | } | |
| 150 | ||
| 151 | @Tes t | |
| 152 | publ ic void te stUpdateDN SRecord_up dateExisti ngRecord_n oDottedSuf fix_assert RecordUpda ted() thro ws Excepti on | |
| 153 | { | |
| 154 | new Te stPlan() | |
| 155 | { | |
| 156 | protecte d DNSRecor d updatedR ecord; | |
| 157 | ||
| 158 | @Overrid e | |
| 159 | protecte d DNSRecor d getRecor dToUpdate( ) | |
| 160 | { | |
| 161 | Collection <org.nhind irect.conf ig.store.D NSRecord> records = dnsDao.get (addedReco rd.getName (), addedR ecord.getT ype()); | |
| 162 | ||
| 163 | // should be one rec ord | |
| 164 | assertEqua ls(1, reco rds.size() ); | |
| 165 | ||
| 166 | org.nhindi rect.confi g.store.DN SRecord re cord = rec ords.itera tor().next (); | |
| 167 | record.set Name("serv er2.com"); | |
| 168 | ||
| 169 | updatedRec ord = Enti tyModelCon version.to ModelDNSRe cord(recor d); | |
| 170 | ||
| 171 | return upd atedRecord ; | |
| 172 | } | |
| 173 | ||
| 174 | @Overrid e | |
| 175 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 176 | { | |
| 177 | assertEqua ls(1, reco rds.size() ); | |
| 178 | ||
| 179 | DNSRecord record = r ecords.ite rator().ne xt(); | |
| 180 | ||
| 181 | assertEqua ls("server 2.com.", r ecord.getN ame()); | |
| 182 | assertTrue (Arrays.eq uals(updat edRecord.g etData(), record.get Data())); | |
| 183 | } | |
| 184 | }.perf orm(); | |
| 185 | } | |
| 186 | ||
| 187 | @Tes t | |
| 188 | publ ic void te stUpdateDN SRecord_re cordDoesnt Exist_asse rtNotFound () throws Exception | |
| 189 | { | |
| 190 | new Te stPlan() | |
| 191 | { | |
| 192 | protecte d DNSRecor d updatedR ecord; | |
| 193 | ||
| 194 | @Overrid e | |
| 195 | protecte d DNSRecor d getRecor dToUpdate( ) | |
| 196 | { | |
| 197 | updatedRec ord = DNSU tils.creat eARecord(" myserver.c om", PORT , " IP "); | |
| 198 | updatedRec ord.setId( 1233); | |
| 199 | return upd atedRecord ; | |
| 200 | } | |
| 201 | ||
| 202 | @Overrid e | |
| 203 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 204 | { | |
| 205 | assertTrue (exception instanceo f ServiceM ethodExcep tion); | |
| 206 | ServiceMet hodExcepti on ex = (S erviceMeth odExceptio n)exceptio n; | |
| 207 | assertEqua ls(404, ex .getRespon seCode()); | |
| 208 | } | |
| 209 | }.perf orm(); | |
| 210 | } | |
| 211 | ||
| 212 | @Tes t | |
| 213 | publ ic void te stUpdateDN SRecord_er rorInLooku p_assertSe rverError( ) throws E xception | |
| 214 | { | |
| 215 | new Te stPlan() | |
| 216 | { | |
| 217 | protecte d DNSRecor d updatedR ecord; | |
| 218 | ||
| 219 | protecte d DNSResou rce dnsSer vice; | |
| 220 | ||
| 221 | @Overrid e | |
| 222 | protecte d void set upMocks() | |
| 223 | { | |
| 224 | try | |
| 225 | { | |
| 226 | su per.setupM ocks(); | |
| 227 | ||
| 228 | dn sService = (DNSResou rce)Config ServiceRun ner.getSpr ingApplica tionContex t().getBea n("DNSReso urce"); | |
| 229 | ||
| 230 | DN SDao mockD AO = mock( DNSDao.cla ss); | |
| 231 | ||
| 232 | do Throw(new RuntimeExc eption()). when(mockD AO).get(eq (1233L)); | |
| 233 | ||
| 234 | dn sService.s etDNSDao(m ockDAO); | |
| 235 | } | |
| 236 | catch (Thr owable t) | |
| 237 | { | |
| 238 | th row new Ru ntimeExcep tion(t); | |
| 239 | } | |
| 240 | } | |
| 241 | ||
| 242 | @Overrid e | |
| 243 | protecte d void tea rDownMocks () | |
| 244 | { | |
| 245 | super.tear DownMocks( ); | |
| 246 | ||
| 247 | dnsService .setDNSDao (dnsDao); | |
| 248 | } | |
| 249 | ||
| 250 | @Overrid e | |
| 251 | protecte d DNSRecor d getDNSRe cordToAdd( ) | |
| 252 | { | |
| 253 | return nul l; | |
| 254 | } | |
| 255 | ||
| 256 | @Overrid e | |
| 257 | protecte d DNSRecor d getRecor dToUpdate( ) | |
| 258 | { | |
| 259 | updatedRec ord = DNSU tils.creat eARecord(" myserver.c om", PORT , " IP "); | |
| 260 | updatedRec ord.setId( 1233); | |
| 261 | return upd atedRecord ; | |
| 262 | } | |
| 263 | ||
| 264 | @Overrid e | |
| 265 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 266 | { | |
| 267 | assertTrue (exception instanceo f ServiceM ethodExcep tion); | |
| 268 | ServiceMet hodExcepti on ex = (S erviceMeth odExceptio n)exceptio n; | |
| 269 | assertEqua ls(500, ex .getRespon seCode()); | |
| 270 | } | |
| 271 | }.perf orm(); | |
| 272 | } | |
| 273 | ||
| 274 | @Tes t | |
| 275 | publ ic void te stUpdateDN SRecord_er rorInUpdat e_assertSe rverError( ) throws E xception | |
| 276 | { | |
| 277 | new Te stPlan() | |
| 278 | { | |
| 279 | protecte d DNSRecor d updatedR ecord; | |
| 280 | ||
| 281 | protecte d DNSResou rce dnsSer vice; | |
| 282 | ||
| 283 | @Overrid e | |
| 284 | protecte d void set upMocks() | |
| 285 | { | |
| 286 | try | |
| 287 | { | |
| 288 | su per.setupM ocks(); | |
| 289 | ||
| 290 | dn sService = (DNSResou rce)Config ServiceRun ner.getSpr ingApplica tionContex t().getBea n("DNSReso urce"); | |
| 291 | ||
| 292 | DN SDao mockD AO = mock( DNSDao.cla ss); | |
| 293 | ||
| 294 | wh en(mockDAO .get(1233L )).thenRet urn(new or g.nhindire ct.config. store.DNSR ecord()); | |
| 295 | do Throw(new RuntimeExc eption()). when(mockD AO).update (eq(1233L) , (org.nhi ndirect.co nfig.store .DNSRecord )any()); | |
| 296 | ||
| 297 | dn sService.s etDNSDao(m ockDAO); | |
| 298 | } | |
| 299 | catch (Thr owable t) | |
| 300 | { | |
| 301 | th row new Ru ntimeExcep tion(t); | |
| 302 | } | |
| 303 | } | |
| 304 | ||
| 305 | @Overrid e | |
| 306 | protecte d void tea rDownMocks () | |
| 307 | { | |
| 308 | super.tear DownMocks( ); | |
| 309 | ||
| 310 | dnsService .setDNSDao (dnsDao); | |
| 311 | } | |
| 312 | ||
| 313 | @Overrid e | |
| 314 | protecte d DNSRecor d getDNSRe cordToAdd( ) | |
| 315 | { | |
| 316 | return nul l; | |
| 317 | } | |
| 318 | ||
| 319 | @Overrid e | |
| 320 | protecte d DNSRecor d getRecor dToUpdate( ) | |
| 321 | { | |
| 322 | updatedRec ord = DNSU tils.creat eARecord(" myserver.c om", PORT , " IP "); | |
| 323 | updatedRec ord.setId( 1233); | |
| 324 | return upd atedRecord ; | |
| 325 | } | |
| 326 | ||
| 327 | @Overrid e | |
| 328 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 329 | { | |
| 330 | assertTrue (exception instanceo f ServiceM ethodExcep tion); | |
| 331 | ServiceMet hodExcepti on ex = (S erviceMeth odExceptio n)exceptio n; | |
| 332 | assertEqua ls(500, ex .getRespon seCode()); | |
| 333 | } | |
| 334 | }.perf orm(); | |
| 335 | } | |
| 336 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.